UNPKG

@ciao-lang/ts-ciao-interface

Version:

Simple Ciao interface for node.

124 lines (119 loc) 28.6 kB
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta name="theme-color" content="#273f79"/><link rel="stylesheet" href="lpdoc.css" type="text/css"/><script type="text/javascript" src="lpdoc.js"></script><title>HTML/XML parser and generator &mdash; The Ciao System v1.22</title></head><body><div class="lpdoc-page fixleftbar"><a href="#" id="sidebar-toggle-button" class="lpdoc-navbutton"><span id="sidebar-button-arrow">&#9776;</span></a><div id="sidebar" class="lpdoc-sidebar"><div style="height: 40px; margin-left: auto; margin-right: auto"><img src="ciao-logo_autofig.png" width=auto height=100%></div><div class="lpdoc-nav"><span class="lpdoc-on-right"><a class="lpdoc-navbutton" href="pillow_doc.html">&#x2191;</a><a class="lpdoc-navbutton" href="pillow_doc.html">&#x2190;</a><a class="lpdoc-navbutton" href="json.html">&#x2192;</a><a class="lpdoc-navbutton" href="ciaosearch.html">&#x1F50D;</a></span><span><a href="ciaofulltoc.html">TOC</a></span></div><hr></hr><ul class="lpdoc-itemize-sectpath"><li><a href="ciao.html">The Ciao System</a> &raquo;<br/> </li><li><a href="ExtraLibs.html">PART VIII - Additional libraries</a> &raquo;<br/> </li><li><a href="pillow_doc.html">Web programming libraries (PiLLoW)</a> &raquo;<br/> </li><li><a href=""><strong>HTML/XML parser and generator</strong></a></li></ul><hr></hr><em>ON THIS PAGE</em><ul><li><a href="#Usage and interface">Usage and interface</a></li><li><a href="#Documentation on exports">Documentation on exports</a></li><li><a href="#Documentation on multifiles">Documentation on multifiles</a></li><li><a href="#Documentation on imports">Documentation on imports</a></li><li><a href="#Other information">Other information</a></li></ul></div><div class="lpdoc-main"><div id=""><h1>HTML/XML parser and generator</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#html"></a> <strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="Daniel Cabeza" href="ciaosearch.html#Daniel Cabeza">Daniel Cabeza</a>, <a class="lpdoc-idx-anchor" id="Manuel Hermenegildo" href="ciaosearch.html#Manuel Hermenegildo">Manuel Hermenegildo</a>, <a class="lpdoc-idx-anchor" id="Sacha Varma" href="ciaosearch.html#Sacha Varma">Sacha Varma</a>, <a class="lpdoc-idx-anchor" id="The Ciao Development Team" href="ciaosearch.html#The Ciao Development Team">The Ciao Development Team</a>.<p> This module implements predicates for <a class="lpdoc-idx-anchor" id="0" href="ciaosearch.html#HTML">HTML</a>/<a class="lpdoc-idx-anchor" id="1" href="ciaosearch.html#XML">XML</a> generation and parsing.<br/><div id="Usage and interface"><h2>Usage and interface</h2><div class="lpdoc-cartouche"><ul><li><strong>Library usage:</strong><br/><tt>:- use_module(library(pillow/html)).</tt><li><strong>Exports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Predicates:</em><br/><a class="lpdoc-idx-anchor" id="2" href="#output_html/1"><tt>output_html/1</tt></a>, <a class="lpdoc-idx-anchor" id="3" href="#html2terms/2"><tt>html2terms/2</tt></a>, <a class="lpdoc-idx-anchor" id="4" href="#xml2terms/2"><tt>xml2terms/2</tt></a>, <a class="lpdoc-idx-anchor" id="5" href="#html_template/3"><tt>html_template/3</tt></a>. <li><em>Regular Types:</em><br/><a class="lpdoc-idx-anchor" id="6" href="#canonic_html_term/1"><tt>canonic_html_term/1</tt></a>, <a class="lpdoc-idx-anchor" id="7" href="#canonic_xml_term/1"><tt>canonic_xml_term/1</tt></a>, <a class="lpdoc-idx-anchor" id="8" href="#html_term/1"><tt>html_term/1</tt></a>. <li><em>Multifiles:</em><br/><a class="lpdoc-idx-anchor" id="9" href="#html_expansion/2"><tt>html_expansion/2</tt></a>. </ul></ul></div></div><div id="Documentation on exports"><h2>Documentation on exports</h2><div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="canonic_html_term/1" href="ciaosearch.html#canonic_html_term/1">canonic_html_term/1</a></div><div class="lpdoc-deftext">A term representing HTML code in canonical, structured way. It is a list of terms defined by the following predicate: <pre class="lpdoc-codeblock">canonic_html_item(comment(S)) :- string(S). canonic_html_item(declare(S)) :- string(S). canonic_html_item(env(Tag,Atts,Terms)) :- atm(Tag), list(tag_attrib,Atts), canonic_html_term(Terms). canonic_html_item($(Tag,Atts)) :- atm(Tag), list(tag_attrib,Atts). canonic_html_item(S) :- string(S). </pre> <pre class="lpdoc-codeblock">tag_attrib(Att) :- atm(Att). tag_attrib(Att=Val) :- atm(Att), string(Val). </pre> Each structure represents one HTML construction: <dl> <p><dt><strong>env(</strong><em>tag</em><strong>,</strong><em>attribs</em><strong>,</strong><em>terms</em><strong>)</strong><dd> An HTML environment, with name <em>tag</em>, list of attributes <em>attribs</em> and contents <em>terms</em>.<p><dt><strong>$(</strong><em>tag</em><strong>,</strong><em>attribs</em><strong>)</strong><dd> An HTML element of name <em>tag</em> and list of attributes <em>attribs</em>. <tt>($)/2</tt> is defined by the pillow package as an infix, binary operator.<p><dt><strong>comment(</strong><em>string</em><strong>)</strong><dd> An HTML comment (translates to/from <tt>&lt;!--</tt><em>string</em><tt>--&gt;</tt>).<p><dt><strong>declare(</strong><em>string</em><strong>)</strong><dd> An HTML declaration, they are used only in the header (translates to/from <tt>&lt;!</tt><em>string</em><tt>&gt;</tt>).<p><dt><em>string</em><dd> Normal text is represented as a list of character codes.<p></dl> <p>For example, the term <pre class="lpdoc-codeblock">env(a,[href=&quot;www.therainforestsite.com&quot;], [&quot;Visit &quot;,img$[src=&quot;TRFS.gif&quot;]]) </pre> is output to (or parsed from): <pre class="lpdoc-codeblock">&lt;a href=&quot;www.therainforestsite.com&quot;&gt;Visit &lt;img src=&quot;TRFS.gif&quot;&gt;&lt;/a&gt; </pre><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>canonic_html_term(HTMLTerm)</tt> </span><p><span class="lpdoc-var">HTMLTerm</span> is a term representing HTML code in canonical form.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="canonic_xml_term/1" href="ciaosearch.html#canonic_xml_term/1">canonic_xml_term/1</a></div><div class="lpdoc-deftext">A term representing XML code in canonical, structured way. It is a list of terms defined by the following predicate (see <a class="lpdoc-idx-anchor" id="10" href="ciaosearch.html#tag_attrib/1"><tt>tag_attrib/1</tt></a> definition in <a class="lpdoc-idx-anchor" id="11" href="#canonic_html_term/1"><tt>canonic_html_term/1</tt></a>): <pre class="lpdoc-codeblock">canonic_xml_item(Term) :- canonic_html_item(Term). canonic_xml_item(xmldecl(Atts)) :- list(tag_attrib,Atts). canonic_xml_item(env(Tag,Atts,Terms)) :- atm(Tag), list(tag_attrib,Atts), canonic_xml_term(Terms). canonic_xml_item(elem(Tag,Atts)) :- atm(Tag), list(tag_attrib,Atts). </pre> In addition to the structures defined by <a class="lpdoc-idx-anchor" id="12" href="#canonic_html_term/1"><tt>canonic_html_term/1</tt></a> (the <tt>($)/2</tt> structure appears only in malformed XML code), the following structures can be used: <dl> <p><dt><strong>elem(</strong><em>tag</em><strong>,</strong><em>atts</em><strong>)</strong><dd> Specifies an XML empty element of name <em>tag</em> and list of attributes <em>atts</em>. For example, the term <pre class="lpdoc-codeblock">elem(arc,[weigh=&quot;3&quot;,begin=&quot;n1&quot;,end=&quot;n2&quot;]) </pre> is output to (or parsed from): <pre class="lpdoc-codeblock">&lt;arc weigh=&quot;3&quot; begin=&quot;n1&quot; end=&quot;n2&quot;/&gt; </pre> <p><dt><strong>xmldecl(</strong><em>atts</em><strong>)</strong><dd> Specifies an XML declaration with attributes <em>atts</em> (translates to/from <tt>&lt;?xml </tt><em>atts</em><tt>?&gt;</tt>)<p></dl><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>canonic_xml_term(XMLTerm)</tt> </span><p><span class="lpdoc-var">XMLTerm</span> is a term representing XML code in canonical form.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="html_term/1" href="ciaosearch.html#html_term/1">html_term/1</a></div><div class="lpdoc-deftext">A term which represents HTML or XML code in a structured way. In addition to the structures defined by <a class="lpdoc-idx-anchor" id="13" href="#canonic_html_term/1"><tt>canonic_html_term/1</tt></a> or <a class="lpdoc-idx-anchor" id="14" href="#canonic_xml_term/1"><tt>canonic_xml_term/1</tt></a>, the following structures can be used: <dl> <p><dt><strong>begin(</strong><em>tag</em><strong>,</strong><em>atts</em><strong>)</strong><dd> It translates to the start of an HTML environment of name <em>tag</em> and attributes <em>atts</em>. There exists also a <strong>begin(<em>tag</em>)</strong> structure. Useful, in conjunction with the next structure, when including in a document output generated by an existing piece of code (e.g. <em>tag</em> = <tt>pre</tt>). Its use is otherwise discouraged.<p><dt><strong>end(</strong><em>tag</em><strong>)</strong><dd> Translates to the end of an HTML environment of name <em>tag</em>.<p><dt><strong>start</strong><dd> Used at the beginning of a document (translates to <tt>&lt;html&gt;</tt>).<p><dt><strong>end</strong><dd> Used at the end of a document (translates to <tt>&lt;/html&gt;</tt>).<p><dt><tt>--</tt><dd> Produces a horizontal rule (translates to <tt>&lt;hr&gt;</tt>).<p><dt><strong>\</strong><dd> Produces a line break (translates to <tt>&lt;br&gt;</tt>).<p><dt><strong>$</strong><dd> Produces a paragraph break (translates to <tt>&lt;p&gt;</tt>).<p><dt><strong>image(</strong><em>address</em><strong>)</strong><dd> Used to include an image of address (URL) <em>address</em> (equivalent to <tt>img$[src=</tt><em>address</em><tt>]</tt>).<p><dt><strong>image(</strong><em>address</em><strong>,</strong><em>atts</em><strong>)</strong><dd> As above with the list of attributes <em>atts</em>.<p><dt><strong>ref(</strong><em>address</em><strong>,</strong><em>text</em><strong>)</strong><dd> Produces a hypertext link, <em>address</em> is the URL of the referenced resource, <em>text</em> is the text of the reference (equivalent to <tt>a([href=</tt><em>address</em><tt>],</tt><em>text</em><tt>)</tt>).<p><dt><strong>label(</strong><em>name</em><strong>,</strong><em>text</em><strong>)</strong><dd> Labels <em>text</em> as a target destination with label <em>name</em> (equivalent to <tt>a([name=</tt><em>name</em><tt>],</tt><em>text</em><tt>)</tt>).<p><dt><strong>heading(</strong><em>n</em><strong>,</strong><em>text</em><strong>)</strong><dd> Produces a heading of level <em>n</em> (between 1 and 6), <em>text</em> is the text to be used as heading. Useful when one wants a heading level relative to another heading (equivalent to <tt>h</tt><em>n</em><tt>(</tt><em>text</em><tt>)</tt>).<p><dt><strong>itemize(</strong><em>items</em><strong>)</strong><dd> Produces a list of bulleted items, <em>items</em> is a list of corresponding HTML terms (translates to a <tt>&lt;ul&gt;</tt> environment).<p><dt><strong>enumerate(</strong><em>items</em><strong>)</strong><dd> Produces a list of numbered items, <em>items</em> is a list of corresponding HTML terms (translates to a <tt>&lt;ol&gt;</tt> environment).<p><dt><strong>description(</strong><em>defs</em><strong>)</strong><dd> Produces a list of defined items, <em>defs</em> is a list whose elements are definitions, each of them being a Prolog sequence (composed by <tt>&apos;,&apos;/2</tt> operators). The last element of the sequence is the definition, the other (if any) are the defined terms (translates to a <tt>&lt;dl&gt;</tt> environment).<p><dt><strong>preformatted(</strong><em>text</em><strong>)</strong><dd> Used to include preformatted text, <em>text</em> is a list of HTML terms, each element of the list being a line of the resulting document (translates to a <tt>&lt;pre&gt;</tt> environment).<p><dt><strong>verbatim(</strong><em>text</em><strong>)</strong><dd> Used to include text verbatim, special HTML characters (<tt>&lt;,&gt;,&amp;,&quot;</tt> and space) are translated into its quoted HTML equivalent.<p><dt><strong>prolog_term(</strong><em>term</em><strong>)</strong><dd> Includes any prolog term <em>term</em>, represented in functional notation. Variables are output as <tt>_</tt>.<p><dt><strong>nl</strong><dd> Used to include a newline in the HTML source (just to improve human readability).<p><dt><strong>entity(</strong><em>name</em><strong>)</strong><dd> Includes the entity of name <em>name</em> (ISO-8859-1 special character).<p><dt><strong>start_form(</strong><em>addr</em><strong>,</strong><em>atts</em><strong>)</strong><dd> Specifies the beginning of a form. <em>addr</em> is the address (URL) of the program that will handle the form, and <em>atts</em> other attributes of the form, as the method used to invoke it. If <em>atts</em> is not present (there is only one argument) the method defaults to POST.<p><dt><strong>start_form</strong><dd> Specifies the beginning of a form without assigning address to the handler.<p><dt><strong>end_form</strong><dd> Specifies the end of a form.<p><dt><strong>checkbox(</strong><em>name</em><strong>,</strong><em>state</em><strong>)</strong><dd> Specifies an input of type <tt>checkbox</tt> with name <em>name</em>, <em>state</em> is <tt>on</tt> if the checkbox is initially checked.<p><dt><strong>radio(</strong><em>name</em><strong>,</strong><em>value</em><strong>,</strong><em>selected</em><strong>)</strong><dd> Specifies an input of type <tt>radio</tt> with name <em>name</em> (several radio buttons which are interlocked must share their name), <em>value</em> is the the value returned by the button, if <em>selected</em>=<em>value</em> the button is initially checked.<p><dt><strong>input(</strong><em>type</em><strong>,</strong><em>atts</em><strong>)</strong><dd> Specifies an input of type <em>type</em> with a list of attributes <em>atts</em>. Possible values of <em>type</em> are <tt>text</tt>, <tt>hidden</tt>, <tt>submit</tt>, <tt>reset</tt>, ldots<p><dt><strong>textinput(</strong><em>name</em><strong>,</strong><em>atts</em><strong>,</strong><em>text</em><strong>)</strong><dd> Specifies an input text area of name <em>name</em>. <em>text</em> provides the default text to be shown in the area, <em>atts</em> a list of attributes.<p><dt><strong>option(</strong><em>name</em><strong>,</strong><em>val</em><strong>,</strong><em>options</em><strong>)</strong><dd> Specifies a simple option selector of name <em>name</em>, <em>options</em> is the list of available options and <em>val</em> is the initial selected option (if <em>val</em> is not in <em>options</em> the first item is selected by default) (translates to a <tt>&lt;select&gt;</tt> environment).<p><dt><strong>menu(</strong><em>name</em><strong>,</strong><em>atts</em><strong>,</strong><em>items</em><strong>)</strong><dd> Specifies a menu of name <em>name</em>, list of attributes <em>atts</em> and list of options <em>items</em>. The elements of the list <em>items</em> are marked with the prefix operator <tt>$</tt> to indicate that they are selected (translates to a <tt>&lt;select&gt;</tt> environment).<p><dt><em>name</em><strong>(</strong><em>text</em><strong>)</strong><dd> A term with functor <em>name</em>/1, different from the special functors defined herein, represents an HTML environment of name <em>name</em> and included text <em>text</em>. For example, the term <pre class="lpdoc-codeblock"> address(&apos;clip@clip.dia.fi.upm.es&apos;) </pre> is translated into the HTML source <pre class="lpdoc-codeblock"> &lt;address&gt;clip@clip.dia.fi.upm.es&lt;/address&gt; </pre> <p><dt><em>name</em><strong>(</strong><em>atts</em><strong>,</strong><em>text</em><strong>)</strong><dd> A term with functor <em>name</em>/2, different from the special functors defined herein, represents an HTML environment of name <em>name</em>, attributes <em>atts</em> and included text <em>text</em>. For example, the term <pre class="lpdoc-codeblock"> a([href=&apos;http://www.clip.dia.fi.upm.es/&apos;],&quot;Clip home&quot;) </pre> represents the HTML source <pre class="lpdoc-codeblock"> &lt;a href=&quot;http://www.clip.dia.fi.upm.es/&quot;&gt;Clip home&lt;/a&gt; </pre> <p></dl> <p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>html_term(HTMLTerm)</tt> </span><p><span class="lpdoc-var">HTMLTerm</span> is a term representing HTML code.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="output_html/1" href="ciaosearch.html#output_html/1">output_html/1</a></div><div class="lpdoc-deftext"><span class="lpdoc-usage-decl"><tt>output_html(HTMLTerm)</tt> </span><p>Outputs <span class="lpdoc-var">HTMLTerm</span>, interpreted as an <a class="lpdoc-idx-anchor" id="15" href="#html_term/1"><tt>html_term/1</tt></a>, to current output stream.<p><span class="lpdoc-usage-header">Usage:</span><p></p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="16" href="#html_term/1"><tt>html:html_term/1</tt></a>)</span><span><span class="lpdoc-var">HTMLTerm</span> is a term representing HTML code. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="html2terms/2" href="ciaosearch.html#html2terms/2">html2terms/2</a></div><div class="lpdoc-deftext"><span class="lpdoc-usage-decl"><tt>html2terms(String,Terms)</tt> </span><p><span class="lpdoc-var">String</span> is a character list containing HTML code and <span class="lpdoc-var">Terms</span> is its prolog structured representation.<p><span class="lpdoc-usage-header">Usage 1:</span><p>Translates an HTML-term into the HTML code it represents.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="17" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">String</span> is a free variable. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="18" href="#html_term/1"><tt>html:html_term/1</tt></a>)</span><span><span class="lpdoc-var">Terms</span> is a term representing HTML code. </span> <li><em>The following properties should hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="19" href="basic_props.html#string/1"><tt>basic_props:string/1</tt></a>)</span><span><span class="lpdoc-var">String</span> is a string (a list of character codes). </span> </ul><p><span class="lpdoc-usage-header">Usage 2:</span><p>Translates HTML code into a structured HTML-term.</p><ul class="lpdoc-itemize-minus"><li><em>Call and exit should be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="20" href="#canonic_html_term/1"><tt>html:canonic_html_term/1</tt></a>)</span><span><span class="lpdoc-var">Terms</span> is a term representing HTML code in canonical form. </span> <li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="21" href="basic_props.html#string/1"><tt>basic_props:string/1</tt></a>)</span><span><span class="lpdoc-var">String</span> is a string (a list of character codes). </span> <li><em>The following properties should hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="22" href="#canonic_html_term/1"><tt>html:canonic_html_term/1</tt></a>)</span><span><span class="lpdoc-var">Terms</span> is a term representing HTML code in canonical form. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="xml2terms/2" href="ciaosearch.html#xml2terms/2">xml2terms/2</a></div><div class="lpdoc-deftext"><span class="lpdoc-usage-decl"><tt>xml2terms(String,Terms)</tt> </span><p><span class="lpdoc-var">String</span> is a character list containing XML code and <span class="lpdoc-var">Terms</span> is its prolog structured representation.<p><span class="lpdoc-usage-header">Usage 1:</span><p>Translates a XML-term into the XML code it represents.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="23" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">String</span> is a free variable. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="24" href="#html_term/1"><tt>html:html_term/1</tt></a>)</span><span><span class="lpdoc-var">Terms</span> is a term representing HTML code. </span> <li><em>The following properties should hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="25" href="basic_props.html#string/1"><tt>basic_props:string/1</tt></a>)</span><span><span class="lpdoc-var">String</span> is a string (a list of character codes). </span> </ul><p><span class="lpdoc-usage-header">Usage 2:</span><p>Translates XML code into a structured XML-term.</p><ul class="lpdoc-itemize-minus"><li><em>Call and exit should be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="26" href="#canonic_xml_term/1"><tt>html:canonic_xml_term/1</tt></a>)</span><span><span class="lpdoc-var">Terms</span> is a term representing XML code in canonical form. </span> <li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="27" href="basic_props.html#string/1"><tt>basic_props:string/1</tt></a>)</span><span><span class="lpdoc-var">String</span> is a string (a list of character codes). </span> <li><em>The following properties should hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="28" href="#canonic_xml_term/1"><tt>html:canonic_xml_term/1</tt></a>)</span><span><span class="lpdoc-var">Terms</span> is a term representing XML code in canonical form. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="html_template/3" href="ciaosearch.html#html_template/3">html_template/3</a></div><div class="lpdoc-deftext"><span class="lpdoc-usage-decl"><tt>html_template(Chars,Terms,Dict)</tt> </span><p>Interprets <span class="lpdoc-var">Chars</span> as an HTML template returning in <span class="lpdoc-var">Terms</span> the corresponding structured HTML-term, which includes variables, and unifying <span class="lpdoc-var">Dict</span> with a dictionary of those variables (an incomplete list of <em>name</em><tt>=</tt><em>Var</em> pairs). An HTML template is standard HTML code, but in which ``slots&apos;&apos; can be defined and given an identifier. These slots represent parts of the HTML code in which other HTML code can be inserted, and are represented in the HTML-term as free variables. There are two kinds of variables in templates: <ul> <p><li>Variables representing page contents. A variable with name <em>name</em> is defined with the special tag <tt>&lt;V&gt;</tt><em>name</em><tt>&lt;/V&gt;</tt>.<p><li>Variables representing tag attributes. They occur as an attribute or an attribute value starting with <tt>_</tt>, followed by its name, which must be formed by alphabetic characters.<p></ul> <p>As an example, suposse the following HTML template: <pre class="lpdoc-codeblock">&lt;html&gt; &lt;body bgcolor=_bgcolor&gt; &lt;v&gt;content&lt;/v&gt; &lt;/body&gt; &lt;/html&gt; </pre> The following query in the Ciao toplevel shows how the template is parsed, and the dictionary returned: <pre class="lpdoc-codeblock">?- file_to_string(&apos;template.html&apos;,_S), html_template(_S,Terms,Dict). Dict = [bgcolor=_A,content=_B|_], Terms = [env(html,[],[&quot; &quot;,env(body,[bgcolor=_A],[&quot; &quot;,_B,&quot; &quot;]),&quot; &quot;]),&quot; &quot;] ? yes </pre> If a dictionary with values is supplied at call time, then variables are unified accordingly inside the template: <pre class="lpdoc-codeblock">?- file_to_string(&apos;template.html&apos;,_S), html_template(_S,Terms,[content=b(&quot;hello world!&quot;),bgcolor=&quot;white&quot;]). Terms = [env(html,[],[&quot; &quot;,env(body,[bgcolor=&quot;white&quot;],[&quot; &quot;,b(&quot;hello world!&quot;),&quot; &quot;]),&quot; &quot;]),&quot; &quot;] ? yes </pre> <p><span class="lpdoc-usage-header">Usage:</span><p></p><ul class="lpdoc-itemize-minus"><li><em>Call and exit should be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="29" href="#canonic_html_term/1"><tt>html:canonic_html_term/1</tt></a>)</span><span><span class="lpdoc-var">Terms</span> is a term representing HTML code in canonical form. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="30" href="basic_props.html#list/1"><tt>basic_props:list/1</tt></a>)</span><span><span class="lpdoc-var">Dict</span> is a list. </span> <li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="31" href="basic_props.html#string/1"><tt>basic_props:string/1</tt></a>)</span><span><span class="lpdoc-var">Chars</span> is a string (a list of character codes). </span> <li><em>The following properties should hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="32" href="#canonic_html_term/1"><tt>html:canonic_html_term/1</tt></a>)</span><span><span class="lpdoc-var">Terms</span> is a term representing HTML code in canonical form. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="33" href="basic_props.html#list/1"><tt>basic_props:list/1</tt></a>)</span><span><span class="lpdoc-var">Dict</span> is a list. </span> </ul></div></div><p> </div><div id="Documentation on multifiles"><h2>Documentation on multifiles</h2><div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="html_expansion/2" href="ciaosearch.html#html_expansion/2">html_expansion/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>html_expansion(Term,Expansion)</tt> </span><p>Hook predicate to define macros. Expand occurrences of <span class="lpdoc-var">Term</span> into <span class="lpdoc-var">Expansion</span>, in <a class="lpdoc-idx-anchor" id="34" href="#output_html/1"><tt>output_html/1</tt></a>. Take care to not transform something into itself!</p><ul class="lpdoc-itemize-minus"></ul> The predicate is <em>multifile</em>.<br/></div></div><p> </div><div id="Documentation on imports"><h2>Documentation on imports</h2>This module has the following direct dependencies:<ul class="lpdoc-itemize-minus"><li><em>System library modules:</em><br/><a class="lpdoc-idx-anchor" id="35" href="stream_utils.html"><tt>stream_utils</tt></a>, <a class="lpdoc-idx-anchor" id="36" href="strings.html"><tt>strings</tt></a>, <a class="lpdoc-idx-anchor" id="37" href="lists.html"><tt>lists</tt></a>. <li><em>Packages:</em><br/><a class="lpdoc-idx-anchor" id="38" href="ciaosearch.html#prelude"><tt>prelude</tt></a>, <a class="lpdoc-idx-anchor" id="39" href="ciaosearch.html#initial"><tt>initial</tt></a>, <a class="lpdoc-idx-anchor" id="40" href="condcomp_doc.html"><tt>condcomp</tt></a>, <a class="lpdoc-idx-anchor" id="41" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="42" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>, <a class="lpdoc-idx-anchor" id="43" href="isomodes_doc.html"><tt>isomodes</tt></a>, <a class="lpdoc-idx-anchor" id="44" href="dcg_doc.html"><tt>dcg</tt></a>. </ul></div><div id="Other information"><h2>Other information</h2> The code uses input from from L. Naish&apos;s forms and Francisco Bueno&apos;s previous Chat interface. Other people who have contributed are (please inform us if we leave out anybody): Markus Fromherz.<br/></div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>