
The _browser.ss_ library in the "browser" collection provides the
following procedures and classes for parsing and viewing _HTML_ files.
The _htmltext.ss_ library provides a simplified interface for
rendering to a subclass of the MrEd text% class.

The browser (and htmltext) supports basic HTML commands, plus special
Scheme hyperlinks of the form <A MZSCHEME=sexpr>...</A>. When the user
clicks on such a link, the string `sexpr' is parsed as a Scheme
program and evaluated. Since `sexpr' is likely to contain Scheme
strings, and since escape characters are difficult for people to read,
a vertical bar (|) character in sexpr is converted to a double-quote
(") character before it is parsed. Thus,

  <A MZSCHEME="|This goes nowhere.|">Nowhere</A>

creates a "Nowhere" hyperlink, which executes the Scheme program

  "This goes nowhere."

The value of that program is a string. When a Scheme hyperlink returns
a string, it is parsed as a new HTML document. Thus, where the use
clicks on "Nowhere", the result is a new page that says "This goes
nowhere."

The browser also treats comment forms containing MZSCHEME=sexpr
specially.  Whereas the <A MZSCHEME=sexpr>...</A> form executes the
expression when the user clicks, the MZSCHEME expression in a comment
is executed immediately during HTML rendering. If the result is a
string, the comment is replaced in the input HTML stream with the
content of the string. Thus,

 <!-- MZSCHEME="(format |<B>Here</B>: ~a| (current-directory))" -->

inserts the path of the current working directory into the containing
document (and "Here" is boldfaced). If the result is a snip instead of
a string, it replaces the comment in the document. Other types of
return values are ignored.

If the html file is being accessed as a "file:" url, the
current-load-relative-directory parameter is set to the directory
during the evaluation of the mzscheme code (in both examples). The
Scheme code is executed through `eval'.

The MZSCHEME forms are disabled unless the web page is a
file: url that points into the `doc' collection.

----------------------------------------

> (open-url url) - Opens the given url
  (either a string, url record, or port) 
  in a vanilla browser frame and returns
  the frame. The frame is an instance of
  hyper-frame%.
  
-----------------------------------------

The html-img-ok parameter controls image rendering for the browser.

> (html-img-ok on?) - Sets the value of the parameter to on?
> (html-img-ok) - Returns the current value of the parameter

The html-eval-ok parameter controls the evaluation of 
`MZSCHEME=' tags. If the parameter is #f, they are disabled.

> (html-eval-ok on?) - Sets the value of the parameter to on?
> (html-eval-ok) - Returns the current value of the parameter


------------------------------------------------------------

> (hyper-frame-mixin frame%) - Extends the given frame% class.

> get-hyper-panel% :: (send hyper-frame get-hyper-panel%)
  returns the class that is instantiated with the frame is created.
  Must be a panel with hyper-panel-mixin mixed in. Defaults to
  just returning hyper-panel%.

> get-hyper-panel :: (send hyper-frame get-hyper-panel) - returns the hyper panel
  in this frame
  
----------------------------------------

> hyper-frame% = (hyper-frame-mixin frame%)

----------------------------------------

> (hyper-text-mixin text%) - Extends the given text% class. The
   initializtion arguments are extended with a three new first
   arguments: a url or a port to be loaded into the text% object, a
   top-level-window or #f to use as a parent for status dialogs, and a
   progress procedure used as for `get-url'.

   Sets the autowrap-bitmap to #f.
   
   An instance of a (hyper-text-mixin text%) class should be displayed
   only in an instance of a class created with `hyper-canvas-mixin'
   (described below).

   The mixin adds the following instance variables:

>   map-shift-style :: (send o map-shift-style start end shift-style)
     Maps the given style over the given range

>   make-link-style :: (send o make-link-style start end)
     Changes the style for the given range to the link style

>   get-url :: (send o get-url)
     Returns the URL displayed by the editor, or #f if there
     is none.

>   get-title :: (send o get-title)
>   set-title :: (send o set-title string)
     Gets or sets the page's title

>   hyper-delta
     A style-delta% object; override it to set the link style

>   add-tag ::(send o add-tag name-string pos)
     Installs a tag.

>   find-tag :: (send o find-tag name-string/number)
     Finds the location of a tag in the buffer (where tags are
     installed in HTML with <A NAME="name">) and returns its
     position. If `name' is a number, the number is returned (assumed
     to be an offset rather than a tag). Otherwise, if the tag is not
     found, #f is returned.

>   remove-tag :: (send o remove-tag name)
     Removes a tag.

>   add-link :: (send o add-link start end url-string)
     Installs a hyperlink.

>   add-scheme-callback :: (send o add-scheme-callback start end scheme-string)
     Installs a Scheme evaluation hyperlink.

>   eval-scheme-string :: (send o eval-scheme-string string)
     Called to handle the <A MZSCHEME="expr">...</A> tag and <!
     MZSCHEME="expr"> comments (see above). Evaluates the string; if
     the result is a string, it is opened as an HTML page.

>  reload :: (send o reload)

    Reloads the current page.
     
----------------------------------------

> hyper-text% = (hyper-text-mixin text:keymap%)

  This is an extension of the keymap class, to support standard keybindings
  in the browser window.

----------------------------------------

