1 .\" $Id: mandoc_html.3,v 1.17 2018/06/25 16:54:59 schwarze Exp $
3 .\" Copyright (c) 2014, 2017, 2018 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: June 25 2018 $
22 .Nd internals of the mandoc HTML formatter
26 .Fn print_gen_decls "struct html *h"
28 .Fn print_gen_comment "struct html *h" "struct roff_node *n"
30 .Fn print_gen_head "struct html *h"
34 .Fa "enum htmltag tag"
41 .Fa "const struct tag *until"
46 .Fa "const struct tag *suntil"
51 .Fa "const char *word"
55 .Fa "const struct roff_node *n"
62 The mandoc HTML formatter is not a formal library.
63 However, as it is compiled into more than one program, in particular
67 and because it may be security-critical in some contexts,
68 some documentation is useful to help to use it correctly and
69 to prevent XSS vulnerabilities.
71 The formatter produces HTML output on the standard output.
72 Since proper escaping is usually required and best taken care of
73 at one central place, the language-specific formatters
79 are not supposed to print directly to
87 Instead, they are expected to use the output functions declared in
89 and implemented as part of the main HTML formatting engine in
92 These structures are declared in
96 Internal state of the HTML formatter.
98 One entry for the LIFO stack of HTML elements.
100 .Fa "enum htmltag tag"
102 .Fa "struct tag *next" .
104 .Ss Private interface functions
108 .Ao Pf \&? Ic xml ? Ac
110 .Aq Pf \&! Ic DOCTYPE
111 declarations required for the current document type.
114 .Fn print_gen_comment
115 prints the leading comments, usually containing a Copyright notice
116 and license, as an HTML comment.
117 It is intended to be called right after opening the
131 elements for the document
141 which takes care of properly encoding attributes,
142 which is relevant for the
148 prints the start tag of an HTML element with the name
150 optionally including the attributes specified by
154 is the empty string, no attributes are written.
157 specifies one attribute to write.
158 Most attributes require one
160 argument which becomes the value of the attribute.
161 The arguments have to be given in the same order as the attribute letters.
164 the respective attribute is not written.
165 .Bl -tag -width 1n -offset indent
170 This attribute letter can optionally be followed by the modifier letter
174 attribute with the same value is also printed.
179 This attribute letter can optionally be followed by a modifier letter.
182 it formats the link as a local one by prefixing a
187 it interpretes the argument as a header file name
188 and generates a link using the
194 it takes two arguments instead of one, a manual page name and
195 section, and formats them as a link to a manual page using the
204 Print an arbitrary attribute.
205 This format letter requires two
207 arguments, the attribute name and the value.
214 If present, it must be the last format letter.
218 The first is the name of the style property, the second its value.
222 uses the private function
224 to take care of HTML encoding.
225 If required by the element type, it remembers in
227 that the element is open.
230 is used to close out all open elements up to and including
233 is a variant to close out all open elements up to but excluding
238 prints HTML element content.
239 It uses the private function
241 to take care of HTML encoding.
242 If the document has requested a non-standard font, for example using a
245 font escape sequence,
249 in an HTML font selection element using the
257 takes a node containing one or more text children
258 and returns a newly allocated string containing the concatenation
259 of the child strings, with blanks replaced by underscores.
262 contains any non-text child node,
267 The caller is responsible for freeing the returned string.
271 counts the number of characters in
273 It is used as a crude estimate of the width needed to display a string.
280 are not yet documented.
282 .Bl -tag -width mandoc_aux.c -compact
284 declarations of public functions for use by the main program,
287 declarations of data types and private functions
288 for use by language-specific HTML formatters
290 main HTML formatting engine and utility functions
304 declarations of data types and private functions
305 for shared use by all mandoc formatters,
308 private functions for shared use by all mandoc formatters
310 declarations of common mandoc utility functions, see
313 implementation of common mandoc utility functions
321 The mandoc HTML formatter was written by
322 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
324 .An Ingo Schwarze Aq Mt schwarze@openbsd.org ,
325 who also wrote this manual.