Re: Anne Ogborn's html tutorial
Jan Wielemaker <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 08/05/2013 11:25 PM, Josef Frydl wrote:
> I am learning to use HTML generation via DCG as instructed in above.
> My question is are all HTML tags define as nonterminal? And is there one place, where there are documented?
>
> For example:
> phrase(
> html(html(
> [head(title('Howdy')),
> body([h1('A Simple Web Page'),
> p('With some text')])])),
> TokenizedHtml,
> []),
> head, h1, must be defined , but I could not find them. html_write documentation does not have p h1 etc>
They are not. The only non-terminal is html//1 (well, the
only principal one; there are some more level and some more
abstract based on it). html//1 takes as argument (among
others Element([Attributes], [Content]). The two argument
version always has attributes and content. If there is one
argument, these are the attributes for EMPTY tags (img, hr,
etc.) and the content for normal elements.
html//1 has some a table with info on HTML elements, basically
helping it to find empty elements (see above) and help getting
reasonable layout. It is happy to use myelement('Hello') and
renders this as <myelement>Hello</myelement>.
Cheers --- Jan
P.s. Note that in the latest version (stable and devel)
you can do
html({|html||
<h1>A Simple Web Page</h1>
<p>With some text
|}).
This is surely more comfortable for longer pieces of
HTML. I think Prolog terms are more comfortable
for HTML that is `mostly structure' and dynamically
generated.
>
> Thanks Josef Frydl
> -------------- next part --------------
> HTML attachment scrubbed and removed
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>