|MANDOC_HTML(3)||Library Functions Manual||MANDOC_HTML(3)|
internals of the mandoc HTML formatter
html *h, struct roff_node
struct tag *
print_otag(struct html *h,
enum htmltag tag, const char
print_tagq(struct html *h,
const struct tag *until);
print_stagq(struct html *h,
const struct tag *suntil);
print_text(struct html *h,
const char *word);
html_make_id(const struct roff_node
html_strlen(const char *cp);
The mandoc HTML formatter is not a formal library. However, as it is compiled into more than one program, in particular mandoc(1) and man.cgi(8), and because it may be security-critical in some contexts, some documentation is useful to help to use it correctly and to prevent XSS vulnerabilities.
The formatter produces HTML output on the standard output. Since
proper escaping is usually required and best taken care of at one central
place, the language-specific formatters (*_html.c,
see FILES) are not supposed to print
stdout using functions like
they are expected to use the output functions declared in
html.h and implemented as part of the main HTML
formatting engine in html.c.
These structures are declared in html.h.
prints the opening ⟨?
DOCTYPE⟩ declarations required for
the current document type.
prints the leading comments, usually containing a Copyright notice and
license, as an HTML comment. It is intended to be called right after opening
HTML⟩ element. Pass the first
ROFFT_COMMENT node in n.
prints the opening ⟨
LINK⟩ elements for the document
HEAD⟩, using the
style member of h unless that is
NULL. It uses
which takes care of properly encoding attributes, which is relevant for the
style link in particular.
prints the start tag of an HTML element with the name
tag, optionally including the attributes specified by
fmt. If fmt is the empty string,
no attributes are written. Each letter of fmt
specifies one attribute to write. Most attributes require one
char * argument which becomes the value of the
attribute. The arguments have to be given in the same order as the attribute
letters. If an argument is
NULL, the respective
attribute is not written.
hrefattribute. This attribute letter can optionally be followed by a modifier letter. If followed by
R, it formats the link as a local one by prefixing a ‘#’ character. If followed by
I, it interpretes the argument as a header file name and generates a link using the mandoc(1)
includesoption. If followed by
M, it takes two arguments instead of one, a manual page name and section, and formats them as a link to a manual page using the mandoc(1)
styleattribute. If present, it must be the last format letter. It requires two char * arguments. The first is the name of the style property, the second its value. The name must not be
sfmt letter can be repeated, each repetition requiring an additional pair of char * arguments.
uses the private function
to take care of HTML encoding. If required by the element type, it remembers
in h that the element is open. The function
is used to close out all open elements up to and including
is a variant to close out all open elements up to but excluding
prints HTML element content. It uses the private function
to take care of HTML encoding. If the document has requested a non-standard
font, for example using a roff(7)
\f font escape sequence,
print_text() wraps word in an
HTML font selection element using the
takes a node containing one or more text children and returns a newly
allocated string containing the concatenation of the child strings, with
blanks replaced by underscores. If the node n contains
any non-text child node,
NULL instead. The caller is responsible for freeing
the returned string.
counts the number of characters in cp. It is used as a
crude estimate of the width needed to display a string.
|January 11, 2019||OpenBSD 6.7|