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.
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:
- One of
html5(default). For compatibility reasons,
htmlis accepted as an alias for
- Set the
>line for page//1 and page//2.
- Set the
Note that the doctype and content_type flags are covered by distinct prolog flags:
html5_doctypeand similar for the content type. The Dialect must be switched before doctype and content type.
The following predicates are exported, but not or incorrectly documented.
- html(Arg1, Arg2, Arg3, Arg4)
- html_print_length(Arg1, Arg2)
- print_html(Arg1, Arg2)
- 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_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)