eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HTMLParser':

Home

everywhere
www.exept.de
for:
[back]

Class: HTMLParser


Inheritance:

   Object
   |
   +--HTMLParser

Package:
stx:libhtml
Category:
System-Documentation
Version:
rev: 1.66 date: 2009/10/01 06:59:19
user: cg
file: HTMLParser.st directory: libhtml
module: stx stc-classLibrary: libhtml
Author:
Claus Gittinger

Description:


instances of this class are used to read HTML documents
and build a collection of markup elements.
This markup-collection can be displayed using the HTMLDocumentViewer
or printed by the HTMLDocumentPrinter.


Related information:

    HTMLMarkup
    HTMLDocumentView
    HTMLDocumentPainter
    HTMLDocumentPrinter

Class protocol:

initialization
o  initialize

o  initializeAmpersandEscapes

o  initializeMathAmpersandEscapes
these are obsolete now, as HTML4 added the missing stuff in the meantime.

parsing
o  parseText: aStringOrStream
parse aStringOrStream.and answer the parsed document

o  parseText: aStringOrStream characterEncoding: anEncodingString
parse aStringOrStream. The encoding of the character set is specified by anEncodingString
(e.g. #utf8 or 'iso8859-1').

Answer the parsed document


Instance protocol:

accessing
o  characterEncoding: aString
set the character set / ecoding for the following text

error reporting
o  infoMessage: msg

scanning
o  ampersandEscape
parse an ampersand escape; the '&' has already been read.

o  ampersandEscape: aString
return a new string, containing the ampersand escape character.
Expects aString to NOT contain the initial ampersand.

o  ampersandEscapeString
parse an ampersand escape; the '&' has already been read.
Return the escape string.

o  extractMetaInformationFrom: element

o  finishTextBlock
finish a scanned textBlock; add it to the markup list

o  finishTextBlockWithDecode: doDecode
finish a scanned textBlock; add it to the markup list

o  parseMarkup
parse '<' and return a markup element

o  parseText: aStringOrStream
parse some string, return a list of markups

o  parseText: aStringOrStream withBindings: metaBindings
parse some string, return a list of HTMLMarkups.
Ampersand variables (i.e. &url) are expanded as given in the
metabindings dictionary.
(this seems to be non-standard HTML, but is used in hotjava).
The destination is only required for scripts, which may want to access
document very early.

o  parseText: aStringOrStream withBindings: metaBindings for: aDestination
parse some string, return a list of HTMLMarkups.
Ampersand variables (i.e. &url) are expanded as given in the
metabindings dictionary.
(this seems to be non-standard HTML, but is used in hotjava).
The destination is only required for scripts, which may want to access
document very early.

o  startNewTextBlock

scripts
o  parseJavaScriptFrom: scriptStream

o  parseSmalltalkScriptFrom: scriptStream

o  script: element
a <script> TAG was encountered.
check for the language (which defaults to javaScript) and dispatch
to a script language handler.

o  script_javascript: element
a <script language=javaScript> TAG was encountered.
parse the script, and construct the scriptObject

o  script_smalltalkscript: element
a <script language=smalltalkScript> TAG was encountered.
parse the script, and construct the scriptObject (which has the methods in
its anonymous class)


Examples:



    |p in document|

    p := HTMLParser new.
    in := '../../doc/online/english/TOP.html' asFilename readStream.
    document := p parseText:in.
    in close.
    document inspect


    |v document|

    v := HTMLDocumentView new openAndWait.

    v homeDocument:'../../doc/online/english/TOP.html'.


    |top v document|

    top := StandardSystemView extent:200@500.
    v := HVScrollableView for:HTMLDocumentView miniScrollerH:true in:top.
    v origin:0.0@ 0.0 corner:1.0@1.0.
    top openAndWait.

    v homeDocument:'../../doc/online/english/TOP.html'.


    |v document|

    v := HTMLDocumentView new openAndWait.

    document := (HTMLParser new) 
                        parseText:('../../doc/online/english/programming/viewintro.html' 
                                        asFilename readStream).
    v document:document.



ST/X 6.1.1; WebServer 1.620 at exept:8081; Mon, 21 May 2012 17:41:36 GMT