1 .\" $Id: mandoc_html.3,v 1.10 2017/07/15 17:57:51 schwarze Exp $
3 .\" Copyright (c) 2014, 2017 Ingo Schwarze <schwarze@openbsd.org>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .Dd $Mdocdate: July 15 2017 $
22 .Nd internals of the mandoc HTML formatter
26 .Fn print_gen_decls "struct html *h"
28 .Fn print_gen_head "struct html *h"
32 .Fa "enum htmltag tag"
39 .Fa "const struct tag *until"
44 .Fa "const struct tag *suntil"
49 .Fa "const char *word"
53 .Fa "const struct roff_node *n"
60 The mandoc HTML formatter is not a formal library.
61 However, as it is compiled into more than one program, in particular
65 and because it may be security-critical in some contexts,
66 some documentation is useful to help to use it correctly and
67 to prevent XSS vulnerabilities.
69 The formatter produces HTML output on the standard output.
70 Since proper escaping is usually required and best taken care of
71 at one central place, the language-specific formatters
77 are not supposed to print directly to
85 Instead, they are expected to use the output functions declared in
87 and implemented as part of the main HTML formatting engine in
90 These structures are declared in
94 Internal state of the HTML formatter.
96 One entry for the LIFO stack of HTML elements.
98 .Fa "enum htmltag tag"
100 .Fa "struct tag *next" .
102 .Ss Private interface functions
106 .Ao Pf \&? Ic xml ? Ac
108 .Aq Pf \&! Ic DOCTYPE
109 declarations required for the current document type.
117 elements for the document
127 which takes care of properly encoding attributes,
128 which is relevant for the
134 prints the start tag of an HTML element with the name
136 optionally including the attributes specified by
140 is the empty string, no attributes are written.
143 specifies one attribute to write.
144 Most attributes require one
146 argument which becomes the value of the attribute.
147 The arguments have to be given in the same order as the attribute letters.
150 the respective attribute is not written.
151 .Bl -tag -width 1n -offset indent
156 This attribute letter can optionally be followed by the modifier letter
160 attribute with the same value is also printed.
165 This attribute letter can optionally be followed by a modifier letter.
168 it formats the link as a local one by prefixing a
173 it interpretes the argument as a header file name
174 and generates a link using the
180 it takes two arguments instead of one, a manual page name and
181 section, and formats them as a link to a manual page using the
190 Print an arbitrary attribute.
191 This format letter requires two
193 arguments, the attribute name and the value.
200 If present, it must be the last format letter.
201 In contrast to the other format letters, this one does not yet
202 print the value and does not take an argument.
203 Instead, the rest of the format string consists of pairs of
204 argument type letters and style name letters.
207 Argument type letters each require one argument as follows:
208 .Bl -tag -width 1n -offset indent
212 argument, interpreted as a horizontal length in units of
217 argument, used as a style value.
221 argument, used as a length.
225 argument, interpreted as an
230 nothing is printed for this pair.
234 argument type letter can optionally be followed by one, two, or three
238 suppresses printing of the pair if the argument matches 6n.
241 increases the width by 20% to make even bold text fit
242 and adds three units for padding between columns.
245 makes the width negative by multiplying it with \-1.
248 Style name letters decide what to do with the preceding argument:
249 .Bl -tag -width 1n -offset indent
276 The first is the style name, the second its value.
277 The style name must not be
282 uses the private function
284 to take care of HTML encoding.
285 If required by the element type, it remembers in
287 that the element is open.
290 is used to close out all open elements up to and including
293 is a variant to close out all open elements up to but excluding
298 prints HTML element content.
299 It uses the private function
301 to take care of HTML encoding.
302 If the document has requested a non-standard font, for example using a
305 font escape sequence,
309 in an HTML font selection element using the
317 takes a node containing one or more text children
318 and returns a newly allocated string containing the concatenation
319 of the child strings, with blanks replaced by underscores.
322 contains any non-text child node,
327 The caller is responsible for freeing the returned string.
331 counts the number of characters in
333 It is used as a crude estimate of the width needed to display a string.
340 are not yet documented.
342 .Bl -tag -width mandoc_aux.c -compact
344 declarations of public functions for use by the main program,
347 declarations of data types and private functions
348 for use by language-specific HTML formatters
350 main HTML formatting engine and utility functions
364 declarations of data types and private functions
365 for shared use by all mandoc formatters,
368 private functions for shared use by all mandoc formatters
370 declarations of common mandoc utility functions, see
373 implementation of common mandoc utility functions
381 The mandoc HTML formatter was written by
382 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
384 .An Ingo Schwarze Aq Mt schwarze@openbsd.org ,
385 who also wrote this manual.