Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / HTML & CSS Parsing

Author
Message
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Oct 2012 18:55
Has anybody experimented with HTML and CSS using DBPRO?

I am currently programming the Styc XML parser for my game interface, as well as other things. Using the traditional XML tags, the game's documentation and aspects of the interface will be designed in HTML.

I have posted a request for help with this at vWorker, because I want to see if I can someone to refine my work while I get on with other things; who knows, I will typically end up doing it all myself. The link to the project is here; and the WIP thread is linked through my signature banner.

So far I have produced the attached sub-program which draws the outline of what ever HTML document you feed it, and it uses Advanced2d to display its content on the screen.

In the future I will have the CSS parsed into a UDT to be used to describe display elements.

Obviously the attached sub-project is by no means a complete one [with only 4000 lines from the game and a couple of html files], the full game project currently has more or less 40,000 lines including Diggsey's TopGUI which can make this,



Look look more along the lines of this



It is a matter of plugging in this HTML library and calling a number of special drawing functions and basic image pasting routines.

Any tips on parsing HTML and CSS? I've attached the sub-project.

darkvee
20
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 25th Oct 2012 20:55
Hi it's not that hard to do.

1st you need a good word finder.
After that you use the word finder to find a certain command for example "font" Once it finds it you then make it search for the equal sign. Then you test if after the equal sign there is no spaces. After that it gets the values.

Once you can do this you can repeat this process and you will have a system that can look at html files and extract the data needed and feed it to the program to display everything your wanting.

I hope that helps you out.

darkvee
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Oct 2012 23:00
An HTML parser is harder than you may think darkvee. Mostly when it comes down to the layout components and how/where to position everything. There's a reason why there's only a handful of web browsers out there, and when you think about it several of them use another company's renderer.


I wrote an XML parser before, it might help you out.
http://forum.thegamecreators.com/?m=forum_view&t=179871&b=6

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Oct 2012 23:25
Thanks guys.

I will have a look at your XML parser. Although I am currently using the parser in Styx, it does have some issues.

I have actually made a good start parsing in the html tags and drawing them to the screen. I will not be putting too much effort into formatting paragraphs; but mostly table and form layouts.

One thing I need to add to my table parser, is the ability to sort the information. Any ideas on that? It seems I'd need to loop through the results, put them into a sorted array, then draw the information.

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 27th Oct 2012 08:42
That is interesting... keeping track

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Oct 2012 21:45
You need to keep track of each component's parent container.

Here's a really old snippet I did to build tables with the intention of eventually parsing HTML myself.
http://forum.thegamecreators.com/?m=forum_view&t=59415&b=6

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 24th Jan 2013 09:28
Ok I am back on this. Thanks Phaelax, I will study your example. I am simply going to use a GUI system to handle the events and drawing.

My job will be to recieve the HTML and convert it into GUI calls.

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Jan 2013 01:29 Edited at: 25th Jan 2013 03:12
I've been working with strings a lot lately and have some functions that might be useful to you. I made a quick example program that just finds the first tag on each line.


I feel like recursion might work well here. Here's a rough example:


It's kinda neat actually for a simple thing.

[edit]
Here's an example that reads from an external file:


And he's my "program":

Save that as a text file or make your own!

[edit]

Oh bugger it doesn't work in DBP Very strange.
Well I've attached a screenshot. -->



"I am a big dumb babby! " - TheComet
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Jan 2013 03:25
I am using MadBits XML plugin to read HTML; his plugin makes the job easy; what is difficult is the complexity of HTML, all of the tags you need to interpret. I am going to leave CSS out for now, but will use the class attribute as a function parameter for styling.

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Jan 2013 03:55
Working now:

It seems DBP doesn't like zero as a background colour.



"I am a big dumb babby! " - TheComet
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Jan 2013 06:53
Nice string functions

Login to post a reply

Server time is: 2026-07-08 17:35:50
Your offset time is: 2026-07-08 17:35:50