xref: /freebsd/contrib/mandoc/mandoc_html.3 (revision 6d38604fc532a3fc060788e3ce40464b46047eaf)
1*6d38604fSBaptiste Daroussin.\"	$Id: mandoc_html.3,v 1.23 2020/04/24 13:13:06 schwarze Exp $
261d06d6bSBaptiste Daroussin.\"
361d06d6bSBaptiste Daroussin.\" Copyright (c) 2014, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
461d06d6bSBaptiste Daroussin.\"
561d06d6bSBaptiste Daroussin.\" Permission to use, copy, modify, and distribute this software for any
661d06d6bSBaptiste Daroussin.\" purpose with or without fee is hereby granted, provided that the above
761d06d6bSBaptiste Daroussin.\" copyright notice and this permission notice appear in all copies.
861d06d6bSBaptiste Daroussin.\"
961d06d6bSBaptiste Daroussin.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1061d06d6bSBaptiste Daroussin.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1161d06d6bSBaptiste Daroussin.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1261d06d6bSBaptiste Daroussin.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1361d06d6bSBaptiste Daroussin.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1461d06d6bSBaptiste Daroussin.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1561d06d6bSBaptiste Daroussin.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1661d06d6bSBaptiste Daroussin.\"
17*6d38604fSBaptiste Daroussin.Dd $Mdocdate: April 24 2020 $
1861d06d6bSBaptiste Daroussin.Dt MANDOC_HTML 3
1961d06d6bSBaptiste Daroussin.Os
2061d06d6bSBaptiste Daroussin.Sh NAME
2161d06d6bSBaptiste Daroussin.Nm mandoc_html
2261d06d6bSBaptiste Daroussin.Nd internals of the mandoc HTML formatter
2361d06d6bSBaptiste Daroussin.Sh SYNOPSIS
24*6d38604fSBaptiste Daroussin.In sys/types.h
25*6d38604fSBaptiste Daroussin.Fd #include """mandoc.h"""
26*6d38604fSBaptiste Daroussin.Fd #include """roff.h"""
27*6d38604fSBaptiste Daroussin.Fd #include """out.h"""
28*6d38604fSBaptiste Daroussin.Fd #include """html.h"""
2961d06d6bSBaptiste Daroussin.Ft void
3061d06d6bSBaptiste Daroussin.Fn print_gen_decls "struct html *h"
3161d06d6bSBaptiste Daroussin.Ft void
3261d06d6bSBaptiste Daroussin.Fn print_gen_comment "struct html *h" "struct roff_node *n"
3361d06d6bSBaptiste Daroussin.Ft void
3461d06d6bSBaptiste Daroussin.Fn print_gen_head "struct html *h"
3561d06d6bSBaptiste Daroussin.Ft struct tag *
3661d06d6bSBaptiste Daroussin.Fo print_otag
3761d06d6bSBaptiste Daroussin.Fa "struct html *h"
3861d06d6bSBaptiste Daroussin.Fa "enum htmltag tag"
3961d06d6bSBaptiste Daroussin.Fa "const char *fmt"
4061d06d6bSBaptiste Daroussin.Fa ...
4161d06d6bSBaptiste Daroussin.Fc
4261d06d6bSBaptiste Daroussin.Ft void
4361d06d6bSBaptiste Daroussin.Fo print_tagq
4461d06d6bSBaptiste Daroussin.Fa "struct html *h"
4561d06d6bSBaptiste Daroussin.Fa "const struct tag *until"
4661d06d6bSBaptiste Daroussin.Fc
4761d06d6bSBaptiste Daroussin.Ft void
4861d06d6bSBaptiste Daroussin.Fo print_stagq
4961d06d6bSBaptiste Daroussin.Fa "struct html *h"
5061d06d6bSBaptiste Daroussin.Fa "const struct tag *suntil"
5161d06d6bSBaptiste Daroussin.Fc
5261d06d6bSBaptiste Daroussin.Ft void
53*6d38604fSBaptiste Daroussin.Fn html_close_paragraph "struct html *h"
54*6d38604fSBaptiste Daroussin.Ft enum roff_tok
55*6d38604fSBaptiste Daroussin.Fo html_fillmode
56*6d38604fSBaptiste Daroussin.Fa "struct html *h"
57*6d38604fSBaptiste Daroussin.Fa "enum roff_tok tok"
58*6d38604fSBaptiste Daroussin.Fc
59*6d38604fSBaptiste Daroussin.Ft int
60*6d38604fSBaptiste Daroussin.Fo html_setfont
61*6d38604fSBaptiste Daroussin.Fa "struct html *h"
62*6d38604fSBaptiste Daroussin.Fa "enum mandoc_esc font"
63*6d38604fSBaptiste Daroussin.Fc
64*6d38604fSBaptiste Daroussin.Ft void
6561d06d6bSBaptiste Daroussin.Fo print_text
6661d06d6bSBaptiste Daroussin.Fa "struct html *h"
6761d06d6bSBaptiste Daroussin.Fa "const char *word"
6861d06d6bSBaptiste Daroussin.Fc
69*6d38604fSBaptiste Daroussin.Ft void
70*6d38604fSBaptiste Daroussin.Fo print_tagged_text
71*6d38604fSBaptiste Daroussin.Fa "struct html *h"
72*6d38604fSBaptiste Daroussin.Fa "const char *word"
73*6d38604fSBaptiste Daroussin.Fa "struct roff_node *n"
74*6d38604fSBaptiste Daroussin.Fc
7561d06d6bSBaptiste Daroussin.Ft char *
7661d06d6bSBaptiste Daroussin.Fo html_make_id
7761d06d6bSBaptiste Daroussin.Fa "const struct roff_node *n"
78*6d38604fSBaptiste Daroussin.Fa "int unique"
7961d06d6bSBaptiste Daroussin.Fc
80*6d38604fSBaptiste Daroussin.Ft struct tag *
81*6d38604fSBaptiste Daroussin.Fo print_otag_id
82*6d38604fSBaptiste Daroussin.Fa "struct html *h"
83*6d38604fSBaptiste Daroussin.Fa "enum htmltag tag"
84*6d38604fSBaptiste Daroussin.Fa "const char *cattr"
85*6d38604fSBaptiste Daroussin.Fa "struct roff_node *n"
8661d06d6bSBaptiste Daroussin.Fc
87*6d38604fSBaptiste Daroussin.Ft void
88*6d38604fSBaptiste Daroussin.Fn print_endline "struct html *h"
8961d06d6bSBaptiste Daroussin.Sh DESCRIPTION
9061d06d6bSBaptiste DaroussinThe mandoc HTML formatter is not a formal library.
9161d06d6bSBaptiste DaroussinHowever, as it is compiled into more than one program, in particular
9261d06d6bSBaptiste Daroussin.Xr mandoc 1
9361d06d6bSBaptiste Daroussinand
9461d06d6bSBaptiste Daroussin.Xr man.cgi 8 ,
9561d06d6bSBaptiste Daroussinand because it may be security-critical in some contexts,
9661d06d6bSBaptiste Daroussinsome documentation is useful to help to use it correctly and
9761d06d6bSBaptiste Daroussinto prevent XSS vulnerabilities.
9861d06d6bSBaptiste Daroussin.Pp
9961d06d6bSBaptiste DaroussinThe formatter produces HTML output on the standard output.
10061d06d6bSBaptiste DaroussinSince proper escaping is usually required and best taken care of
10161d06d6bSBaptiste Daroussinat one central place, the language-specific formatters
10261d06d6bSBaptiste Daroussin.Po
10361d06d6bSBaptiste Daroussin.Pa *_html.c ,
10461d06d6bSBaptiste Daroussinsee
10561d06d6bSBaptiste Daroussin.Sx FILES
10661d06d6bSBaptiste Daroussin.Pc
10761d06d6bSBaptiste Daroussinare not supposed to print directly to
10861d06d6bSBaptiste Daroussin.Dv stdout
10961d06d6bSBaptiste Daroussinusing functions like
11061d06d6bSBaptiste Daroussin.Xr printf 3 ,
11161d06d6bSBaptiste Daroussin.Xr putc 3 ,
11261d06d6bSBaptiste Daroussin.Xr puts 3 ,
11361d06d6bSBaptiste Daroussinor
11461d06d6bSBaptiste Daroussin.Xr write 2 .
11561d06d6bSBaptiste DaroussinInstead, they are expected to use the output functions declared in
11661d06d6bSBaptiste Daroussin.Pa html.h
11761d06d6bSBaptiste Daroussinand implemented as part of the main HTML formatting engine in
11861d06d6bSBaptiste Daroussin.Pa html.c .
11961d06d6bSBaptiste Daroussin.Ss Data structures
12061d06d6bSBaptiste DaroussinThese structures are declared in
12161d06d6bSBaptiste Daroussin.Pa html.h .
12261d06d6bSBaptiste Daroussin.Bl -tag -width Ds
12361d06d6bSBaptiste Daroussin.It Vt struct html
12461d06d6bSBaptiste DaroussinInternal state of the HTML formatter.
12561d06d6bSBaptiste Daroussin.It Vt struct tag
12661d06d6bSBaptiste DaroussinOne entry for the LIFO stack of HTML elements.
127*6d38604fSBaptiste DaroussinMembers include
12861d06d6bSBaptiste Daroussin.Fa "enum htmltag tag"
12961d06d6bSBaptiste Daroussinand
13061d06d6bSBaptiste Daroussin.Fa "struct tag *next" .
13161d06d6bSBaptiste Daroussin.El
13261d06d6bSBaptiste Daroussin.Ss Private interface functions
13361d06d6bSBaptiste DaroussinThe function
13461d06d6bSBaptiste Daroussin.Fn print_gen_decls
13561d06d6bSBaptiste Daroussinprints the opening
13661d06d6bSBaptiste Daroussin.Aq Pf \&! Ic DOCTYPE
137*6d38604fSBaptiste Daroussindeclaration.
13861d06d6bSBaptiste Daroussin.Pp
13961d06d6bSBaptiste DaroussinThe function
14061d06d6bSBaptiste Daroussin.Fn print_gen_comment
14161d06d6bSBaptiste Daroussinprints the leading comments, usually containing a Copyright notice
14261d06d6bSBaptiste Daroussinand license, as an HTML comment.
14361d06d6bSBaptiste DaroussinIt is intended to be called right after opening the
14461d06d6bSBaptiste Daroussin.Aq Ic HTML
14561d06d6bSBaptiste Daroussinelement.
14661d06d6bSBaptiste DaroussinPass the first
14761d06d6bSBaptiste Daroussin.Dv ROFFT_COMMENT
14861d06d6bSBaptiste Daroussinnode in
14961d06d6bSBaptiste Daroussin.Fa n .
15061d06d6bSBaptiste Daroussin.Pp
15161d06d6bSBaptiste DaroussinThe function
15261d06d6bSBaptiste Daroussin.Fn print_gen_head
15361d06d6bSBaptiste Daroussinprints the opening
15461d06d6bSBaptiste Daroussin.Aq Ic META
15561d06d6bSBaptiste Daroussinand
15661d06d6bSBaptiste Daroussin.Aq Ic LINK
15761d06d6bSBaptiste Daroussinelements for the document
15861d06d6bSBaptiste Daroussin.Aq Ic HEAD ,
15961d06d6bSBaptiste Daroussinusing the
16061d06d6bSBaptiste Daroussin.Fa style
16161d06d6bSBaptiste Daroussinmember of
16261d06d6bSBaptiste Daroussin.Fa h
16361d06d6bSBaptiste Daroussinunless that is
16461d06d6bSBaptiste Daroussin.Dv NULL .
16561d06d6bSBaptiste DaroussinIt uses
16661d06d6bSBaptiste Daroussin.Fn print_otag
16761d06d6bSBaptiste Daroussinwhich takes care of properly encoding attributes,
16861d06d6bSBaptiste Daroussinwhich is relevant for the
16961d06d6bSBaptiste Daroussin.Fa style
17061d06d6bSBaptiste Daroussinlink in particular.
17161d06d6bSBaptiste Daroussin.Pp
17261d06d6bSBaptiste DaroussinThe function
17361d06d6bSBaptiste Daroussin.Fn print_otag
17461d06d6bSBaptiste Daroussinprints the start tag of an HTML element with the name
17561d06d6bSBaptiste Daroussin.Fa tag ,
17661d06d6bSBaptiste Daroussinoptionally including the attributes specified by
17761d06d6bSBaptiste Daroussin.Fa fmt .
17861d06d6bSBaptiste DaroussinIf
17961d06d6bSBaptiste Daroussin.Fa fmt
18061d06d6bSBaptiste Daroussinis the empty string, no attributes are written.
18161d06d6bSBaptiste DaroussinEach letter of
18261d06d6bSBaptiste Daroussin.Fa fmt
18361d06d6bSBaptiste Daroussinspecifies one attribute to write.
18461d06d6bSBaptiste DaroussinMost attributes require one
18561d06d6bSBaptiste Daroussin.Va char *
18661d06d6bSBaptiste Daroussinargument which becomes the value of the attribute.
18761d06d6bSBaptiste DaroussinThe arguments have to be given in the same order as the attribute letters.
18861d06d6bSBaptiste DaroussinIf an argument is
18961d06d6bSBaptiste Daroussin.Dv NULL ,
19061d06d6bSBaptiste Daroussinthe respective attribute is not written.
19161d06d6bSBaptiste Daroussin.Bl -tag -width 1n -offset indent
19261d06d6bSBaptiste Daroussin.It Cm c
19361d06d6bSBaptiste DaroussinPrint a
19461d06d6bSBaptiste Daroussin.Cm class
19561d06d6bSBaptiste Daroussinattribute.
19661d06d6bSBaptiste Daroussin.It Cm h
19761d06d6bSBaptiste DaroussinPrint a
19861d06d6bSBaptiste Daroussin.Cm href
19961d06d6bSBaptiste Daroussinattribute.
20061d06d6bSBaptiste DaroussinThis attribute letter can optionally be followed by a modifier letter.
20161d06d6bSBaptiste DaroussinIf followed by
20261d06d6bSBaptiste Daroussin.Cm R ,
20361d06d6bSBaptiste Daroussinit formats the link as a local one by prefixing a
20461d06d6bSBaptiste Daroussin.Sq #
20561d06d6bSBaptiste Daroussincharacter.
20661d06d6bSBaptiste DaroussinIf followed by
20761d06d6bSBaptiste Daroussin.Cm I ,
20861d06d6bSBaptiste Daroussinit interpretes the argument as a header file name
20961d06d6bSBaptiste Daroussinand generates a link using the
21061d06d6bSBaptiste Daroussin.Xr mandoc 1
21161d06d6bSBaptiste Daroussin.Fl O Cm includes
21261d06d6bSBaptiste Daroussinoption.
21361d06d6bSBaptiste DaroussinIf followed by
21461d06d6bSBaptiste Daroussin.Cm M ,
21561d06d6bSBaptiste Daroussinit takes two arguments instead of one, a manual page name and
21661d06d6bSBaptiste Daroussinsection, and formats them as a link to a manual page using the
21761d06d6bSBaptiste Daroussin.Xr mandoc 1
21861d06d6bSBaptiste Daroussin.Fl O Cm man
21961d06d6bSBaptiste Daroussinoption.
22061d06d6bSBaptiste Daroussin.It Cm i
22161d06d6bSBaptiste DaroussinPrint an
22261d06d6bSBaptiste Daroussin.Cm id
22361d06d6bSBaptiste Daroussinattribute.
22461d06d6bSBaptiste Daroussin.It Cm \&?
22561d06d6bSBaptiste DaroussinPrint an arbitrary attribute.
22661d06d6bSBaptiste DaroussinThis format letter requires two
22761d06d6bSBaptiste Daroussin.Vt char *
22861d06d6bSBaptiste Daroussinarguments, the attribute name and the value.
22961d06d6bSBaptiste DaroussinThe name must not be
23061d06d6bSBaptiste Daroussin.Dv NULL .
23161d06d6bSBaptiste Daroussin.It Cm s
23261d06d6bSBaptiste DaroussinPrint a
23361d06d6bSBaptiste Daroussin.Cm style
23461d06d6bSBaptiste Daroussinattribute.
23561d06d6bSBaptiste DaroussinIf present, it must be the last format letter.
23661d06d6bSBaptiste DaroussinIt requires two
23761d06d6bSBaptiste Daroussin.Va char *
23861d06d6bSBaptiste Daroussinarguments.
23961d06d6bSBaptiste DaroussinThe first is the name of the style property, the second its value.
2407295610fSBaptiste DaroussinThe name must not be
2417295610fSBaptiste Daroussin.Dv NULL .
2427295610fSBaptiste DaroussinThe
2437295610fSBaptiste Daroussin.Cm s
2447295610fSBaptiste Daroussin.Ar fmt
2457295610fSBaptiste Daroussinletter can be repeated, each repetition requiring an additional pair of
2467295610fSBaptiste Daroussin.Va char *
2477295610fSBaptiste Daroussinarguments.
24861d06d6bSBaptiste Daroussin.El
24961d06d6bSBaptiste Daroussin.Pp
25061d06d6bSBaptiste Daroussin.Fn print_otag
25161d06d6bSBaptiste Daroussinuses the private function
25261d06d6bSBaptiste Daroussin.Fn print_encode
25361d06d6bSBaptiste Daroussinto take care of HTML encoding.
25461d06d6bSBaptiste DaroussinIf required by the element type, it remembers in
25561d06d6bSBaptiste Daroussin.Fa h
25661d06d6bSBaptiste Daroussinthat the element is open.
25761d06d6bSBaptiste DaroussinThe function
25861d06d6bSBaptiste Daroussin.Fn print_tagq
25961d06d6bSBaptiste Daroussinis used to close out all open elements up to and including
26061d06d6bSBaptiste Daroussin.Fa until ;
26161d06d6bSBaptiste Daroussin.Fn print_stagq
26261d06d6bSBaptiste Daroussinis a variant to close out all open elements up to but excluding
26361d06d6bSBaptiste Daroussin.Fa suntil .
264*6d38604fSBaptiste DaroussinThe function
265*6d38604fSBaptiste Daroussin.Fn html_close_paragraph
266*6d38604fSBaptiste Daroussincloses all open elements that establish phrasing context,
267*6d38604fSBaptiste Daroussinthus returning to the innermost flow context.
268*6d38604fSBaptiste Daroussin.Pp
269*6d38604fSBaptiste DaroussinThe function
270*6d38604fSBaptiste Daroussin.Fn html_fillmode
271*6d38604fSBaptiste Daroussinswitches to fill mode if
272*6d38604fSBaptiste Daroussin.Fa want
273*6d38604fSBaptiste Daroussinis
274*6d38604fSBaptiste Daroussin.Dv ROFF_fi
275*6d38604fSBaptiste Daroussinor to no-fill mode if
276*6d38604fSBaptiste Daroussin.Fa want
277*6d38604fSBaptiste Daroussinis
278*6d38604fSBaptiste Daroussin.Dv ROFF_nf .
279*6d38604fSBaptiste DaroussinSwitching from fill mode to no-fill mode closes the current paragraph
280*6d38604fSBaptiste Daroussinand opens a
281*6d38604fSBaptiste Daroussin.Aq Ic PRE
282*6d38604fSBaptiste Daroussinelement.
283*6d38604fSBaptiste DaroussinSwitching in the opposite direction closes the
284*6d38604fSBaptiste Daroussin.Aq Ic PRE
285*6d38604fSBaptiste Daroussinelement, but does not open a new paragraph.
286*6d38604fSBaptiste DaroussinIf
287*6d38604fSBaptiste Daroussin.Fa want
288*6d38604fSBaptiste Daroussinmatches the mode that is already active, no elements are closed nor opened.
289*6d38604fSBaptiste DaroussinIf
290*6d38604fSBaptiste Daroussin.Fa want
291*6d38604fSBaptiste Daroussinis
292*6d38604fSBaptiste Daroussin.Dv TOKEN_NONE ,
293*6d38604fSBaptiste Daroussinthe mode remains as it is.
294*6d38604fSBaptiste Daroussin.Pp
295*6d38604fSBaptiste DaroussinThe function
296*6d38604fSBaptiste Daroussin.Fn html_setfont
297*6d38604fSBaptiste Daroussinselects the
298*6d38604fSBaptiste Daroussin.Fa font ,
299*6d38604fSBaptiste Daroussinwhich can be
300*6d38604fSBaptiste Daroussin.Dv ESCAPE_FONTROMAN ,
301*6d38604fSBaptiste Daroussin.Dv ESCAPE_FONTBOLD ,
302*6d38604fSBaptiste Daroussin.Dv ESCAPE_FONTITALIC ,
303*6d38604fSBaptiste Daroussin.Dv ESCAPE_FONTBI ,
304*6d38604fSBaptiste Daroussinor
305*6d38604fSBaptiste Daroussin.Dv ESCAPE_FONTCW ,
306*6d38604fSBaptiste Daroussinfor future text output and internally remembers
307*6d38604fSBaptiste Daroussinthe font that was active before the change.
308*6d38604fSBaptiste DaroussinIf the
309*6d38604fSBaptiste Daroussin.Fa font
310*6d38604fSBaptiste Daroussinargument is
311*6d38604fSBaptiste Daroussin.Dv ESCAPE_FONTPREV ,
312*6d38604fSBaptiste Daroussinthe current and the previous font are exchanged.
313*6d38604fSBaptiste DaroussinThis function only changes the internal state of the
314*6d38604fSBaptiste Daroussin.Fa h
315*6d38604fSBaptiste Daroussinobject; no HTML elements are written yet.
316*6d38604fSBaptiste DaroussinSubsequent text output will write font elements when needed.
31761d06d6bSBaptiste Daroussin.Pp
31861d06d6bSBaptiste DaroussinThe function
31961d06d6bSBaptiste Daroussin.Fn print_text
32061d06d6bSBaptiste Daroussinprints HTML element content.
32161d06d6bSBaptiste DaroussinIt uses the private function
32261d06d6bSBaptiste Daroussin.Fn print_encode
32361d06d6bSBaptiste Daroussinto take care of HTML encoding.
32461d06d6bSBaptiste DaroussinIf the document has requested a non-standard font, for example using a
32561d06d6bSBaptiste Daroussin.Xr roff 7
32661d06d6bSBaptiste Daroussin.Ic \ef
32761d06d6bSBaptiste Daroussinfont escape sequence,
32861d06d6bSBaptiste Daroussin.Fn print_text
32961d06d6bSBaptiste Daroussinwraps
33061d06d6bSBaptiste Daroussin.Fa word
33161d06d6bSBaptiste Daroussinin an HTML font selection element using the
33261d06d6bSBaptiste Daroussin.Fn print_otag
33361d06d6bSBaptiste Daroussinand
33461d06d6bSBaptiste Daroussin.Fn print_tagq
33561d06d6bSBaptiste Daroussinfunctions.
33661d06d6bSBaptiste Daroussin.Pp
33761d06d6bSBaptiste DaroussinThe function
338*6d38604fSBaptiste Daroussin.Fn print_tagged_text
339*6d38604fSBaptiste Daroussinis a variant of
340*6d38604fSBaptiste Daroussin.Fn print_text
341*6d38604fSBaptiste Daroussinthat wraps
342*6d38604fSBaptiste Daroussin.Fa word
343*6d38604fSBaptiste Daroussinin an
344*6d38604fSBaptiste Daroussin.Aq Ic A
345*6d38604fSBaptiste Daroussinelement of class
346*6d38604fSBaptiste Daroussin.Qq permalink
347*6d38604fSBaptiste Daroussinif
34861d06d6bSBaptiste Daroussin.Fa n
349*6d38604fSBaptiste Daroussinis not
35061d06d6bSBaptiste Daroussin.Dv NULL
351*6d38604fSBaptiste Daroussinand yields a segment identifier when passed to
352*6d38604fSBaptiste Daroussin.Fn html_make_id .
35361d06d6bSBaptiste Daroussin.Pp
35461d06d6bSBaptiste DaroussinThe function
355*6d38604fSBaptiste Daroussin.Fn html_make_id
356*6d38604fSBaptiste Daroussinallocates a string to be used for the
357*6d38604fSBaptiste Daroussin.Cm id
358*6d38604fSBaptiste Daroussinattribute of an HTML element and/or as a segment identifier for a URI in an
359*6d38604fSBaptiste Daroussin.Aq Ic A
360*6d38604fSBaptiste Daroussinelement.
361*6d38604fSBaptiste DaroussinIf
362*6d38604fSBaptiste Daroussin.Fa n
363*6d38604fSBaptiste Daroussincontains a
364*6d38604fSBaptiste Daroussin.Fa tag
365*6d38604fSBaptiste Daroussinattribute, it is used; otherwise, child nodes are used.
366*6d38604fSBaptiste DaroussinIf
367*6d38604fSBaptiste Daroussin.Fa n
368*6d38604fSBaptiste Daroussinis an
369*6d38604fSBaptiste Daroussin.Ic \&Sh ,
370*6d38604fSBaptiste Daroussin.Ic \&Ss ,
371*6d38604fSBaptiste Daroussin.Ic \&Sx ,
372*6d38604fSBaptiste Daroussin.Ic SH ,
373*6d38604fSBaptiste Daroussinor
374*6d38604fSBaptiste Daroussin.Ic SS
375*6d38604fSBaptiste Daroussinnode, the resulting string is the concatenation of the child strings;
376*6d38604fSBaptiste Daroussinfor other node types, only the first child is used.
377*6d38604fSBaptiste DaroussinBytes not permitted in URI-fragment strings are replaced by underscores.
378*6d38604fSBaptiste DaroussinIf any of the children to be used is not a text node,
379*6d38604fSBaptiste Daroussinno string is generated and
380*6d38604fSBaptiste Daroussin.Dv NULL
381*6d38604fSBaptiste Daroussinis returned instead.
382*6d38604fSBaptiste DaroussinIf the
383*6d38604fSBaptiste Daroussin.Fa unique
384*6d38604fSBaptiste Daroussinargument is non-zero, deduplication is performed by appending an
385*6d38604fSBaptiste Daroussinunderscore and a decimal integer, if necessary.
386*6d38604fSBaptiste DaroussinIf the
387*6d38604fSBaptiste Daroussin.Fa unique
388*6d38604fSBaptiste Daroussinargument is 1, this is assumed to be the first call for this tag
389*6d38604fSBaptiste Daroussinat this location, typically for use by
390*6d38604fSBaptiste Daroussin.Dv NODE_ID ,
391*6d38604fSBaptiste Daroussinso the integer is incremented before use.
392*6d38604fSBaptiste DaroussinIf the
393*6d38604fSBaptiste Daroussin.Fa unique
394*6d38604fSBaptiste Daroussinargument is 2, this is ssumed to be the second call for this tag
395*6d38604fSBaptiste Daroussinat this location, typically for use by
396*6d38604fSBaptiste Daroussin.Dv NODE_HREF ,
397*6d38604fSBaptiste Daroussinso the existing integer, if any, is used without incrementing it.
398*6d38604fSBaptiste Daroussin.Pp
399*6d38604fSBaptiste DaroussinThe function
400*6d38604fSBaptiste Daroussin.Fn print_otag_id
401*6d38604fSBaptiste Daroussinopens a
402*6d38604fSBaptiste Daroussin.Fa tag
403*6d38604fSBaptiste Daroussinelement of class
404*6d38604fSBaptiste Daroussin.Fa cattr
405*6d38604fSBaptiste Daroussinfor the node
406*6d38604fSBaptiste Daroussin.Fa n .
407*6d38604fSBaptiste DaroussinIf the flag
408*6d38604fSBaptiste Daroussin.Dv NODE_ID
409*6d38604fSBaptiste Daroussinis set in
410*6d38604fSBaptiste Daroussin.Fa n ,
411*6d38604fSBaptiste Daroussinit attempts to generate an
412*6d38604fSBaptiste Daroussin.Cm id
413*6d38604fSBaptiste Daroussinattribute with
414*6d38604fSBaptiste Daroussin.Fn html_make_id .
415*6d38604fSBaptiste DaroussinIf the flag
416*6d38604fSBaptiste Daroussin.Dv NODE_HREF
417*6d38604fSBaptiste Daroussinis set in
418*6d38604fSBaptiste Daroussin.Fa n ,
419*6d38604fSBaptiste Daroussinan
420*6d38604fSBaptiste Daroussin.Aq Ic A
421*6d38604fSBaptiste Daroussinelement of class
422*6d38604fSBaptiste Daroussin.Qq permalink
423*6d38604fSBaptiste Daroussinis added:
424*6d38604fSBaptiste Daroussinoutside if
425*6d38604fSBaptiste Daroussin.Fa n
426*6d38604fSBaptiste Daroussingenerates an element that can only occur in phrasing context,
427*6d38604fSBaptiste Daroussinor inside otherwise.
428*6d38604fSBaptiste DaroussinThis function is a wrapper around
429*6d38604fSBaptiste Daroussin.Fn html_make_id
430*6d38604fSBaptiste Daroussinand
431*6d38604fSBaptiste Daroussin.Fn print_otag ,
432*6d38604fSBaptiste Daroussinautomatically chosing the
433*6d38604fSBaptiste Daroussin.Fa unique
434*6d38604fSBaptiste Daroussinargument appropriately and setting the
435*6d38604fSBaptiste Daroussin.Fa fmt
436*6d38604fSBaptiste Daroussinarguments to
437*6d38604fSBaptiste Daroussin.Qq chR
438*6d38604fSBaptiste Daroussinand
439*6d38604fSBaptiste Daroussin.Qq ci ,
440*6d38604fSBaptiste Daroussinrespectively.
441*6d38604fSBaptiste Daroussin.Pp
442*6d38604fSBaptiste DaroussinThe function
443*6d38604fSBaptiste Daroussin.Fn print_endline
444*6d38604fSBaptiste Daroussinmakes sure subsequent output starts on a new HTML output line.
445*6d38604fSBaptiste DaroussinIf nothing was printed on the current output line yet, it has no effect.
446*6d38604fSBaptiste DaroussinOtherwise, it appends any buffered text to the current output line,
447*6d38604fSBaptiste Daroussinends the line, and updates the internal state of the
448*6d38604fSBaptiste Daroussin.Fa h
449*6d38604fSBaptiste Daroussinobject.
45061d06d6bSBaptiste Daroussin.Pp
45161d06d6bSBaptiste DaroussinThe functions
45261d06d6bSBaptiste Daroussin.Fn print_eqn ,
45361d06d6bSBaptiste Daroussin.Fn print_tbl ,
45461d06d6bSBaptiste Daroussinand
45561d06d6bSBaptiste Daroussin.Fn print_tblclose
45661d06d6bSBaptiste Daroussinare not yet documented.
457*6d38604fSBaptiste Daroussin.Sh RETURN VALUES
458*6d38604fSBaptiste DaroussinThe functions
459*6d38604fSBaptiste Daroussin.Fn print_otag
460*6d38604fSBaptiste Daroussinand
461*6d38604fSBaptiste Daroussin.Fn print_otag_id
462*6d38604fSBaptiste Daroussinreturn a pointer to a new element on the stack of HTML elements.
463*6d38604fSBaptiste DaroussinWhen
464*6d38604fSBaptiste Daroussin.Fn print_otag_id
465*6d38604fSBaptiste Daroussinopens two elements, a pointer to the outer one is returned.
466*6d38604fSBaptiste DaroussinThe memory pointed to is owned by the library and is automatically
467*6d38604fSBaptiste Daroussin.Xr free 3 Ns d
468*6d38604fSBaptiste Daroussinwhen
469*6d38604fSBaptiste Daroussin.Fn print_tagq
470*6d38604fSBaptiste Daroussinis called on it or when
471*6d38604fSBaptiste Daroussin.Fn print_stagq
472*6d38604fSBaptiste Daroussinis called on a parent element.
473*6d38604fSBaptiste Daroussin.Pp
474*6d38604fSBaptiste DaroussinThe function
475*6d38604fSBaptiste Daroussin.Fn html_fillmode
476*6d38604fSBaptiste Daroussinreturns
477*6d38604fSBaptiste Daroussin.Dv ROFF_fi
478*6d38604fSBaptiste Daroussinif fill mode was active before the call or
479*6d38604fSBaptiste Daroussin.Dv ROFF_nf
480*6d38604fSBaptiste Daroussinotherwise.
481*6d38604fSBaptiste Daroussin.Pp
482*6d38604fSBaptiste DaroussinThe function
483*6d38604fSBaptiste Daroussin.Fn html_make_id
484*6d38604fSBaptiste Daroussinreturns a newly allocated string or
485*6d38604fSBaptiste Daroussin.Dv NULL
486*6d38604fSBaptiste Daroussinif
487*6d38604fSBaptiste Daroussin.Fa n
488*6d38604fSBaptiste Daroussinlacks text data to create the attribute from.
489*6d38604fSBaptiste DaroussinThe caller is responsible for
490*6d38604fSBaptiste Daroussin.Xr free 3 Ns ing
491*6d38604fSBaptiste Daroussinthe returned string after using it.
492*6d38604fSBaptiste Daroussin.Pp
493*6d38604fSBaptiste DaroussinIn case of
494*6d38604fSBaptiste Daroussin.Xr malloc 3
495*6d38604fSBaptiste Daroussinfailure, these functions do not return but call
496*6d38604fSBaptiste Daroussin.Xr err 3 .
49761d06d6bSBaptiste Daroussin.Sh FILES
49861d06d6bSBaptiste Daroussin.Bl -tag -width mandoc_aux.c -compact
49961d06d6bSBaptiste Daroussin.It Pa main.h
50061d06d6bSBaptiste Daroussindeclarations of public functions for use by the main program,
50161d06d6bSBaptiste Daroussinnot yet documented
50261d06d6bSBaptiste Daroussin.It Pa html.h
50361d06d6bSBaptiste Daroussindeclarations of data types and private functions
50461d06d6bSBaptiste Daroussinfor use by language-specific HTML formatters
50561d06d6bSBaptiste Daroussin.It Pa html.c
50661d06d6bSBaptiste Daroussinmain HTML formatting engine and utility functions
50761d06d6bSBaptiste Daroussin.It Pa mdoc_html.c
50861d06d6bSBaptiste Daroussin.Xr mdoc 7
50961d06d6bSBaptiste DaroussinHTML formatter
51061d06d6bSBaptiste Daroussin.It Pa man_html.c
51161d06d6bSBaptiste Daroussin.Xr man 7
51261d06d6bSBaptiste DaroussinHTML formatter
51361d06d6bSBaptiste Daroussin.It Pa tbl_html.c
51461d06d6bSBaptiste Daroussin.Xr tbl 7
51561d06d6bSBaptiste DaroussinHTML formatter
51661d06d6bSBaptiste Daroussin.It Pa eqn_html.c
51761d06d6bSBaptiste Daroussin.Xr eqn 7
51861d06d6bSBaptiste DaroussinHTML formatter
519*6d38604fSBaptiste Daroussin.It Pa roff_html.c
520*6d38604fSBaptiste Daroussin.Xr roff 7
521*6d38604fSBaptiste DaroussinHTML formatter, handling requests like
522*6d38604fSBaptiste Daroussin.Ic br ,
523*6d38604fSBaptiste Daroussin.Ic ce ,
524*6d38604fSBaptiste Daroussin.Ic fi ,
525*6d38604fSBaptiste Daroussin.Ic ft ,
526*6d38604fSBaptiste Daroussin.Ic nf ,
527*6d38604fSBaptiste Daroussin.Ic rj ,
528*6d38604fSBaptiste Daroussinand
529*6d38604fSBaptiste Daroussin.Ic sp .
53061d06d6bSBaptiste Daroussin.It Pa out.h
53161d06d6bSBaptiste Daroussindeclarations of data types and private functions
53261d06d6bSBaptiste Daroussinfor shared use by all mandoc formatters,
53361d06d6bSBaptiste Daroussinnot yet documented
53461d06d6bSBaptiste Daroussin.It Pa out.c
53561d06d6bSBaptiste Daroussinprivate functions for shared use by all mandoc formatters
53661d06d6bSBaptiste Daroussin.It Pa mandoc_aux.h
53761d06d6bSBaptiste Daroussindeclarations of common mandoc utility functions, see
53861d06d6bSBaptiste Daroussin.Xr mandoc 3
53961d06d6bSBaptiste Daroussin.It Pa mandoc_aux.c
54061d06d6bSBaptiste Daroussinimplementation of common mandoc utility functions
54161d06d6bSBaptiste Daroussin.El
54261d06d6bSBaptiste Daroussin.Sh SEE ALSO
54361d06d6bSBaptiste Daroussin.Xr mandoc 1 ,
54461d06d6bSBaptiste Daroussin.Xr mandoc 3 ,
54561d06d6bSBaptiste Daroussin.Xr man.cgi 8
54661d06d6bSBaptiste Daroussin.Sh AUTHORS
54761d06d6bSBaptiste Daroussin.An -nosplit
54861d06d6bSBaptiste DaroussinThe mandoc HTML formatter was written by
54961d06d6bSBaptiste Daroussin.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
55061d06d6bSBaptiste DaroussinIt is maintained by
55161d06d6bSBaptiste Daroussin.An Ingo Schwarze Aq Mt schwarze@openbsd.org ,
55261d06d6bSBaptiste Daroussinwho also wrote this manual.
553