1 .\" $Id: mandoc_html.3,v 1.6 2017/03/13 19:01:38 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: March 13 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"
52 The mandoc HTML formatter is not a formal library.
53 However, as it is compiled into more than one program, in particular
57 and because it may be security-critical in some contexts,
58 some documentation is useful to help to use it correctly and
59 to prevent XSS vulnerabilities.
61 The formatter produces HTML output on the standard output.
62 Since proper escaping is usually required and best taken care of
63 at one central place, the language-specific formatters
69 are not supposed to print directly to
77 Instead, they are expected to use the output functions declared in
79 and implemented as part of the main HTML formatting engine in
82 These structures are declared in
86 Internal state of the HTML formatter.
88 One entry for the LIFO stack of HTML elements.
90 .Fa "enum htmltag tag"
92 .Fa "struct tag *next" .
94 .Ss Private interface functions
98 .Ao Pf \&? Ic xml ? Ac
100 .Aq Pf \&! Ic DOCTYPE
101 declarations required for the current document type.
109 elements for the document
119 which takes care of properly encoding attributes,
120 which is relevant for the
126 prints the start tag of an HTML element with the name
128 optionally including the attributes specified by
132 is the empty string, no attributes are written.
135 specifies one attribute to write.
136 Most attributes require one
138 argument which becomes the value of the attribute.
139 The arguments have to be given in the same order as the attribute letters.
142 the respective attribute is not written.
143 .Bl -tag -width 1n -offset indent
148 This attribute letter can optionally be followed by the modifier letter
152 attribute with the same value is also printed.
157 This attribute letter can optionally be followed by a modifier letter.
160 it formats the link as a local one by prefixing a
165 it interpretes the argument as a header file name
166 and generates a link using the
172 it takes two arguments instead of one, a manual page name and
173 section, and formats them as a link to a manual page using the
182 Print an arbitrary attribute.
183 This format letter requires two
185 arguments, the attribute name and the value.
192 If present, it must be the last format letter.
193 In contrast to the other format letters, this one does not yet
194 print the value and does not take an argument.
195 Instead, the rest of the format string consists of pairs of
196 argument type letters and style name letters.
199 Argument type letters each require on argument as follows:
200 .Bl -tag -width 1n -offset indent
204 argument, interpreted as a horizontal length in units of
209 argument, used as a style value.
213 argument, used as a length.
217 argument, interpreted as a vertical length in units of
222 argument, interpreted as an
227 nothing is printed for this pair.
231 but makes the width negative by multiplying it with \(mi1.
234 Style name letters decide what to do with the preceding argument:
235 .Bl -tag -width 1n -offset indent
270 The first is the style name, the second its value.
271 The style name must not be
276 uses the private function
278 to take care of HTML encoding.
279 If required by the element type, it remembers in
281 that the element is open.
284 is used to close out all open elements up to and including
287 is a variant to close out all open elements up to but excluding
292 prints HTML element content.
293 It uses the private function
295 to take care of HTML encoding.
296 If the document has requested a non-standard font, for example using a
299 font escape sequence,
303 in an HTML font selection element using the
315 are not yet documented.
317 .Bl -tag -width mandoc_aux.c -compact
319 declarations of public functions for use by the main program,
322 declarations of data types and private functions
323 for use by language-specific HTML formatters
325 main HTML formatting engine and utility functions
339 declarations of data types and private functions
340 for shared use by all mandoc formatters,
343 private functions for shared use by all mandoc formatters
345 declarations of common mandoc utility functions, see
348 implementation of common mandoc utility functions
356 The mandoc HTML formatter was written by
357 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
359 .An Ingo Schwarze Aq Mt schwarze@openbsd.org ,
360 who also wrote this manual.