Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 02 Jul 2015, 08:47
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
thoughts on HTML-documentation-viewers
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message

Joined: 24 Aug 2005
Posts: 13644
Location: Karlsruhe, Germany

PostPosted: Mon 02 Jul 2007, 19:32    Post_subject:  thoughts on HTML-documentation-viewers  

Concerning News-log:

HTML-viewers can be pretty (gtkmoz-embedded) and large, or small and not very capable (Dillo).

Must documentation-browser be capable? No.

They must be able to do display:
add a link
insert a picture.
This is sufficient. Tables or coloured backgrounds would be nice, but are not strongly needed.

Following this assumption, Dillo is overkill Wink
Gtkbasic has a Textwidget. It currently misses an important part: markers.
With markers, you'd be able to display coloured, bold italic text and so on.
Gtkbasic also misses pixmap-support, but that is on top of my todo-list.

So if those functions would be implemented, you could write some Basic-code like this:

PSEUDO-Code, commands might not exist in this syntax:
thefile = readfile(thehelpfile)
for each theline in thefile

  // find position of bold text
  tstart = instr( theline , "<b>" )
  tend = instr( theline , "</b>" )

  // remove HTML-code
  replace ( theline , "<b>" , "" )
  replace ( theline , "</b>" , "" )

  //add it to the textwidget
  addline_to_textview( textview1 , theline )
  t = set_textmodifier("bold")
  gtk("gtk_modify_textview" , t , tstart , tend)

So you would parse a text for simple HTML-tags, and "translate" them into directives for the textview.

Instead of Gtkbasic you could write such parsers for any other language, that supports Textwidgets with support of typical modern layout-stuff.

Back to top
View user's profile Send_private_message Visit_website 
Puppy Master

Joined: 09 May 2005
Posts: 7441
Location: Perth, Western Australia

PostPosted: Tue 03 Jul 2007, 03:05    Post_subject:  

Yeah, I wrote a basic html parser for my little EVE vector editor a few years ago. It read the basic tags for italic, bold, text-color. I know nothing about the "proper" way to write parsers, just started coding.

But turning it into a fully-fledged html viewer is another thing.
Back to top
View user's profile Send_private_message Visit_website 

Joined: 24 Nov 2006
Posts: 132

PostPosted: Thu 05 Jul 2007, 03:26    Post_subject:  

I did a crude XML parser in VB once that wasn't so different, one of the nice things about xml/html is that it was designed to be parsed so it tends to be easy to do.

Couple of problems I can see, first is I looked at the gtk text widget and I am wondering if it supports hyperlinks?

Second is that type of search-and-replace involves a lot of memory reallocation, especially if you use a a high level language which often use create new, copy, destroy old for every string operation. I have found in the past that these can seem to work well on a small file but slow down dramatically with large files (I also found to my cost once that string operations in VB take roughly 1000 times longer once the string is over 32KB).

So I think a better way to do this is allocate memory once for the processed string, then work through copying from the old string byte by byte, but looking ahead for tags and translating them on the fly. In pseudocode something like


OldLength = Length(OldString)
String NewString(OldLength * 2)  // extra length just in case

OldMarker = 0
NewMarker = 0

While (OldMarker < OldLength)

    If (OldString(Marker) <> "<")
         'Copy Character
         NewString(NewMarker) = OldString(OldMarker)
         'Process Tag, Update Markers


I think there is one calley tinyxml on sourceforge that uses this method in C++

Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0555s ][ Queries: 12 (0.0050s) ][ GZIP on ]