Library
Module
Module type
Parameter
Class
Class type
mapper
allows to implement AST rewriting using open recursion. A typical mapper would be based on default_mapper
, a deep identity mapper, and will fall back on it for handling the syntax it does not modify.
type mapper = {
document : mapper ->
Wikitext__.Wktxt_type.block list ->
Wikitext__.Wktxt_type.block list;
block : mapper -> Wikitext__.Wktxt_type.block -> Wikitext__.Wktxt_type.block;
table_block : mapper ->
Wikitext__.Wktxt_type.table_block ->
Wikitext__.Wktxt_type.table_block;
inline : mapper ->
Wikitext__.Wktxt_type.inline ->
Wikitext__.Wktxt_type.inline;
}
val default_mapper : mapper
A default mapper, which implements a "deep identity" mapping.
val toc :
Wikitext__.Wktxt_type.block list ->
(Wikitext__.Wktxt_type.block list * Wikitext__.Wktxt_type.block) option
toc doc
Compute the table of contents of doc
. This table of contents is computed by looking at headers. First level header is omitted. Table of contents is returned as un ordered list of links pointing to title's anchors.
set_toc doc
Replace "__TOC__"
in doc
by the auto-generated table of contents.
link sep str
A very basic link creation. No escaping is performed. Turn str
into a link ("<a href=\"%s\">%s</a>"
). If str
contains a sep
character, everything coming before is used as the url, and the rest as text.
set_links doc
Replace Link
and ExtLink
occurences by their HTML representation. using link
. Link
uses '|'
as separator and ExtLink
uses ' '
.