An HTML term is a Prolog term in which certain atoms and structures represent special functionality at the HTML level. It can be recursively a list of HTML terms. The following are legal HTML terms:
hello [hello, world] ['This is an ', em('HTML'), ' term']
html_term/3 in general leaves atoms in HTML terms unchanged, but translates structures into the corresponding format in HTML, applying then html_term/2 recursively to their arguments. For example, given the following code:
:- ['/usr/local/lib/prolog/html.pl']. main :- tell('html_simple.html'), icon_address(clip,ClipLogo), output_html([ start, title('Simple HTML document generated from Prolog'), image(ClipLogo), nl, heading(1,'Simple HTML document'), 'This document was produced with the ',tt('html.pl'),' library.', \\, 'It has facilities for:', itemize([ [em('Generating'),' HTML documents (including forms).'], [em('Parsing'),' input from HTML forms.'], [em('Producing'),' stand-alone forms handlers.'], etc ]), --, address('clip@dia.fi.upm.es'), end ]), told.Loading this code and calling main/0 produces the file html_simple.html, the contents of which are:
<html><title>Simple HTML document generated from Prolog</title> <img src="http://www.clip.dia.fi.upm.es/images/clip.gif"> <h1>Simple HTML document</h1> This document was produced with the <tt>html.pl</tt> library.<br> It has facilities for:<ul> <li> <em>Generating</em> HTML documents (including forms). <li> <em>Parsing</em> input from HTML forms. <li> <em>Producing</em> stand-alone forms handlers. <li> etc </ul> <hr> <address>clip@dia.fi.upm.es</address></html>
As was shown with the previous example, HTML terms may contain logic variables, provided they are instantiated before the term is translated or output. This allows creating documents piecemeal, backpatching of references in documents, etc.
In the following sections we list the meaning of the various Prolog structures that represent special functionality at the HTML level. Any atom not included here is assumed to be normal text and will be passed through to the HTML document. These sections are included for reference, but in any case the source file is clear enough (perhaps more than this description). You can also examine the example files.