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 Tue 02 Sep 2014, 03:32
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 [3 Posts]  
Author Message
MU


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

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

Concerning News-log:
http://puppylinux.com/news/comments.php?y=07&m=07&entry=entry070702-083738


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:
fat
italic
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:
Code:
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)
next


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.

Mark
Back to top
View user's profile Send private message Visit poster's website 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7047
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 poster's website 
DavidBell

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

Code:

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)
         NewMarker++
         OldMarker++
    Else
         'Process Tag, Update Markers
    EndIf

Loop



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

DB
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


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