]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_html.c
1 /* $Id: mdoc_html.c,v 1.154 2011/03/07 01:35:51 schwarze Exp $ */
3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
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.
21 #include <sys/types.h>
39 #define MDOC_ARGS const struct mdoc_meta *m, \
40 const struct mdoc_node *n, \
44 #define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b))
48 int (*pre
)(MDOC_ARGS
);
49 void (*post
)(MDOC_ARGS
);
52 static void print_mdoc(MDOC_ARGS
);
53 static void print_mdoc_head(MDOC_ARGS
);
54 static void print_mdoc_node(MDOC_ARGS
);
55 static void print_mdoc_nodelist(MDOC_ARGS
);
56 static void synopsis_pre(struct html
*,
57 const struct mdoc_node
*);
59 static void a2width(const char *, struct roffsu
*);
60 static void a2offs(const char *, struct roffsu
*);
62 static void mdoc_root_post(MDOC_ARGS
);
63 static int mdoc_root_pre(MDOC_ARGS
);
65 static void mdoc__x_post(MDOC_ARGS
);
66 static int mdoc__x_pre(MDOC_ARGS
);
67 static int mdoc_ad_pre(MDOC_ARGS
);
68 static int mdoc_an_pre(MDOC_ARGS
);
69 static int mdoc_ap_pre(MDOC_ARGS
);
70 static int mdoc_ar_pre(MDOC_ARGS
);
71 static int mdoc_bd_pre(MDOC_ARGS
);
72 static int mdoc_bf_pre(MDOC_ARGS
);
73 static void mdoc_bk_post(MDOC_ARGS
);
74 static int mdoc_bk_pre(MDOC_ARGS
);
75 static int mdoc_bl_pre(MDOC_ARGS
);
76 static int mdoc_bt_pre(MDOC_ARGS
);
77 static int mdoc_bx_pre(MDOC_ARGS
);
78 static int mdoc_cd_pre(MDOC_ARGS
);
79 static int mdoc_d1_pre(MDOC_ARGS
);
80 static int mdoc_dv_pre(MDOC_ARGS
);
81 static int mdoc_fa_pre(MDOC_ARGS
);
82 static int mdoc_fd_pre(MDOC_ARGS
);
83 static int mdoc_fl_pre(MDOC_ARGS
);
84 static int mdoc_fn_pre(MDOC_ARGS
);
85 static int mdoc_ft_pre(MDOC_ARGS
);
86 static int mdoc_em_pre(MDOC_ARGS
);
87 static int mdoc_er_pre(MDOC_ARGS
);
88 static int mdoc_ev_pre(MDOC_ARGS
);
89 static int mdoc_ex_pre(MDOC_ARGS
);
90 static void mdoc_fo_post(MDOC_ARGS
);
91 static int mdoc_fo_pre(MDOC_ARGS
);
92 static int mdoc_ic_pre(MDOC_ARGS
);
93 static int mdoc_igndelim_pre(MDOC_ARGS
);
94 static int mdoc_in_pre(MDOC_ARGS
);
95 static int mdoc_it_pre(MDOC_ARGS
);
96 static int mdoc_lb_pre(MDOC_ARGS
);
97 static int mdoc_li_pre(MDOC_ARGS
);
98 static int mdoc_lk_pre(MDOC_ARGS
);
99 static int mdoc_mt_pre(MDOC_ARGS
);
100 static int mdoc_ms_pre(MDOC_ARGS
);
101 static int mdoc_nd_pre(MDOC_ARGS
);
102 static int mdoc_nm_pre(MDOC_ARGS
);
103 static int mdoc_ns_pre(MDOC_ARGS
);
104 static int mdoc_pa_pre(MDOC_ARGS
);
105 static void mdoc_pf_post(MDOC_ARGS
);
106 static int mdoc_pp_pre(MDOC_ARGS
);
107 static void mdoc_quote_post(MDOC_ARGS
);
108 static int mdoc_quote_pre(MDOC_ARGS
);
109 static int mdoc_rs_pre(MDOC_ARGS
);
110 static int mdoc_rv_pre(MDOC_ARGS
);
111 static int mdoc_sh_pre(MDOC_ARGS
);
112 static int mdoc_sm_pre(MDOC_ARGS
);
113 static int mdoc_sp_pre(MDOC_ARGS
);
114 static int mdoc_ss_pre(MDOC_ARGS
);
115 static int mdoc_sx_pre(MDOC_ARGS
);
116 static int mdoc_sy_pre(MDOC_ARGS
);
117 static int mdoc_ud_pre(MDOC_ARGS
);
118 static int mdoc_va_pre(MDOC_ARGS
);
119 static int mdoc_vt_pre(MDOC_ARGS
);
120 static int mdoc_xr_pre(MDOC_ARGS
);
121 static int mdoc_xx_pre(MDOC_ARGS
);
123 static const struct htmlmdoc mdocs
[MDOC_MAX
] = {
124 {mdoc_ap_pre
, NULL
}, /* Ap */
125 {NULL
, NULL
}, /* Dd */
126 {NULL
, NULL
}, /* Dt */
127 {NULL
, NULL
}, /* Os */
128 {mdoc_sh_pre
, NULL
}, /* Sh */
129 {mdoc_ss_pre
, NULL
}, /* Ss */
130 {mdoc_pp_pre
, NULL
}, /* Pp */
131 {mdoc_d1_pre
, NULL
}, /* D1 */
132 {mdoc_d1_pre
, NULL
}, /* Dl */
133 {mdoc_bd_pre
, NULL
}, /* Bd */
134 {NULL
, NULL
}, /* Ed */
135 {mdoc_bl_pre
, NULL
}, /* Bl */
136 {NULL
, NULL
}, /* El */
137 {mdoc_it_pre
, NULL
}, /* It */
138 {mdoc_ad_pre
, NULL
}, /* Ad */
139 {mdoc_an_pre
, NULL
}, /* An */
140 {mdoc_ar_pre
, NULL
}, /* Ar */
141 {mdoc_cd_pre
, NULL
}, /* Cd */
142 {mdoc_fl_pre
, NULL
}, /* Cm */
143 {mdoc_dv_pre
, NULL
}, /* Dv */
144 {mdoc_er_pre
, NULL
}, /* Er */
145 {mdoc_ev_pre
, NULL
}, /* Ev */
146 {mdoc_ex_pre
, NULL
}, /* Ex */
147 {mdoc_fa_pre
, NULL
}, /* Fa */
148 {mdoc_fd_pre
, NULL
}, /* Fd */
149 {mdoc_fl_pre
, NULL
}, /* Fl */
150 {mdoc_fn_pre
, NULL
}, /* Fn */
151 {mdoc_ft_pre
, NULL
}, /* Ft */
152 {mdoc_ic_pre
, NULL
}, /* Ic */
153 {mdoc_in_pre
, NULL
}, /* In */
154 {mdoc_li_pre
, NULL
}, /* Li */
155 {mdoc_nd_pre
, NULL
}, /* Nd */
156 {mdoc_nm_pre
, NULL
}, /* Nm */
157 {mdoc_quote_pre
, mdoc_quote_post
}, /* Op */
158 {NULL
, NULL
}, /* Ot */
159 {mdoc_pa_pre
, NULL
}, /* Pa */
160 {mdoc_rv_pre
, NULL
}, /* Rv */
161 {NULL
, NULL
}, /* St */
162 {mdoc_va_pre
, NULL
}, /* Va */
163 {mdoc_vt_pre
, NULL
}, /* Vt */
164 {mdoc_xr_pre
, NULL
}, /* Xr */
165 {mdoc__x_pre
, mdoc__x_post
}, /* %A */
166 {mdoc__x_pre
, mdoc__x_post
}, /* %B */
167 {mdoc__x_pre
, mdoc__x_post
}, /* %D */
168 {mdoc__x_pre
, mdoc__x_post
}, /* %I */
169 {mdoc__x_pre
, mdoc__x_post
}, /* %J */
170 {mdoc__x_pre
, mdoc__x_post
}, /* %N */
171 {mdoc__x_pre
, mdoc__x_post
}, /* %O */
172 {mdoc__x_pre
, mdoc__x_post
}, /* %P */
173 {mdoc__x_pre
, mdoc__x_post
}, /* %R */
174 {mdoc__x_pre
, mdoc__x_post
}, /* %T */
175 {mdoc__x_pre
, mdoc__x_post
}, /* %V */
176 {NULL
, NULL
}, /* Ac */
177 {mdoc_quote_pre
, mdoc_quote_post
}, /* Ao */
178 {mdoc_quote_pre
, mdoc_quote_post
}, /* Aq */
179 {NULL
, NULL
}, /* At */
180 {NULL
, NULL
}, /* Bc */
181 {mdoc_bf_pre
, NULL
}, /* Bf */
182 {mdoc_quote_pre
, mdoc_quote_post
}, /* Bo */
183 {mdoc_quote_pre
, mdoc_quote_post
}, /* Bq */
184 {mdoc_xx_pre
, NULL
}, /* Bsx */
185 {mdoc_bx_pre
, NULL
}, /* Bx */
186 {NULL
, NULL
}, /* Db */
187 {NULL
, NULL
}, /* Dc */
188 {mdoc_quote_pre
, mdoc_quote_post
}, /* Do */
189 {mdoc_quote_pre
, mdoc_quote_post
}, /* Dq */
190 {NULL
, NULL
}, /* Ec */ /* FIXME: no space */
191 {NULL
, NULL
}, /* Ef */
192 {mdoc_em_pre
, NULL
}, /* Em */
193 {NULL
, NULL
}, /* Eo */
194 {mdoc_xx_pre
, NULL
}, /* Fx */
195 {mdoc_ms_pre
, NULL
}, /* Ms */
196 {mdoc_igndelim_pre
, NULL
}, /* No */
197 {mdoc_ns_pre
, NULL
}, /* Ns */
198 {mdoc_xx_pre
, NULL
}, /* Nx */
199 {mdoc_xx_pre
, NULL
}, /* Ox */
200 {NULL
, NULL
}, /* Pc */
201 {mdoc_igndelim_pre
, mdoc_pf_post
}, /* Pf */
202 {mdoc_quote_pre
, mdoc_quote_post
}, /* Po */
203 {mdoc_quote_pre
, mdoc_quote_post
}, /* Pq */
204 {NULL
, NULL
}, /* Qc */
205 {mdoc_quote_pre
, mdoc_quote_post
}, /* Ql */
206 {mdoc_quote_pre
, mdoc_quote_post
}, /* Qo */
207 {mdoc_quote_pre
, mdoc_quote_post
}, /* Qq */
208 {NULL
, NULL
}, /* Re */
209 {mdoc_rs_pre
, NULL
}, /* Rs */
210 {NULL
, NULL
}, /* Sc */
211 {mdoc_quote_pre
, mdoc_quote_post
}, /* So */
212 {mdoc_quote_pre
, mdoc_quote_post
}, /* Sq */
213 {mdoc_sm_pre
, NULL
}, /* Sm */
214 {mdoc_sx_pre
, NULL
}, /* Sx */
215 {mdoc_sy_pre
, NULL
}, /* Sy */
216 {NULL
, NULL
}, /* Tn */
217 {mdoc_xx_pre
, NULL
}, /* Ux */
218 {NULL
, NULL
}, /* Xc */
219 {NULL
, NULL
}, /* Xo */
220 {mdoc_fo_pre
, mdoc_fo_post
}, /* Fo */
221 {NULL
, NULL
}, /* Fc */
222 {mdoc_quote_pre
, mdoc_quote_post
}, /* Oo */
223 {NULL
, NULL
}, /* Oc */
224 {mdoc_bk_pre
, mdoc_bk_post
}, /* Bk */
225 {NULL
, NULL
}, /* Ek */
226 {mdoc_bt_pre
, NULL
}, /* Bt */
227 {NULL
, NULL
}, /* Hf */
228 {NULL
, NULL
}, /* Fr */
229 {mdoc_ud_pre
, NULL
}, /* Ud */
230 {mdoc_lb_pre
, NULL
}, /* Lb */
231 {mdoc_pp_pre
, NULL
}, /* Lp */
232 {mdoc_lk_pre
, NULL
}, /* Lk */
233 {mdoc_mt_pre
, NULL
}, /* Mt */
234 {mdoc_quote_pre
, mdoc_quote_post
}, /* Brq */
235 {mdoc_quote_pre
, mdoc_quote_post
}, /* Bro */
236 {NULL
, NULL
}, /* Brc */
237 {mdoc__x_pre
, mdoc__x_post
}, /* %C */
238 {NULL
, NULL
}, /* Es */ /* TODO */
239 {NULL
, NULL
}, /* En */ /* TODO */
240 {mdoc_xx_pre
, NULL
}, /* Dx */
241 {mdoc__x_pre
, mdoc__x_post
}, /* %Q */
242 {mdoc_sp_pre
, NULL
}, /* br */
243 {mdoc_sp_pre
, NULL
}, /* sp */
244 {mdoc__x_pre
, mdoc__x_post
}, /* %U */
245 {NULL
, NULL
}, /* Ta */
248 static const char * const lists
[LIST_MAX
] = {
264 html_mdoc(void *arg
, const struct mdoc
*m
)
269 h
= (struct html
*)arg
;
272 t
= print_otag(h
, TAG_HTML
, 0, NULL
);
273 print_mdoc(mdoc_meta(m
), mdoc_node(m
), h
);
281 * Calculate the scaling unit passed in a `-width' argument. This uses
282 * either a native scaling unit (e.g., 1i, 2m) or the string length of
286 a2width(const char *p
, struct roffsu
*su
)
289 if ( ! a2roffsu(p
, su
, SCALE_MAX
)) {
291 su
->scale
= (int)strlen(p
);
297 * See the same function in mdoc_term.c for documentation.
300 synopsis_pre(struct html
*h
, const struct mdoc_node
*n
)
303 if (NULL
== n
->prev
|| ! (MDOC_SYNPRETTY
& n
->flags
))
306 if (n
->prev
->tok
== n
->tok
&&
310 print_otag(h
, TAG_BR
, 0, NULL
);
314 switch (n
->prev
->tok
) {
324 print_otag(h
, TAG_P
, 0, NULL
);
327 if (MDOC_Fn
!= n
->tok
&& MDOC_Fo
!= n
->tok
) {
328 print_otag(h
, TAG_P
, 0, NULL
);
333 print_otag(h
, TAG_BR
, 0, NULL
);
340 * Calculate the scaling unit passed in an `-offset' argument. This
341 * uses either a native scaling unit (e.g., 1i, 2m), one of a set of
342 * predefined strings (indent, etc.), or the string length of the value.
345 a2offs(const char *p
, struct roffsu
*su
)
348 /* FIXME: "right"? */
350 if (0 == strcmp(p
, "left"))
351 SCALE_HS_INIT(su
, 0);
352 else if (0 == strcmp(p
, "indent"))
353 SCALE_HS_INIT(su
, INDENT
);
354 else if (0 == strcmp(p
, "indent-two"))
355 SCALE_HS_INIT(su
, INDENT
* 2);
356 else if ( ! a2roffsu(p
, su
, SCALE_MAX
)) {
358 su
->scale
= (int)strlen(p
);
364 print_mdoc(MDOC_ARGS
)
368 t
= print_otag(h
, TAG_HEAD
, 0, NULL
);
369 print_mdoc_head(m
, n
, h
);
372 t
= print_otag(h
, TAG_BODY
, 0, NULL
);
373 print_mdoc_nodelist(m
, n
, h
);
380 print_mdoc_head(MDOC_ARGS
)
385 buffmt(h
, "%s(%s)", m
->title
, m
->msec
);
393 print_otag(h
, TAG_TITLE
, 0, NULL
);
394 print_text(h
, h
->buf
);
399 print_mdoc_nodelist(MDOC_ARGS
)
402 print_mdoc_node(m
, n
, h
);
404 print_mdoc_nodelist(m
, n
->next
, h
);
409 print_mdoc_node(MDOC_ARGS
)
421 child
= mdoc_root_pre(m
, n
, h
);
424 /* No tables in this mode... */
425 assert(NULL
== h
->tblt
);
428 * Make sure that if we're in a literal mode already
429 * (i.e., within a <PRE>) don't print the newline.
431 if (' ' == *n
->string
&& MDOC_LINE
& n
->flags
)
432 if ( ! (HTML_LITERAL
& h
->flags
))
433 print_otag(h
, TAG_BR
, 0, NULL
);
434 print_text(h
, n
->string
);
437 PAIR_CLASS_INIT(&tag
, "eqn");
438 print_otag(h
, TAG_SPAN
, 1, &tag
);
439 print_text(h
, n
->eqn
->data
);
443 * This will take care of initialising all of the table
444 * state data for the first table, then tearing it down
447 print_tbl(h
, n
->span
);
451 * Close out the current table, if it's open, and unset
452 * the "meta" table state. This will be reopened on the
453 * next table element.
460 assert(NULL
== h
->tblt
);
461 if (mdocs
[n
->tok
].pre
&& ENDBODY_NOT
== n
->end
)
462 child
= (*mdocs
[n
->tok
].pre
)(m
, n
, h
);
466 if (HTML_KEEP
& h
->flags
) {
467 if (n
->prev
&& n
->prev
->line
!= n
->line
) {
468 h
->flags
&= ~HTML_KEEP
;
469 h
->flags
|= HTML_PREKEEP
;
470 } else if (NULL
== n
->prev
) {
471 if (n
->parent
&& n
->parent
->line
!= n
->line
) {
472 h
->flags
&= ~HTML_KEEP
;
473 h
->flags
|= HTML_PREKEEP
;
478 if (child
&& n
->child
)
479 print_mdoc_nodelist(m
, n
->child
, h
);
486 mdoc_root_post(m
, n
, h
);
491 if (mdocs
[n
->tok
].post
&& ENDBODY_NOT
== n
->end
)
492 (*mdocs
[n
->tok
].post
)(m
, n
, h
);
499 mdoc_root_post(MDOC_ARGS
)
501 struct htmlpair tag
[3];
504 PAIR_SUMMARY_INIT(&tag
[0], "Document Footer");
505 PAIR_CLASS_INIT(&tag
[1], "foot");
506 if (NULL
== h
->style
) {
507 PAIR_INIT(&tag
[2], ATTR_WIDTH
, "100%");
508 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
509 PAIR_INIT(&tag
[0], ATTR_WIDTH
, "50%");
510 print_otag(h
, TAG_COL
, 1, tag
);
511 print_otag(h
, TAG_COL
, 1, tag
);
513 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
515 t
= print_otag(h
, TAG_TBODY
, 0, NULL
);
517 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
519 PAIR_CLASS_INIT(&tag
[0], "foot-date");
520 print_otag(h
, TAG_TD
, 1, tag
);
522 print_text(h
, m
->date
);
525 PAIR_CLASS_INIT(&tag
[0], "foot-os");
526 if (NULL
== h
->style
) {
527 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "right");
528 print_otag(h
, TAG_TD
, 2, tag
);
530 print_otag(h
, TAG_TD
, 1, tag
);
532 print_text(h
, m
->os
);
539 mdoc_root_pre(MDOC_ARGS
)
541 struct htmlpair tag
[3];
543 char b
[BUFSIZ
], title
[BUFSIZ
];
545 strlcpy(b
, m
->vol
, BUFSIZ
);
548 strlcat(b
, " (", BUFSIZ
);
549 strlcat(b
, m
->arch
, BUFSIZ
);
550 strlcat(b
, ")", BUFSIZ
);
553 snprintf(title
, BUFSIZ
- 1, "%s(%s)", m
->title
, m
->msec
);
555 PAIR_SUMMARY_INIT(&tag
[0], "Document Header");
556 PAIR_CLASS_INIT(&tag
[1], "head");
557 if (NULL
== h
->style
) {
558 PAIR_INIT(&tag
[2], ATTR_WIDTH
, "100%");
559 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
560 PAIR_INIT(&tag
[0], ATTR_WIDTH
, "30%");
561 print_otag(h
, TAG_COL
, 1, tag
);
562 print_otag(h
, TAG_COL
, 1, tag
);
563 print_otag(h
, TAG_COL
, 1, tag
);
565 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
567 print_otag(h
, TAG_TBODY
, 0, NULL
);
569 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
571 PAIR_CLASS_INIT(&tag
[0], "head-ltitle");
572 print_otag(h
, TAG_TD
, 1, tag
);
574 print_text(h
, title
);
577 PAIR_CLASS_INIT(&tag
[0], "head-vol");
578 if (NULL
== h
->style
) {
579 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "center");
580 print_otag(h
, TAG_TD
, 2, tag
);
582 print_otag(h
, TAG_TD
, 1, tag
);
587 PAIR_CLASS_INIT(&tag
[0], "head-rtitle");
588 if (NULL
== h
->style
) {
589 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "right");
590 print_otag(h
, TAG_TD
, 2, tag
);
592 print_otag(h
, TAG_TD
, 1, tag
);
594 print_text(h
, title
);
602 mdoc_sh_pre(MDOC_ARGS
)
607 if (MDOC_BLOCK
== n
->type
) {
608 PAIR_CLASS_INIT(&tag
, "section");
609 print_otag(h
, TAG_DIV
, 1, &tag
);
611 } else if (MDOC_BODY
== n
->type
)
615 for (n
= n
->child
; n
; n
= n
->next
) {
616 html_idcat(buf
, n
->string
, BUFSIZ
);
618 html_idcat(buf
, " ", BUFSIZ
);
621 PAIR_ID_INIT(&tag
, buf
);
622 print_otag(h
, TAG_H1
, 1, &tag
);
629 mdoc_ss_pre(MDOC_ARGS
)
634 if (MDOC_BLOCK
== n
->type
) {
635 PAIR_CLASS_INIT(&tag
, "subsection");
636 print_otag(h
, TAG_DIV
, 1, &tag
);
638 } else if (MDOC_BODY
== n
->type
)
642 for (n
= n
->child
; n
; n
= n
->next
) {
643 html_idcat(buf
, n
->string
, BUFSIZ
);
645 html_idcat(buf
, " ", BUFSIZ
);
648 PAIR_ID_INIT(&tag
, buf
);
649 print_otag(h
, TAG_H2
, 1, &tag
);
656 mdoc_fl_pre(MDOC_ARGS
)
660 PAIR_CLASS_INIT(&tag
, "flag");
661 print_otag(h
, TAG_B
, 1, &tag
);
663 /* `Cm' has no leading hyphen. */
665 if (MDOC_Cm
== n
->tok
)
668 print_text(h
, "\\-");
671 h
->flags
|= HTML_NOSPACE
;
672 else if (n
->next
&& n
->next
->line
== n
->line
)
673 h
->flags
|= HTML_NOSPACE
;
681 mdoc_nd_pre(MDOC_ARGS
)
685 if (MDOC_BODY
!= n
->type
)
688 /* XXX: this tag in theory can contain block elements. */
690 print_text(h
, "\\(em");
691 PAIR_CLASS_INIT(&tag
, "desc");
692 print_otag(h
, TAG_SPAN
, 1, &tag
);
698 mdoc_nm_pre(MDOC_ARGS
)
707 PAIR_CLASS_INIT(&tag
, "name");
708 print_otag(h
, TAG_B
, 1, &tag
);
709 if (NULL
== n
->child
&& m
->name
)
710 print_text(h
, m
->name
);
713 print_otag(h
, TAG_TD
, 0, NULL
);
714 if (NULL
== n
->child
&& m
->name
)
715 print_text(h
, m
->name
);
718 print_otag(h
, TAG_TD
, 0, NULL
);
725 PAIR_CLASS_INIT(&tag
, "synopsis");
726 print_otag(h
, TAG_TABLE
, 1, &tag
);
728 for (len
= 0, n
= n
->child
; n
; n
= n
->next
)
729 if (MDOC_TEXT
== n
->type
)
730 len
+= strlen(n
->string
);
732 if (0 == len
&& m
->name
)
733 len
= strlen(m
->name
);
735 SCALE_HS_INIT(&su
, (double)len
);
736 bufcat_su(h
, "width", &su
);
737 PAIR_STYLE_INIT(&tag
, h
);
738 print_otag(h
, TAG_COL
, 1, &tag
);
739 print_otag(h
, TAG_COL
, 0, NULL
);
740 print_otag(h
, TAG_TBODY
, 0, NULL
);
741 print_otag(h
, TAG_TR
, 0, NULL
);
748 mdoc_xr_pre(MDOC_ARGS
)
750 struct htmlpair tag
[2];
751 const struct mdoc_node
*nn
;
753 if (NULL
== n
->child
)
756 PAIR_CLASS_INIT(&tag
[0], "link-man");
759 buffmt_man(h
, n
->child
->string
,
761 n
->child
->next
->string
: NULL
);
762 PAIR_HREF_INIT(&tag
[1], h
->buf
);
763 print_otag(h
, TAG_A
, 2, tag
);
765 print_otag(h
, TAG_A
, 1, tag
);
768 print_text(h
, nn
->string
);
770 if (NULL
== (nn
= nn
->next
))
773 h
->flags
|= HTML_NOSPACE
;
775 h
->flags
|= HTML_NOSPACE
;
776 print_text(h
, nn
->string
);
777 h
->flags
|= HTML_NOSPACE
;
785 mdoc_ns_pre(MDOC_ARGS
)
788 if ( ! (MDOC_LINE
& n
->flags
))
789 h
->flags
|= HTML_NOSPACE
;
796 mdoc_ar_pre(MDOC_ARGS
)
800 PAIR_CLASS_INIT(&tag
, "arg");
801 print_otag(h
, TAG_I
, 1, &tag
);
808 mdoc_xx_pre(MDOC_ARGS
)
837 PAIR_CLASS_INIT(&tag
, "unix");
838 print_otag(h
, TAG_SPAN
, 1, &tag
);
843 h
->flags
|= HTML_KEEP
;
844 print_text(h
, n
->child
->string
);
853 mdoc_bx_pre(MDOC_ARGS
)
857 PAIR_CLASS_INIT(&tag
, "unix");
858 print_otag(h
, TAG_SPAN
, 1, &tag
);
860 if (NULL
!= (n
= n
->child
)) {
861 print_text(h
, n
->string
);
862 h
->flags
|= HTML_NOSPACE
;
863 print_text(h
, "BSD");
865 print_text(h
, "BSD");
869 if (NULL
!= (n
= n
->next
)) {
870 h
->flags
|= HTML_NOSPACE
;
872 h
->flags
|= HTML_NOSPACE
;
873 print_text(h
, n
->string
);
881 mdoc_it_pre(MDOC_ARGS
)
885 struct htmlpair tag
[2];
886 const struct mdoc_node
*bl
;
889 while (bl
&& MDOC_Bl
!= bl
->tok
)
894 type
= bl
->norm
->Bl
.type
;
897 PAIR_CLASS_INIT(&tag
[0], lists
[type
]);
899 if (MDOC_HEAD
== n
->type
) {
920 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
921 bufcat_su(h
, "margin-top", &su
);
922 PAIR_STYLE_INIT(&tag
[1], h
);
923 print_otag(h
, TAG_DT
, 2, tag
);
924 if (LIST_diag
!= type
)
926 PAIR_CLASS_INIT(&tag
[0], "diag");
927 print_otag(h
, TAG_B
, 1, tag
);
934 } else if (MDOC_BODY
== n
->type
) {
945 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
946 bufcat_su(h
, "margin-top", &su
);
947 PAIR_STYLE_INIT(&tag
[1], h
);
948 print_otag(h
, TAG_LI
, 2, tag
);
959 if (NULL
== bl
->norm
->Bl
.width
) {
960 print_otag(h
, TAG_DD
, 1, tag
);
963 a2width(bl
->norm
->Bl
.width
, &su
);
964 bufcat_su(h
, "margin-left", &su
);
965 PAIR_STYLE_INIT(&tag
[1], h
);
966 print_otag(h
, TAG_DD
, 2, tag
);
969 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
970 bufcat_su(h
, "margin-top", &su
);
971 PAIR_STYLE_INIT(&tag
[1], h
);
972 print_otag(h
, TAG_TD
, 2, tag
);
980 print_otag(h
, TAG_TR
, 1, tag
);
992 mdoc_bl_pre(MDOC_ARGS
)
995 struct htmlpair tag
[3];
999 if (MDOC_BODY
== n
->type
) {
1000 if (LIST_column
== n
->norm
->Bl
.type
)
1001 print_otag(h
, TAG_TBODY
, 0, NULL
);
1005 if (MDOC_HEAD
== n
->type
) {
1006 if (LIST_column
!= n
->norm
->Bl
.type
)
1010 * For each column, print out the <COL> tag with our
1011 * suggested width. The last column gets min-width, as
1012 * in terminal mode it auto-sizes to the width of the
1013 * screen and we want to preserve that behaviour.
1016 for (i
= 0; i
< (int)n
->norm
->Bl
.ncols
; i
++) {
1017 a2width(n
->norm
->Bl
.cols
[i
], &su
);
1019 if (i
< (int)n
->norm
->Bl
.ncols
- 1)
1020 bufcat_su(h
, "width", &su
);
1022 bufcat_su(h
, "min-width", &su
);
1023 PAIR_STYLE_INIT(&tag
[0], h
);
1024 print_otag(h
, TAG_COL
, 1, tag
);
1030 SCALE_VS_INIT(&su
, 0);
1031 bufcat_su(h
, "margin-top", &su
);
1032 bufcat_su(h
, "margin-bottom", &su
);
1033 PAIR_STYLE_INIT(&tag
[0], h
);
1035 assert(lists
[n
->norm
->Bl
.type
]);
1036 strlcpy(buf
, "list ", BUFSIZ
);
1037 strlcat(buf
, lists
[n
->norm
->Bl
.type
], BUFSIZ
);
1038 PAIR_INIT(&tag
[1], ATTR_CLASS
, buf
);
1040 /* Set the block's left-hand margin. */
1042 if (n
->norm
->Bl
.offs
) {
1043 a2offs(n
->norm
->Bl
.offs
, &su
);
1044 bufcat_su(h
, "margin-left", &su
);
1047 switch (n
->norm
->Bl
.type
) {
1055 print_otag(h
, TAG_UL
, 2, tag
);
1058 print_otag(h
, TAG_OL
, 2, tag
);
1069 print_otag(h
, TAG_DL
, 2, tag
);
1072 print_otag(h
, TAG_TABLE
, 2, tag
);
1084 mdoc_ex_pre(MDOC_ARGS
)
1086 const struct mdoc_node
*nn
;
1088 struct htmlpair tag
;
1091 print_otag(h
, TAG_BR
, 0, NULL
);
1093 PAIR_CLASS_INIT(&tag
, "utility");
1095 print_text(h
, "The");
1096 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1097 t
= print_otag(h
, TAG_B
, 1, &tag
);
1098 print_text(h
, nn
->string
);
1101 h
->flags
|= HTML_NOSPACE
;
1103 if (nn
->next
&& NULL
== nn
->next
->next
)
1104 print_text(h
, ", and");
1108 h
->flags
&= ~HTML_NOSPACE
;
1111 if (n
->child
&& n
->child
->next
)
1112 print_text(h
, "utilities exit");
1114 print_text(h
, "utility exits");
1116 print_text(h
, "0 on success, and >0 if an error occurs.");
1123 mdoc_em_pre(MDOC_ARGS
)
1125 struct htmlpair tag
;
1127 PAIR_CLASS_INIT(&tag
, "emph");
1128 print_otag(h
, TAG_SPAN
, 1, &tag
);
1135 mdoc_d1_pre(MDOC_ARGS
)
1137 struct htmlpair tag
[2];
1140 if (MDOC_BLOCK
!= n
->type
)
1143 SCALE_VS_INIT(&su
, 0);
1144 bufcat_su(h
, "margin-top", &su
);
1145 bufcat_su(h
, "margin-bottom", &su
);
1146 PAIR_STYLE_INIT(&tag
[0], h
);
1147 print_otag(h
, TAG_BLOCKQUOTE
, 1, tag
);
1149 /* BLOCKQUOTE needs a block body. */
1151 PAIR_CLASS_INIT(&tag
[0], "display");
1152 print_otag(h
, TAG_DIV
, 1, tag
);
1154 if (MDOC_Dl
== n
->tok
) {
1155 PAIR_CLASS_INIT(&tag
[0], "lit");
1156 print_otag(h
, TAG_CODE
, 1, tag
);
1165 mdoc_sx_pre(MDOC_ARGS
)
1167 struct htmlpair tag
[2];
1168 const struct mdoc_node
*nn
;
1171 strlcpy(buf
, "#", BUFSIZ
);
1172 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1173 html_idcat(buf
, nn
->string
, BUFSIZ
);
1175 html_idcat(buf
, " ", BUFSIZ
);
1178 PAIR_CLASS_INIT(&tag
[0], "link-sec");
1179 PAIR_HREF_INIT(&tag
[1], buf
);
1181 print_otag(h
, TAG_I
, 1, tag
);
1182 print_otag(h
, TAG_A
, 2, tag
);
1189 mdoc_bd_pre(MDOC_ARGS
)
1191 struct htmlpair tag
[2];
1193 const struct mdoc_node
*nn
;
1196 if (MDOC_HEAD
== n
->type
)
1199 if (MDOC_BLOCK
== n
->type
) {
1200 comp
= n
->norm
->Bd
.comp
;
1201 for (nn
= n
; nn
&& ! comp
; nn
= nn
->parent
) {
1202 if (MDOC_BLOCK
!= nn
->type
)
1204 if (MDOC_Ss
== nn
->tok
|| MDOC_Sh
== nn
->tok
)
1210 print_otag(h
, TAG_P
, 0, NULL
);
1214 SCALE_HS_INIT(&su
, 0);
1215 if (n
->norm
->Bd
.offs
)
1216 a2offs(n
->norm
->Bd
.offs
, &su
);
1218 bufcat_su(h
, "margin-left", &su
);
1219 PAIR_STYLE_INIT(&tag
[0], h
);
1221 if (DISP_unfilled
!= n
->norm
->Bd
.type
&&
1222 DISP_literal
!= n
->norm
->Bd
.type
) {
1223 PAIR_CLASS_INIT(&tag
[1], "display");
1224 print_otag(h
, TAG_DIV
, 2, tag
);
1228 PAIR_CLASS_INIT(&tag
[1], "lit display");
1229 print_otag(h
, TAG_PRE
, 2, tag
);
1231 /* This can be recursive: save & set our literal state. */
1233 sv
= h
->flags
& HTML_LITERAL
;
1234 h
->flags
|= HTML_LITERAL
;
1236 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1237 print_mdoc_node(m
, nn
, h
);
1239 * If the printed node flushes its own line, then we
1240 * needn't do it here as well. This is hacky, but the
1241 * notion of selective eoln whitespace is pretty dumb
1242 * anyway, so don't sweat it.
1264 if (nn
->next
&& nn
->next
->line
== nn
->line
)
1267 print_text(h
, "\n");
1269 h
->flags
|= HTML_NOSPACE
;
1273 h
->flags
&= ~HTML_LITERAL
;
1281 mdoc_pa_pre(MDOC_ARGS
)
1283 struct htmlpair tag
;
1285 PAIR_CLASS_INIT(&tag
, "file");
1286 print_otag(h
, TAG_I
, 1, &tag
);
1293 mdoc_ad_pre(MDOC_ARGS
)
1295 struct htmlpair tag
;
1297 PAIR_CLASS_INIT(&tag
, "addr");
1298 print_otag(h
, TAG_I
, 1, &tag
);
1305 mdoc_an_pre(MDOC_ARGS
)
1307 struct htmlpair tag
;
1309 /* TODO: -split and -nosplit (see termp_an_pre()). */
1311 PAIR_CLASS_INIT(&tag
, "author");
1312 print_otag(h
, TAG_SPAN
, 1, &tag
);
1319 mdoc_cd_pre(MDOC_ARGS
)
1321 struct htmlpair tag
;
1324 PAIR_CLASS_INIT(&tag
, "config");
1325 print_otag(h
, TAG_B
, 1, &tag
);
1332 mdoc_dv_pre(MDOC_ARGS
)
1334 struct htmlpair tag
;
1336 PAIR_CLASS_INIT(&tag
, "define");
1337 print_otag(h
, TAG_SPAN
, 1, &tag
);
1344 mdoc_ev_pre(MDOC_ARGS
)
1346 struct htmlpair tag
;
1348 PAIR_CLASS_INIT(&tag
, "env");
1349 print_otag(h
, TAG_SPAN
, 1, &tag
);
1356 mdoc_er_pre(MDOC_ARGS
)
1358 struct htmlpair tag
;
1360 PAIR_CLASS_INIT(&tag
, "errno");
1361 print_otag(h
, TAG_SPAN
, 1, &tag
);
1368 mdoc_fa_pre(MDOC_ARGS
)
1370 const struct mdoc_node
*nn
;
1371 struct htmlpair tag
;
1374 PAIR_CLASS_INIT(&tag
, "farg");
1375 if (n
->parent
->tok
!= MDOC_Fo
) {
1376 print_otag(h
, TAG_I
, 1, &tag
);
1380 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1381 t
= print_otag(h
, TAG_I
, 1, &tag
);
1382 print_text(h
, nn
->string
);
1388 if (n
->child
&& n
->next
&& n
->next
->tok
== MDOC_Fa
)
1397 mdoc_fd_pre(MDOC_ARGS
)
1399 struct htmlpair tag
;
1403 PAIR_CLASS_INIT(&tag
, "macro");
1404 print_otag(h
, TAG_B
, 1, &tag
);
1411 mdoc_vt_pre(MDOC_ARGS
)
1413 struct htmlpair tag
;
1415 if (MDOC_BLOCK
== n
->type
) {
1418 } else if (MDOC_ELEM
== n
->type
) {
1420 } else if (MDOC_HEAD
== n
->type
)
1423 PAIR_CLASS_INIT(&tag
, "type");
1424 print_otag(h
, TAG_SPAN
, 1, &tag
);
1431 mdoc_ft_pre(MDOC_ARGS
)
1433 struct htmlpair tag
;
1436 PAIR_CLASS_INIT(&tag
, "ftype");
1437 print_otag(h
, TAG_I
, 1, &tag
);
1444 mdoc_fn_pre(MDOC_ARGS
)
1447 struct htmlpair tag
[2];
1448 const struct mdoc_node
*nn
;
1450 const char *sp
, *ep
;
1455 /* Split apart into type and name. */
1456 assert(n
->child
->string
);
1457 sp
= n
->child
->string
;
1459 ep
= strchr(sp
, ' ');
1461 PAIR_CLASS_INIT(&tag
[0], "ftype");
1462 t
= print_otag(h
, TAG_I
, 1, tag
);
1465 sz
= MIN((int)(ep
- sp
), BUFSIZ
- 1);
1466 (void)memcpy(nbuf
, sp
, (size_t)sz
);
1468 print_text(h
, nbuf
);
1470 ep
= strchr(sp
, ' ');
1475 PAIR_CLASS_INIT(&tag
[0], "fname");
1478 * FIXME: only refer to IDs that we know exist.
1482 if (MDOC_SYNPRETTY
& n
->flags
) {
1484 html_idcat(nbuf
, sp
, BUFSIZ
);
1485 PAIR_ID_INIT(&tag
[1], nbuf
);
1487 strlcpy(nbuf
, "#", BUFSIZ
);
1488 html_idcat(nbuf
, sp
, BUFSIZ
);
1489 PAIR_HREF_INIT(&tag
[1], nbuf
);
1493 t
= print_otag(h
, TAG_B
, 1, tag
);
1496 strlcpy(nbuf
, sp
, BUFSIZ
);
1497 print_text(h
, nbuf
);
1502 h
->flags
|= HTML_NOSPACE
;
1506 PAIR_CLASS_INIT(&tag
[0], "farg");
1507 bufcat_style(h
, "white-space", "nowrap");
1508 PAIR_STYLE_INIT(&tag
[1], h
);
1510 for (nn
= n
->child
->next
; nn
; nn
= nn
->next
) {
1512 if (MDOC_SYNPRETTY
& n
->flags
)
1514 t
= print_otag(h
, TAG_I
, i
, tag
);
1515 print_text(h
, nn
->string
);
1522 if (MDOC_SYNPRETTY
& n
->flags
)
1531 mdoc_sm_pre(MDOC_ARGS
)
1534 assert(n
->child
&& MDOC_TEXT
== n
->child
->type
);
1535 if (0 == strcmp("on", n
->child
->string
)) {
1537 * FIXME: no p->col to check. Thus, if we have
1544 * the "3" is preceded by a space.
1546 h
->flags
&= ~HTML_NOSPACE
;
1547 h
->flags
&= ~HTML_NONOSPACE
;
1549 h
->flags
|= HTML_NONOSPACE
;
1556 mdoc_pp_pre(MDOC_ARGS
)
1559 print_otag(h
, TAG_P
, 0, NULL
);
1566 mdoc_sp_pre(MDOC_ARGS
)
1569 struct htmlpair tag
;
1571 SCALE_VS_INIT(&su
, 1);
1573 if (MDOC_sp
== n
->tok
) {
1575 a2roffsu(n
->child
->string
, &su
, SCALE_VS
);
1579 bufcat_su(h
, "height", &su
);
1580 PAIR_STYLE_INIT(&tag
, h
);
1581 print_otag(h
, TAG_DIV
, 1, &tag
);
1583 /* So the div isn't empty: */
1584 print_text(h
, "\\~");
1592 mdoc_lk_pre(MDOC_ARGS
)
1594 const struct mdoc_node
*nn
;
1595 struct htmlpair tag
[2];
1599 PAIR_CLASS_INIT(&tag
[0], "link-ext");
1600 PAIR_HREF_INIT(&tag
[1], nn
->string
);
1601 print_otag(h
, TAG_A
, 2, tag
);
1603 if (NULL
== nn
|| NULL
== nn
->next
)
1606 for (nn
= nn
->next
; nn
; nn
= nn
->next
)
1607 print_text(h
, nn
->string
);
1615 mdoc_mt_pre(MDOC_ARGS
)
1617 struct htmlpair tag
[2];
1619 const struct mdoc_node
*nn
;
1621 PAIR_CLASS_INIT(&tag
[0], "link-mail");
1623 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1625 bufcat(h
, "mailto:");
1626 bufcat(h
, nn
->string
);
1627 PAIR_HREF_INIT(&tag
[1], h
->buf
);
1628 t
= print_otag(h
, TAG_A
, 2, tag
);
1629 print_text(h
, nn
->string
);
1639 mdoc_fo_pre(MDOC_ARGS
)
1641 struct htmlpair tag
;
1644 if (MDOC_BODY
== n
->type
) {
1645 h
->flags
|= HTML_NOSPACE
;
1647 h
->flags
|= HTML_NOSPACE
;
1649 } else if (MDOC_BLOCK
== n
->type
) {
1654 /* XXX: we drop non-initial arguments as per groff. */
1657 assert(n
->child
->string
);
1659 PAIR_CLASS_INIT(&tag
, "fname");
1660 t
= print_otag(h
, TAG_B
, 1, &tag
);
1661 print_text(h
, n
->child
->string
);
1669 mdoc_fo_post(MDOC_ARGS
)
1672 if (MDOC_BODY
!= n
->type
)
1681 mdoc_in_pre(MDOC_ARGS
)
1683 const struct mdoc_node
*nn
;
1685 struct htmlpair tag
[2];
1690 PAIR_CLASS_INIT(&tag
[0], "includes");
1691 print_otag(h
, TAG_B
, 1, tag
);
1693 if (MDOC_SYNPRETTY
& n
->flags
&& MDOC_LINE
& n
->flags
)
1694 print_text(h
, "#include");
1697 h
->flags
|= HTML_NOSPACE
;
1699 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1700 PAIR_CLASS_INIT(&tag
[0], "link-includes");
1703 if (h
->base_includes
) {
1704 buffmt_includes(h
, nn
->string
);
1705 PAIR_HREF_INIT(&tag
[i
], h
->buf
);
1708 t
= print_otag(h
, TAG_A
, i
, tag
);
1709 print_mdoc_node(m
, nn
, h
);
1713 h
->flags
|= HTML_NOSPACE
;
1722 mdoc_ic_pre(MDOC_ARGS
)
1724 struct htmlpair tag
;
1726 PAIR_CLASS_INIT(&tag
, "cmd");
1727 print_otag(h
, TAG_B
, 1, &tag
);
1734 mdoc_rv_pre(MDOC_ARGS
)
1736 const struct mdoc_node
*nn
;
1737 struct htmlpair tag
;
1741 print_otag(h
, TAG_BR
, 0, NULL
);
1743 print_text(h
, "The");
1745 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1746 PAIR_CLASS_INIT(&tag
, "fname");
1747 t
= print_otag(h
, TAG_B
, 1, &tag
);
1748 print_text(h
, nn
->string
);
1751 h
->flags
|= HTML_NOSPACE
;
1752 if (nn
->next
&& NULL
== nn
->next
->next
)
1753 print_text(h
, "(), and");
1755 print_text(h
, "(),");
1757 print_text(h
, "()");
1760 if (n
->child
&& n
->child
->next
)
1761 print_text(h
, "functions return");
1763 print_text(h
, "function returns");
1765 print_text(h
, "the value 0 if successful; otherwise the value "
1766 "-1 is returned and the global variable");
1768 PAIR_CLASS_INIT(&tag
, "var");
1769 t
= print_otag(h
, TAG_B
, 1, &tag
);
1770 print_text(h
, "errno");
1772 print_text(h
, "is set to indicate the error.");
1779 mdoc_va_pre(MDOC_ARGS
)
1781 struct htmlpair tag
;
1783 PAIR_CLASS_INIT(&tag
, "var");
1784 print_otag(h
, TAG_B
, 1, &tag
);
1791 mdoc_ap_pre(MDOC_ARGS
)
1794 h
->flags
|= HTML_NOSPACE
;
1795 print_text(h
, "\\(aq");
1796 h
->flags
|= HTML_NOSPACE
;
1803 mdoc_bf_pre(MDOC_ARGS
)
1805 struct htmlpair tag
[2];
1808 if (MDOC_HEAD
== n
->type
)
1810 else if (MDOC_BODY
!= n
->type
)
1813 if (FONT_Em
== n
->norm
->Bf
.font
)
1814 PAIR_CLASS_INIT(&tag
[0], "emph");
1815 else if (FONT_Sy
== n
->norm
->Bf
.font
)
1816 PAIR_CLASS_INIT(&tag
[0], "symb");
1817 else if (FONT_Li
== n
->norm
->Bf
.font
)
1818 PAIR_CLASS_INIT(&tag
[0], "lit");
1820 PAIR_CLASS_INIT(&tag
[0], "none");
1823 * We want this to be inline-formatted, but needs to be div to
1824 * accept block children.
1826 bufcat_style(h
, "display", "inline");
1827 SCALE_HS_INIT(&su
, 1);
1828 /* Needs a left-margin for spacing. */
1829 bufcat_su(h
, "margin-left", &su
);
1830 PAIR_STYLE_INIT(&tag
[1], h
);
1831 print_otag(h
, TAG_DIV
, 2, tag
);
1838 mdoc_ms_pre(MDOC_ARGS
)
1840 struct htmlpair tag
;
1842 PAIR_CLASS_INIT(&tag
, "symb");
1843 print_otag(h
, TAG_SPAN
, 1, &tag
);
1850 mdoc_igndelim_pre(MDOC_ARGS
)
1853 h
->flags
|= HTML_IGNDELIM
;
1860 mdoc_pf_post(MDOC_ARGS
)
1863 h
->flags
|= HTML_NOSPACE
;
1869 mdoc_rs_pre(MDOC_ARGS
)
1871 struct htmlpair tag
;
1873 if (MDOC_BLOCK
!= n
->type
)
1876 if (n
->prev
&& SEC_SEE_ALSO
== n
->sec
)
1877 print_otag(h
, TAG_P
, 0, NULL
);
1879 PAIR_CLASS_INIT(&tag
, "ref");
1880 print_otag(h
, TAG_SPAN
, 1, &tag
);
1888 mdoc_li_pre(MDOC_ARGS
)
1890 struct htmlpair tag
;
1892 PAIR_CLASS_INIT(&tag
, "lit");
1893 print_otag(h
, TAG_SPAN
, 1, &tag
);
1900 mdoc_sy_pre(MDOC_ARGS
)
1902 struct htmlpair tag
;
1904 PAIR_CLASS_INIT(&tag
, "symb");
1905 print_otag(h
, TAG_SPAN
, 1, &tag
);
1912 mdoc_bt_pre(MDOC_ARGS
)
1915 print_text(h
, "is currently in beta test.");
1922 mdoc_ud_pre(MDOC_ARGS
)
1925 print_text(h
, "currently under development.");
1932 mdoc_lb_pre(MDOC_ARGS
)
1934 struct htmlpair tag
;
1936 if (SEC_LIBRARY
== n
->sec
&& MDOC_LINE
& n
->flags
&& n
->prev
)
1937 print_otag(h
, TAG_BR
, 0, NULL
);
1939 PAIR_CLASS_INIT(&tag
, "lib");
1940 print_otag(h
, TAG_SPAN
, 1, &tag
);
1947 mdoc__x_pre(MDOC_ARGS
)
1949 struct htmlpair tag
[2];
1956 PAIR_CLASS_INIT(&tag
[0], "ref-auth");
1957 if (n
->prev
&& MDOC__A
== n
->prev
->tok
)
1958 if (NULL
== n
->next
|| MDOC__A
!= n
->next
->tok
)
1959 print_text(h
, "and");
1962 PAIR_CLASS_INIT(&tag
[0], "ref-book");
1966 PAIR_CLASS_INIT(&tag
[0], "ref-city");
1969 PAIR_CLASS_INIT(&tag
[0], "ref-date");
1972 PAIR_CLASS_INIT(&tag
[0], "ref-issue");
1976 PAIR_CLASS_INIT(&tag
[0], "ref-jrnl");
1980 PAIR_CLASS_INIT(&tag
[0], "ref-num");
1983 PAIR_CLASS_INIT(&tag
[0], "ref-opt");
1986 PAIR_CLASS_INIT(&tag
[0], "ref-page");
1989 PAIR_CLASS_INIT(&tag
[0], "ref-corp");
1992 PAIR_CLASS_INIT(&tag
[0], "ref-rep");
1995 PAIR_CLASS_INIT(&tag
[0], "ref-title");
1998 PAIR_CLASS_INIT(&tag
[0], "link-ref");
2001 PAIR_CLASS_INIT(&tag
[0], "ref-vol");
2008 if (MDOC__U
!= n
->tok
) {
2009 print_otag(h
, t
, 1, tag
);
2013 PAIR_HREF_INIT(&tag
[1], n
->child
->string
);
2014 print_otag(h
, TAG_A
, 2, tag
);
2022 mdoc__x_post(MDOC_ARGS
)
2025 if (MDOC__A
== n
->tok
&& n
->next
&& MDOC__A
== n
->next
->tok
)
2026 if (NULL
== n
->next
->next
|| MDOC__A
!= n
->next
->next
->tok
)
2027 if (NULL
== n
->prev
|| MDOC__A
!= n
->prev
->tok
)
2032 if (NULL
== n
->parent
|| MDOC_Rs
!= n
->parent
->tok
)
2035 print_text(h
, n
->next
? "," : ".");
2041 mdoc_bk_pre(MDOC_ARGS
)
2050 if (n
->parent
->args
|| 0 == n
->prev
->nchild
)
2051 h
->flags
|= HTML_PREKEEP
;
2064 mdoc_bk_post(MDOC_ARGS
)
2067 if (MDOC_BODY
== n
->type
)
2068 h
->flags
&= ~(HTML_KEEP
| HTML_PREKEEP
);
2074 mdoc_quote_pre(MDOC_ARGS
)
2076 struct htmlpair tag
;
2078 if (MDOC_BODY
!= n
->type
)
2085 print_text(h
, "\\(la");
2090 print_text(h
, "\\(lC");
2095 print_text(h
, "\\(lB");
2100 print_text(h
, "\\(lB");
2101 h
->flags
|= HTML_NOSPACE
;
2102 PAIR_CLASS_INIT(&tag
, "opt");
2103 print_otag(h
, TAG_SPAN
, 1, &tag
);
2112 print_text(h
, "\\(lq");
2124 print_text(h
, "\\(oq");
2131 h
->flags
|= HTML_NOSPACE
;
2138 mdoc_quote_post(MDOC_ARGS
)
2141 if (MDOC_BODY
!= n
->type
)
2144 h
->flags
|= HTML_NOSPACE
;
2150 print_text(h
, "\\(ra");
2155 print_text(h
, "\\(rC");
2164 print_text(h
, "\\(rB");
2173 print_text(h
, "\\(rq");
2185 print_text(h
, "\\(aq");