> (hyper-canvas-mixin editor-canvas%) - Extends the given
  editor-canvas% class. The intialization arguments are unchanged.

  The canvas's parent should be an instance of a class derived with
  `hyper-panel-mixin' (described below).

  The mixin adds the following instance variables:

>   make-editor :: (send o make-editor url)
     Creates an hypertext editor for the canvas, called to navigate
     among hypertext pages. Changing the page changes the editor in
     the canvas, and the page history is maintained by keeping the old
     editors.
 
>   get-editor% :: (send o get-editor%)
     Returns the class used to implement the editor in the browser
     window. It should be derived from hyper-text% and should pass on the
     initialization arguments to hyper-text%


>   current-page :: (send o current-page)
     Returns a reprsentation of the currently displayed page, which
     includes a particular editor and a visible range within the
     editor.
 
>   goto-url :: (send o goto-url url relative-to-url [progress-proc])
     Changes to the given url, loading it by calling the `make-editor'
     method. If `relative-to-url' is not #f, it must be a URL for
     resolving `url' as a relative URL.
     `url' may also be a port. If it is, relative-to-url must be #f.

     The `progress-proc' procedure is called with a boolean at the
     point where the URL has been resolved and enough progress has
     been made to dismiss any message that the URL is being
     resolved. The procedure is called with #t if the URL will be
     loaded into a browser window, #f otherwise (e.g., the user will
     save the URL content to a file).

>   set-page :: (send o set-page page notify?)
     Changes to the given page. If `notify?' is not #f, the canvas's
     parent is notified about the change by calling its `leaving-page'
     method.

>   after-set-page :: (send o after-set-page)
     Called during `set-page'. Defaultly does nothing.

----------------------------------------

> hyper-canvas% = (hyper-canvas-mixin editor-canvas%)

----------------------------------------

> (hyper-panel-mixin area-container%) - Extends the given area
  container class. The initialization arguments are unchanged, but
  initialization creates controls and a hyper text canvas.  The
  controls permit a user to move back and forth in the hypertext
  history.

  The mixin adds a initialization argument, info-line?, which is a
  boolean indicating whether the browser should contain a line to
  display special "DOCNOTE" tags in a page. Such tags are used
  primarily by the PLT documentation.

  The mixin adds the following instance variables:

>   make-canvas :: (send o make-canvas container)
     Creates the panel's hypertext canvas, an instance of a class
     derived using `hyper-canvas-mixin' (described above). This
     method is called during initialization.

>   get-canvas% :: (send o get-canvas%)
     Returns the class instantiated by make-canvas. It must be derived from
     hyper-canvas% 


>   make-control-bar-panel :: (send o make-control-bar-panel container)
     Create's the panel's sub-container for the control bar containing
     the navigation buttons. If #f is returned, the panel will have no
     control bar. The default method instantiates horizontal-panel%.

>   rewind :: (send o rewind)
     Goes back one page, if possible.

>   forward :: (send o forward)
     Goes forward one page, if possible.

>   get-canvas :: (send o get-canvas)
     Gets the hypertext canvas.

>   on-navigate :: (send o on-navigate)
     Callback that is invoked any time the displayed hypertext page
     changes (either by clicking on a link in the canvas or by
     `rewind' or `forward' calls).

>   leaving-page :: (send o leaving-page page new-page)
     This method is called by the hypertext canvas to notify the
     panel that the hypertext page changed. The `page' is #f
     if `new-page' is the first page for the canvas. See also
     `page->editor' (decsribed below).

>   filter-notes :: (send o filter-notes list-of-strings)
     Given the notes from a page as a list of strings (where
     each string is a note), returns a single string to print
     above the page.

>   reload :: (send o reload)

   Reloads the currently visible page by calling the reload method of
   the currently displayed hyper-text.
----------------------------------------

> hyper-panel% = (hyper-panel-mixin vertical-panel%)

----------------------------------------

> (editor->page editor) - Creates a page record for the given editor,
  suitable for use with the `set-page' method of hyper-canvas-mixin.

> (page->editor page) - Extracts the editor from a page record.

> (on-installer-run [proc]) - Parameter for a procedure to be invoked
  after the installer is run on a .plt file

> (bullet-size [n]) - Parameter controlling the point size of a
  bullet

-----------------------------------------

The _browser-unit.ss_ library in the "browser" collection is a
unitized version of the code documented above.  It imports unit
matching thefollowing signatures:

    setup:plt-installer^
    mred^

 It exports the browser^ signature.
 
-----------------------------------------

The _browser-sig.ss_ library in the "browser" collection defines
the browser^ signature with all of the names listed above.


========================================
htmltext.ss
========================================

> html-text<%>

An interface that extends text% with the following methods:

> get-url :: (send t get-url) --- returns a base URL used for building
  relative URLs, or #f if no base is available

> set-title :: (send t set-title str) --- registers the title `str'
  for the rendered page

> add-link :: (send t add-link start-pos end-pos url-string) ---
  registers a hyperlink for the given region in rendered page

> add-tag :: (send t label pos) --- registers a tag at the given
  position in the rendered page

> make-link-style :: (send t make-link-style start-pos end-pos) ---
  modifies the style of the rendered page from start-pos to end-pos to
  look like a hyperlink

> add-scheme-callback :: (send t add-scheme-callback pos endpos code-string)
  --- registers a code-evaluating hyperlink for the given region

----------------------------------------

> (html-text-mixin text%-subclass) -> html-text<%> implementation

Extends the given text% class with implementations of the html-text<%>
methods. Hyperlinks are attched to clickbacks that use `send-url'
(from the "sendurl.ss" library of the "net" collection).

> (render-html-to-text input-port html-text<%>-obj load-img? eval-mz?)

Reads HTML from `input-port' and renders it to `html-text<%>-obj'.  If
`load-img?' is false, then images are rendered as Xed-out boxes. If
`eval-mz?' is false, then MZSCHEME hyperlink expressions and comments
are not evaluated.

