
html_write.pl -- Write HTML text
The purpose of this library is to simplify writing HTML pages. Of course, it is possible to use format/3 to write to the HTML stream directly, but this is generally not very satisfactory:
- It is a lot of typing
- It does not guarantee proper HTML syntax. You have to deal with HTML quoting, proper nesting and reasonable layout.
- It is hard to use satisfactory abstraction
This module tries to remedy these problems. The idea is to translate a Prolog term into an HTML document. We use DCG for most of the generation.
International documents
The library supports the generation of international documents, but this is currently limited to using UTF-8 encoded HTML or XHTML documents. It is strongly recommended to use the following mime-type.
Content-type: text/html; charset=UTF-8
When generating XHTML documents, the output stream must be in UTF-8 encoding.
html_set_options(+Options) is det
- Set options for the HTML output. Options are stored in prolog
flags to ensure proper multi-threaded behaviour where setting an
option is local to the thread and new threads start with the
options from the parent thread. Defined options are:
- dialect(Dialect)
- One of
html4
,xhtml
orhtml5
(default). For compatibility reasons,html
is accepted as an alias forhtml4
. - doctype(+DocType)
- Set the
<|DOCTYPE
DocType>
line for page//1 and page//2. - content_type(+ContentType)
- Set the
Content-type
for reply_html_page/3
Note that the doctype and content_type flags are covered by distinct prolog flags:
html4_doctype
,xhtml_doctype
andhtml5_doctype
and similar for the content type. The Dialect must be switched before doctype and content type.
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
html(Arg1, Arg2, Arg3, Arg4)
print_html(Arg1)
html_print_length(Arg1, Arg2)
print_html(Arg1, Arg2)
html_meta(Arg1)
html_quoted(Arg1, Arg2, Arg3)
html_quoted_attribute(Arg1, Arg2, Arg3)
html_begin(Arg1, Arg2, Arg3)
html_end(Arg1, Arg2, Arg3)
html_post(Arg1, Arg2, Arg3, Arg4)
html_current_option(Arg1)
html_receive(Arg1, Arg2, Arg3)
html_receive(Arg1, Arg2, Arg3, Arg4)
xhtml_ns(Arg1, Arg2, Arg3, Arg4)
html(Arg1, Arg2, Arg3)
page(Arg1, Arg2, Arg3)
html_root_attribute(Arg1, Arg2, Arg3, Arg4)
page(Arg1, Arg2, Arg3, Arg4)
reply_html_page(Arg1, Arg2)
reply_html_page(Arg1, Arg2, Arg3)
page(Arg1, Arg2, Arg3, Arg4, Arg5)