]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_html.c
1 /* $Id: mdoc_html.c,v 1.161 2011/04/04 16:44:56 kristaps 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 if (MDOC_DELIMC
& n
->flags
)
435 h
->flags
|= HTML_NOSPACE
;
436 print_text(h
, n
->string
);
437 if (MDOC_DELIMO
& n
->flags
)
438 h
->flags
|= HTML_NOSPACE
;
441 PAIR_CLASS_INIT(&tag
, "eqn");
442 print_otag(h
, TAG_SPAN
, 1, &tag
);
443 print_text(h
, n
->eqn
->data
);
447 * This will take care of initialising all of the table
448 * state data for the first table, then tearing it down
451 print_tbl(h
, n
->span
);
455 * Close out the current table, if it's open, and unset
456 * the "meta" table state. This will be reopened on the
457 * next table element.
464 assert(NULL
== h
->tblt
);
465 if (mdocs
[n
->tok
].pre
&& ENDBODY_NOT
== n
->end
)
466 child
= (*mdocs
[n
->tok
].pre
)(m
, n
, h
);
470 if (HTML_KEEP
& h
->flags
) {
471 if (n
->prev
&& n
->prev
->line
!= n
->line
) {
472 h
->flags
&= ~HTML_KEEP
;
473 h
->flags
|= HTML_PREKEEP
;
474 } else if (NULL
== n
->prev
) {
475 if (n
->parent
&& n
->parent
->line
!= n
->line
) {
476 h
->flags
&= ~HTML_KEEP
;
477 h
->flags
|= HTML_PREKEEP
;
482 if (child
&& n
->child
)
483 print_mdoc_nodelist(m
, n
->child
, h
);
490 mdoc_root_post(m
, n
, h
);
495 if (mdocs
[n
->tok
].post
&& ENDBODY_NOT
== n
->end
)
496 (*mdocs
[n
->tok
].post
)(m
, n
, h
);
503 mdoc_root_post(MDOC_ARGS
)
505 struct htmlpair tag
[3];
508 PAIR_SUMMARY_INIT(&tag
[0], "Document Footer");
509 PAIR_CLASS_INIT(&tag
[1], "foot");
510 if (NULL
== h
->style
) {
511 PAIR_INIT(&tag
[2], ATTR_WIDTH
, "100%");
512 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
513 PAIR_INIT(&tag
[0], ATTR_WIDTH
, "50%");
514 print_otag(h
, TAG_COL
, 1, tag
);
515 print_otag(h
, TAG_COL
, 1, tag
);
517 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
519 t
= print_otag(h
, TAG_TBODY
, 0, NULL
);
521 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
523 PAIR_CLASS_INIT(&tag
[0], "foot-date");
524 print_otag(h
, TAG_TD
, 1, tag
);
526 print_text(h
, m
->date
);
529 PAIR_CLASS_INIT(&tag
[0], "foot-os");
530 if (NULL
== h
->style
) {
531 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "right");
532 print_otag(h
, TAG_TD
, 2, tag
);
534 print_otag(h
, TAG_TD
, 1, tag
);
536 print_text(h
, m
->os
);
543 mdoc_root_pre(MDOC_ARGS
)
545 struct htmlpair tag
[3];
547 char b
[BUFSIZ
], title
[BUFSIZ
];
549 strlcpy(b
, m
->vol
, BUFSIZ
);
552 strlcat(b
, " (", BUFSIZ
);
553 strlcat(b
, m
->arch
, BUFSIZ
);
554 strlcat(b
, ")", BUFSIZ
);
557 snprintf(title
, BUFSIZ
- 1, "%s(%s)", m
->title
, m
->msec
);
559 PAIR_SUMMARY_INIT(&tag
[0], "Document Header");
560 PAIR_CLASS_INIT(&tag
[1], "head");
561 if (NULL
== h
->style
) {
562 PAIR_INIT(&tag
[2], ATTR_WIDTH
, "100%");
563 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
564 PAIR_INIT(&tag
[0], ATTR_WIDTH
, "30%");
565 print_otag(h
, TAG_COL
, 1, tag
);
566 print_otag(h
, TAG_COL
, 1, tag
);
567 print_otag(h
, TAG_COL
, 1, tag
);
569 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
571 print_otag(h
, TAG_TBODY
, 0, NULL
);
573 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
575 PAIR_CLASS_INIT(&tag
[0], "head-ltitle");
576 print_otag(h
, TAG_TD
, 1, tag
);
578 print_text(h
, title
);
581 PAIR_CLASS_INIT(&tag
[0], "head-vol");
582 if (NULL
== h
->style
) {
583 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "center");
584 print_otag(h
, TAG_TD
, 2, tag
);
586 print_otag(h
, TAG_TD
, 1, tag
);
591 PAIR_CLASS_INIT(&tag
[0], "head-rtitle");
592 if (NULL
== h
->style
) {
593 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "right");
594 print_otag(h
, TAG_TD
, 2, tag
);
596 print_otag(h
, TAG_TD
, 1, tag
);
598 print_text(h
, title
);
606 mdoc_sh_pre(MDOC_ARGS
)
611 if (MDOC_BLOCK
== n
->type
) {
612 PAIR_CLASS_INIT(&tag
, "section");
613 print_otag(h
, TAG_DIV
, 1, &tag
);
615 } else if (MDOC_BODY
== n
->type
)
619 for (n
= n
->child
; n
; n
= n
->next
) {
620 html_idcat(buf
, n
->string
, BUFSIZ
);
622 html_idcat(buf
, " ", BUFSIZ
);
625 PAIR_ID_INIT(&tag
, buf
);
626 print_otag(h
, TAG_H1
, 1, &tag
);
633 mdoc_ss_pre(MDOC_ARGS
)
638 if (MDOC_BLOCK
== n
->type
) {
639 PAIR_CLASS_INIT(&tag
, "subsection");
640 print_otag(h
, TAG_DIV
, 1, &tag
);
642 } else if (MDOC_BODY
== n
->type
)
646 for (n
= n
->child
; n
; n
= n
->next
) {
647 html_idcat(buf
, n
->string
, BUFSIZ
);
649 html_idcat(buf
, " ", BUFSIZ
);
652 PAIR_ID_INIT(&tag
, buf
);
653 print_otag(h
, TAG_H2
, 1, &tag
);
660 mdoc_fl_pre(MDOC_ARGS
)
664 PAIR_CLASS_INIT(&tag
, "flag");
665 print_otag(h
, TAG_B
, 1, &tag
);
667 /* `Cm' has no leading hyphen. */
669 if (MDOC_Cm
== n
->tok
)
672 print_text(h
, "\\-");
675 h
->flags
|= HTML_NOSPACE
;
676 else if (n
->next
&& n
->next
->line
== n
->line
)
677 h
->flags
|= HTML_NOSPACE
;
685 mdoc_nd_pre(MDOC_ARGS
)
689 if (MDOC_BODY
!= n
->type
)
692 /* XXX: this tag in theory can contain block elements. */
694 print_text(h
, "\\(em");
695 PAIR_CLASS_INIT(&tag
, "desc");
696 print_otag(h
, TAG_SPAN
, 1, &tag
);
702 mdoc_nm_pre(MDOC_ARGS
)
711 PAIR_CLASS_INIT(&tag
, "name");
712 print_otag(h
, TAG_B
, 1, &tag
);
713 if (NULL
== n
->child
&& m
->name
)
714 print_text(h
, m
->name
);
717 print_otag(h
, TAG_TD
, 0, NULL
);
718 if (NULL
== n
->child
&& m
->name
)
719 print_text(h
, m
->name
);
722 print_otag(h
, TAG_TD
, 0, NULL
);
729 PAIR_CLASS_INIT(&tag
, "synopsis");
730 print_otag(h
, TAG_TABLE
, 1, &tag
);
732 for (len
= 0, n
= n
->child
; n
; n
= n
->next
)
733 if (MDOC_TEXT
== n
->type
)
734 len
+= strlen(n
->string
);
736 if (0 == len
&& m
->name
)
737 len
= strlen(m
->name
);
739 SCALE_HS_INIT(&su
, (double)len
);
740 bufcat_su(h
, "width", &su
);
741 PAIR_STYLE_INIT(&tag
, h
);
742 print_otag(h
, TAG_COL
, 1, &tag
);
743 print_otag(h
, TAG_COL
, 0, NULL
);
744 print_otag(h
, TAG_TBODY
, 0, NULL
);
745 print_otag(h
, TAG_TR
, 0, NULL
);
752 mdoc_xr_pre(MDOC_ARGS
)
754 struct htmlpair tag
[2];
756 if (NULL
== n
->child
)
759 PAIR_CLASS_INIT(&tag
[0], "link-man");
762 buffmt_man(h
, n
->child
->string
,
764 n
->child
->next
->string
: NULL
);
765 PAIR_HREF_INIT(&tag
[1], h
->buf
);
766 print_otag(h
, TAG_A
, 2, tag
);
768 print_otag(h
, TAG_A
, 1, tag
);
771 print_text(h
, n
->string
);
773 if (NULL
== (n
= n
->next
))
776 h
->flags
|= HTML_NOSPACE
;
778 h
->flags
|= HTML_NOSPACE
;
779 print_text(h
, n
->string
);
780 h
->flags
|= HTML_NOSPACE
;
788 mdoc_ns_pre(MDOC_ARGS
)
791 if ( ! (MDOC_LINE
& n
->flags
))
792 h
->flags
|= HTML_NOSPACE
;
799 mdoc_ar_pre(MDOC_ARGS
)
803 PAIR_CLASS_INIT(&tag
, "arg");
804 print_otag(h
, TAG_I
, 1, &tag
);
811 mdoc_xx_pre(MDOC_ARGS
)
840 PAIR_CLASS_INIT(&tag
, "unix");
841 print_otag(h
, TAG_SPAN
, 1, &tag
);
846 h
->flags
|= HTML_KEEP
;
847 print_text(h
, n
->child
->string
);
856 mdoc_bx_pre(MDOC_ARGS
)
860 PAIR_CLASS_INIT(&tag
, "unix");
861 print_otag(h
, TAG_SPAN
, 1, &tag
);
863 if (NULL
!= (n
= n
->child
)) {
864 print_text(h
, n
->string
);
865 h
->flags
|= HTML_NOSPACE
;
866 print_text(h
, "BSD");
868 print_text(h
, "BSD");
872 if (NULL
!= (n
= n
->next
)) {
873 h
->flags
|= HTML_NOSPACE
;
875 h
->flags
|= HTML_NOSPACE
;
876 print_text(h
, n
->string
);
884 mdoc_it_pre(MDOC_ARGS
)
888 struct htmlpair tag
[2];
889 const struct mdoc_node
*bl
;
892 while (bl
&& MDOC_Bl
!= bl
->tok
)
897 type
= bl
->norm
->Bl
.type
;
900 PAIR_CLASS_INIT(&tag
[0], lists
[type
]);
902 if (MDOC_HEAD
== n
->type
) {
923 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
924 bufcat_su(h
, "margin-top", &su
);
925 PAIR_STYLE_INIT(&tag
[1], h
);
926 print_otag(h
, TAG_DT
, 2, tag
);
927 if (LIST_diag
!= type
)
929 PAIR_CLASS_INIT(&tag
[0], "diag");
930 print_otag(h
, TAG_B
, 1, tag
);
937 } else if (MDOC_BODY
== n
->type
) {
948 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
949 bufcat_su(h
, "margin-top", &su
);
950 PAIR_STYLE_INIT(&tag
[1], h
);
951 print_otag(h
, TAG_LI
, 2, tag
);
962 if (NULL
== bl
->norm
->Bl
.width
) {
963 print_otag(h
, TAG_DD
, 1, tag
);
966 a2width(bl
->norm
->Bl
.width
, &su
);
967 bufcat_su(h
, "margin-left", &su
);
968 PAIR_STYLE_INIT(&tag
[1], h
);
969 print_otag(h
, TAG_DD
, 2, tag
);
972 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
973 bufcat_su(h
, "margin-top", &su
);
974 PAIR_STYLE_INIT(&tag
[1], h
);
975 print_otag(h
, TAG_TD
, 2, tag
);
983 print_otag(h
, TAG_TR
, 1, tag
);
995 mdoc_bl_pre(MDOC_ARGS
)
998 struct htmlpair tag
[3];
1002 if (MDOC_BODY
== n
->type
) {
1003 if (LIST_column
== n
->norm
->Bl
.type
)
1004 print_otag(h
, TAG_TBODY
, 0, NULL
);
1008 if (MDOC_HEAD
== n
->type
) {
1009 if (LIST_column
!= n
->norm
->Bl
.type
)
1013 * For each column, print out the <COL> tag with our
1014 * suggested width. The last column gets min-width, as
1015 * in terminal mode it auto-sizes to the width of the
1016 * screen and we want to preserve that behaviour.
1019 for (i
= 0; i
< (int)n
->norm
->Bl
.ncols
; i
++) {
1020 a2width(n
->norm
->Bl
.cols
[i
], &su
);
1022 if (i
< (int)n
->norm
->Bl
.ncols
- 1)
1023 bufcat_su(h
, "width", &su
);
1025 bufcat_su(h
, "min-width", &su
);
1026 PAIR_STYLE_INIT(&tag
[0], h
);
1027 print_otag(h
, TAG_COL
, 1, tag
);
1033 SCALE_VS_INIT(&su
, 0);
1034 bufcat_su(h
, "margin-top", &su
);
1035 bufcat_su(h
, "margin-bottom", &su
);
1036 PAIR_STYLE_INIT(&tag
[0], h
);
1038 assert(lists
[n
->norm
->Bl
.type
]);
1039 strlcpy(buf
, "list ", BUFSIZ
);
1040 strlcat(buf
, lists
[n
->norm
->Bl
.type
], BUFSIZ
);
1041 PAIR_INIT(&tag
[1], ATTR_CLASS
, buf
);
1043 /* Set the block's left-hand margin. */
1045 if (n
->norm
->Bl
.offs
) {
1046 a2offs(n
->norm
->Bl
.offs
, &su
);
1047 bufcat_su(h
, "margin-left", &su
);
1050 switch (n
->norm
->Bl
.type
) {
1058 print_otag(h
, TAG_UL
, 2, tag
);
1061 print_otag(h
, TAG_OL
, 2, tag
);
1072 print_otag(h
, TAG_DL
, 2, tag
);
1075 print_otag(h
, TAG_TABLE
, 2, tag
);
1087 mdoc_ex_pre(MDOC_ARGS
)
1090 struct htmlpair tag
;
1094 print_otag(h
, TAG_BR
, 0, NULL
);
1096 PAIR_CLASS_INIT(&tag
, "utility");
1098 print_text(h
, "The");
1101 for (n
= n
->child
; n
; n
= n
->next
) {
1102 assert(MDOC_TEXT
== n
->type
);
1104 t
= print_otag(h
, TAG_B
, 1, &tag
);
1105 print_text(h
, n
->string
);
1108 if (nchild
> 2 && n
->next
) {
1109 h
->flags
|= HTML_NOSPACE
;
1113 if (n
->next
&& NULL
== n
->next
->next
)
1114 print_text(h
, "and");
1118 print_text(h
, "utilities exit");
1120 print_text(h
, "utility exits");
1122 print_text(h
, "0 on success, and >0 if an error occurs.");
1129 mdoc_em_pre(MDOC_ARGS
)
1131 struct htmlpair tag
;
1133 PAIR_CLASS_INIT(&tag
, "emph");
1134 print_otag(h
, TAG_SPAN
, 1, &tag
);
1141 mdoc_d1_pre(MDOC_ARGS
)
1143 struct htmlpair tag
[2];
1146 if (MDOC_BLOCK
!= n
->type
)
1149 SCALE_VS_INIT(&su
, 0);
1150 bufcat_su(h
, "margin-top", &su
);
1151 bufcat_su(h
, "margin-bottom", &su
);
1152 PAIR_STYLE_INIT(&tag
[0], h
);
1153 print_otag(h
, TAG_BLOCKQUOTE
, 1, tag
);
1155 /* BLOCKQUOTE needs a block body. */
1157 PAIR_CLASS_INIT(&tag
[0], "display");
1158 print_otag(h
, TAG_DIV
, 1, tag
);
1160 if (MDOC_Dl
== n
->tok
) {
1161 PAIR_CLASS_INIT(&tag
[0], "lit");
1162 print_otag(h
, TAG_CODE
, 1, tag
);
1171 mdoc_sx_pre(MDOC_ARGS
)
1173 struct htmlpair tag
[2];
1176 strlcpy(buf
, "#", BUFSIZ
);
1177 for (n
= n
->child
; n
; n
= n
->next
) {
1178 html_idcat(buf
, n
->string
, BUFSIZ
);
1180 html_idcat(buf
, " ", BUFSIZ
);
1183 PAIR_CLASS_INIT(&tag
[0], "link-sec");
1184 PAIR_HREF_INIT(&tag
[1], buf
);
1186 print_otag(h
, TAG_I
, 1, tag
);
1187 print_otag(h
, TAG_A
, 2, tag
);
1194 mdoc_bd_pre(MDOC_ARGS
)
1196 struct htmlpair tag
[2];
1198 const struct mdoc_node
*nn
;
1201 if (MDOC_HEAD
== n
->type
)
1204 if (MDOC_BLOCK
== n
->type
) {
1205 comp
= n
->norm
->Bd
.comp
;
1206 for (nn
= n
; nn
&& ! comp
; nn
= nn
->parent
) {
1207 if (MDOC_BLOCK
!= nn
->type
)
1209 if (MDOC_Ss
== nn
->tok
|| MDOC_Sh
== nn
->tok
)
1215 print_otag(h
, TAG_P
, 0, NULL
);
1219 SCALE_HS_INIT(&su
, 0);
1220 if (n
->norm
->Bd
.offs
)
1221 a2offs(n
->norm
->Bd
.offs
, &su
);
1223 bufcat_su(h
, "margin-left", &su
);
1224 PAIR_STYLE_INIT(&tag
[0], h
);
1226 if (DISP_unfilled
!= n
->norm
->Bd
.type
&&
1227 DISP_literal
!= n
->norm
->Bd
.type
) {
1228 PAIR_CLASS_INIT(&tag
[1], "display");
1229 print_otag(h
, TAG_DIV
, 2, tag
);
1233 PAIR_CLASS_INIT(&tag
[1], "lit display");
1234 print_otag(h
, TAG_PRE
, 2, tag
);
1236 /* This can be recursive: save & set our literal state. */
1238 sv
= h
->flags
& HTML_LITERAL
;
1239 h
->flags
|= HTML_LITERAL
;
1241 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1242 print_mdoc_node(m
, nn
, h
);
1244 * If the printed node flushes its own line, then we
1245 * needn't do it here as well. This is hacky, but the
1246 * notion of selective eoln whitespace is pretty dumb
1247 * anyway, so don't sweat it.
1269 if (nn
->next
&& nn
->next
->line
== nn
->line
)
1272 print_text(h
, "\n");
1274 h
->flags
|= HTML_NOSPACE
;
1278 h
->flags
&= ~HTML_LITERAL
;
1286 mdoc_pa_pre(MDOC_ARGS
)
1288 struct htmlpair tag
;
1290 PAIR_CLASS_INIT(&tag
, "file");
1291 print_otag(h
, TAG_I
, 1, &tag
);
1298 mdoc_ad_pre(MDOC_ARGS
)
1300 struct htmlpair tag
;
1302 PAIR_CLASS_INIT(&tag
, "addr");
1303 print_otag(h
, TAG_I
, 1, &tag
);
1310 mdoc_an_pre(MDOC_ARGS
)
1312 struct htmlpair tag
;
1314 /* TODO: -split and -nosplit (see termp_an_pre()). */
1316 PAIR_CLASS_INIT(&tag
, "author");
1317 print_otag(h
, TAG_SPAN
, 1, &tag
);
1324 mdoc_cd_pre(MDOC_ARGS
)
1326 struct htmlpair tag
;
1329 PAIR_CLASS_INIT(&tag
, "config");
1330 print_otag(h
, TAG_B
, 1, &tag
);
1337 mdoc_dv_pre(MDOC_ARGS
)
1339 struct htmlpair tag
;
1341 PAIR_CLASS_INIT(&tag
, "define");
1342 print_otag(h
, TAG_SPAN
, 1, &tag
);
1349 mdoc_ev_pre(MDOC_ARGS
)
1351 struct htmlpair tag
;
1353 PAIR_CLASS_INIT(&tag
, "env");
1354 print_otag(h
, TAG_SPAN
, 1, &tag
);
1361 mdoc_er_pre(MDOC_ARGS
)
1363 struct htmlpair tag
;
1365 PAIR_CLASS_INIT(&tag
, "errno");
1366 print_otag(h
, TAG_SPAN
, 1, &tag
);
1373 mdoc_fa_pre(MDOC_ARGS
)
1375 const struct mdoc_node
*nn
;
1376 struct htmlpair tag
;
1379 PAIR_CLASS_INIT(&tag
, "farg");
1380 if (n
->parent
->tok
!= MDOC_Fo
) {
1381 print_otag(h
, TAG_I
, 1, &tag
);
1385 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1386 t
= print_otag(h
, TAG_I
, 1, &tag
);
1387 print_text(h
, nn
->string
);
1390 h
->flags
|= HTML_NOSPACE
;
1395 if (n
->child
&& n
->next
&& n
->next
->tok
== MDOC_Fa
) {
1396 h
->flags
|= HTML_NOSPACE
;
1406 mdoc_fd_pre(MDOC_ARGS
)
1408 struct htmlpair tag
;
1412 PAIR_CLASS_INIT(&tag
, "macro");
1413 print_otag(h
, TAG_B
, 1, &tag
);
1420 mdoc_vt_pre(MDOC_ARGS
)
1422 struct htmlpair tag
;
1424 if (MDOC_BLOCK
== n
->type
) {
1427 } else if (MDOC_ELEM
== n
->type
) {
1429 } else if (MDOC_HEAD
== n
->type
)
1432 PAIR_CLASS_INIT(&tag
, "type");
1433 print_otag(h
, TAG_SPAN
, 1, &tag
);
1440 mdoc_ft_pre(MDOC_ARGS
)
1442 struct htmlpair tag
;
1445 PAIR_CLASS_INIT(&tag
, "ftype");
1446 print_otag(h
, TAG_I
, 1, &tag
);
1453 mdoc_fn_pre(MDOC_ARGS
)
1456 struct htmlpair tag
[2];
1458 const char *sp
, *ep
;
1461 pretty
= MDOC_SYNPRETTY
& n
->flags
;
1464 /* Split apart into type and name. */
1465 assert(n
->child
->string
);
1466 sp
= n
->child
->string
;
1468 ep
= strchr(sp
, ' ');
1470 PAIR_CLASS_INIT(&tag
[0], "ftype");
1471 t
= print_otag(h
, TAG_I
, 1, tag
);
1474 sz
= MIN((int)(ep
- sp
), BUFSIZ
- 1);
1475 (void)memcpy(nbuf
, sp
, (size_t)sz
);
1477 print_text(h
, nbuf
);
1479 ep
= strchr(sp
, ' ');
1484 PAIR_CLASS_INIT(&tag
[0], "fname");
1487 * FIXME: only refer to IDs that we know exist.
1491 if (MDOC_SYNPRETTY
& n
->flags
) {
1493 html_idcat(nbuf
, sp
, BUFSIZ
);
1494 PAIR_ID_INIT(&tag
[1], nbuf
);
1496 strlcpy(nbuf
, "#", BUFSIZ
);
1497 html_idcat(nbuf
, sp
, BUFSIZ
);
1498 PAIR_HREF_INIT(&tag
[1], nbuf
);
1502 t
= print_otag(h
, TAG_B
, 1, tag
);
1505 strlcpy(nbuf
, sp
, BUFSIZ
);
1506 print_text(h
, nbuf
);
1511 h
->flags
|= HTML_NOSPACE
;
1515 PAIR_CLASS_INIT(&tag
[0], "farg");
1516 bufcat_style(h
, "white-space", "nowrap");
1517 PAIR_STYLE_INIT(&tag
[1], h
);
1519 for (n
= n
->child
->next
; n
; n
= n
->next
) {
1521 if (MDOC_SYNPRETTY
& n
->flags
)
1523 t
= print_otag(h
, TAG_I
, i
, tag
);
1524 print_text(h
, n
->string
);
1527 h
->flags
|= HTML_NOSPACE
;
1532 h
->flags
|= HTML_NOSPACE
;
1536 h
->flags
|= HTML_NOSPACE
;
1546 mdoc_sm_pre(MDOC_ARGS
)
1549 assert(n
->child
&& MDOC_TEXT
== n
->child
->type
);
1550 if (0 == strcmp("on", n
->child
->string
)) {
1552 * FIXME: no p->col to check. Thus, if we have
1559 * the "3" is preceded by a space.
1561 h
->flags
&= ~HTML_NOSPACE
;
1562 h
->flags
&= ~HTML_NONOSPACE
;
1564 h
->flags
|= HTML_NONOSPACE
;
1571 mdoc_pp_pre(MDOC_ARGS
)
1574 print_otag(h
, TAG_P
, 0, NULL
);
1581 mdoc_sp_pre(MDOC_ARGS
)
1584 struct htmlpair tag
;
1586 SCALE_VS_INIT(&su
, 1);
1588 if (MDOC_sp
== n
->tok
) {
1590 a2roffsu(n
->child
->string
, &su
, SCALE_VS
);
1594 bufcat_su(h
, "height", &su
);
1595 PAIR_STYLE_INIT(&tag
, h
);
1596 print_otag(h
, TAG_DIV
, 1, &tag
);
1598 /* So the div isn't empty: */
1599 print_text(h
, "\\~");
1607 mdoc_lk_pre(MDOC_ARGS
)
1609 struct htmlpair tag
[2];
1611 if (NULL
== (n
= n
->child
))
1614 assert(MDOC_TEXT
== n
->type
);
1616 PAIR_CLASS_INIT(&tag
[0], "link-ext");
1617 PAIR_HREF_INIT(&tag
[1], n
->string
);
1619 print_otag(h
, TAG_A
, 2, tag
);
1621 for (n
= n
->next
; n
; n
= n
->next
) {
1622 assert(MDOC_TEXT
== n
->type
);
1623 print_text(h
, n
->string
);
1632 mdoc_mt_pre(MDOC_ARGS
)
1634 struct htmlpair tag
[2];
1637 PAIR_CLASS_INIT(&tag
[0], "link-mail");
1639 for (n
= n
->child
; n
; n
= n
->next
) {
1640 assert(MDOC_TEXT
== n
->type
);
1643 bufcat(h
, "mailto:");
1644 bufcat(h
, n
->string
);
1646 PAIR_HREF_INIT(&tag
[1], h
->buf
);
1647 t
= print_otag(h
, TAG_A
, 2, tag
);
1648 print_text(h
, n
->string
);
1658 mdoc_fo_pre(MDOC_ARGS
)
1660 struct htmlpair tag
;
1663 if (MDOC_BODY
== n
->type
) {
1664 h
->flags
|= HTML_NOSPACE
;
1666 h
->flags
|= HTML_NOSPACE
;
1668 } else if (MDOC_BLOCK
== n
->type
) {
1673 /* XXX: we drop non-initial arguments as per groff. */
1676 assert(n
->child
->string
);
1678 PAIR_CLASS_INIT(&tag
, "fname");
1679 t
= print_otag(h
, TAG_B
, 1, &tag
);
1680 print_text(h
, n
->child
->string
);
1688 mdoc_fo_post(MDOC_ARGS
)
1691 if (MDOC_BODY
!= n
->type
)
1693 h
->flags
|= HTML_NOSPACE
;
1695 h
->flags
|= HTML_NOSPACE
;
1702 mdoc_in_pre(MDOC_ARGS
)
1705 struct htmlpair tag
[2];
1710 PAIR_CLASS_INIT(&tag
[0], "includes");
1711 print_otag(h
, TAG_B
, 1, tag
);
1714 * The first argument of the `In' gets special treatment as
1715 * being a linked value. Subsequent values are printed
1716 * afterward. groff does similarly. This also handles the case
1720 if (MDOC_SYNPRETTY
& n
->flags
&& MDOC_LINE
& n
->flags
)
1721 print_text(h
, "#include");
1724 h
->flags
|= HTML_NOSPACE
;
1726 if (NULL
!= (n
= n
->child
)) {
1727 assert(MDOC_TEXT
== n
->type
);
1729 PAIR_CLASS_INIT(&tag
[0], "link-includes");
1734 if (h
->base_includes
) {
1735 buffmt_includes(h
, n
->string
);
1736 PAIR_HREF_INIT(&tag
[i
], h
->buf
);
1740 t
= print_otag(h
, TAG_A
, i
, tag
);
1741 print_text(h
, n
->string
);
1747 h
->flags
|= HTML_NOSPACE
;
1750 for ( ; n
; n
= n
->next
) {
1751 assert(MDOC_TEXT
== n
->type
);
1752 print_text(h
, n
->string
);
1761 mdoc_ic_pre(MDOC_ARGS
)
1763 struct htmlpair tag
;
1765 PAIR_CLASS_INIT(&tag
, "cmd");
1766 print_otag(h
, TAG_B
, 1, &tag
);
1773 mdoc_rv_pre(MDOC_ARGS
)
1775 struct htmlpair tag
;
1780 print_otag(h
, TAG_BR
, 0, NULL
);
1782 PAIR_CLASS_INIT(&tag
, "fname");
1784 print_text(h
, "The");
1787 for (n
= n
->child
; n
; n
= n
->next
) {
1788 assert(MDOC_TEXT
== n
->type
);
1790 t
= print_otag(h
, TAG_B
, 1, &tag
);
1791 print_text(h
, n
->string
);
1794 h
->flags
|= HTML_NOSPACE
;
1795 print_text(h
, "()");
1797 if (nchild
> 2 && n
->next
) {
1798 h
->flags
|= HTML_NOSPACE
;
1802 if (n
->next
&& NULL
== n
->next
->next
)
1803 print_text(h
, "and");
1807 print_text(h
, "functions return");
1809 print_text(h
, "function returns");
1811 print_text(h
, "the value 0 if successful; otherwise the value "
1812 "-1 is returned and the global variable");
1814 PAIR_CLASS_INIT(&tag
, "var");
1815 t
= print_otag(h
, TAG_B
, 1, &tag
);
1816 print_text(h
, "errno");
1818 print_text(h
, "is set to indicate the error.");
1825 mdoc_va_pre(MDOC_ARGS
)
1827 struct htmlpair tag
;
1829 PAIR_CLASS_INIT(&tag
, "var");
1830 print_otag(h
, TAG_B
, 1, &tag
);
1837 mdoc_ap_pre(MDOC_ARGS
)
1840 h
->flags
|= HTML_NOSPACE
;
1841 print_text(h
, "\\(aq");
1842 h
->flags
|= HTML_NOSPACE
;
1849 mdoc_bf_pre(MDOC_ARGS
)
1851 struct htmlpair tag
[2];
1854 if (MDOC_HEAD
== n
->type
)
1856 else if (MDOC_BODY
!= n
->type
)
1859 if (FONT_Em
== n
->norm
->Bf
.font
)
1860 PAIR_CLASS_INIT(&tag
[0], "emph");
1861 else if (FONT_Sy
== n
->norm
->Bf
.font
)
1862 PAIR_CLASS_INIT(&tag
[0], "symb");
1863 else if (FONT_Li
== n
->norm
->Bf
.font
)
1864 PAIR_CLASS_INIT(&tag
[0], "lit");
1866 PAIR_CLASS_INIT(&tag
[0], "none");
1869 * We want this to be inline-formatted, but needs to be div to
1870 * accept block children.
1872 bufcat_style(h
, "display", "inline");
1873 SCALE_HS_INIT(&su
, 1);
1874 /* Needs a left-margin for spacing. */
1875 bufcat_su(h
, "margin-left", &su
);
1876 PAIR_STYLE_INIT(&tag
[1], h
);
1877 print_otag(h
, TAG_DIV
, 2, tag
);
1884 mdoc_ms_pre(MDOC_ARGS
)
1886 struct htmlpair tag
;
1888 PAIR_CLASS_INIT(&tag
, "symb");
1889 print_otag(h
, TAG_SPAN
, 1, &tag
);
1896 mdoc_igndelim_pre(MDOC_ARGS
)
1899 h
->flags
|= HTML_IGNDELIM
;
1906 mdoc_pf_post(MDOC_ARGS
)
1909 h
->flags
|= HTML_NOSPACE
;
1915 mdoc_rs_pre(MDOC_ARGS
)
1917 struct htmlpair tag
;
1919 if (MDOC_BLOCK
!= n
->type
)
1922 if (n
->prev
&& SEC_SEE_ALSO
== n
->sec
)
1923 print_otag(h
, TAG_P
, 0, NULL
);
1925 PAIR_CLASS_INIT(&tag
, "ref");
1926 print_otag(h
, TAG_SPAN
, 1, &tag
);
1934 mdoc_li_pre(MDOC_ARGS
)
1936 struct htmlpair tag
;
1938 PAIR_CLASS_INIT(&tag
, "lit");
1939 print_otag(h
, TAG_SPAN
, 1, &tag
);
1946 mdoc_sy_pre(MDOC_ARGS
)
1948 struct htmlpair tag
;
1950 PAIR_CLASS_INIT(&tag
, "symb");
1951 print_otag(h
, TAG_SPAN
, 1, &tag
);
1958 mdoc_bt_pre(MDOC_ARGS
)
1961 print_text(h
, "is currently in beta test.");
1968 mdoc_ud_pre(MDOC_ARGS
)
1971 print_text(h
, "currently under development.");
1978 mdoc_lb_pre(MDOC_ARGS
)
1980 struct htmlpair tag
;
1982 if (SEC_LIBRARY
== n
->sec
&& MDOC_LINE
& n
->flags
&& n
->prev
)
1983 print_otag(h
, TAG_BR
, 0, NULL
);
1985 PAIR_CLASS_INIT(&tag
, "lib");
1986 print_otag(h
, TAG_SPAN
, 1, &tag
);
1993 mdoc__x_pre(MDOC_ARGS
)
1995 struct htmlpair tag
[2];
2002 PAIR_CLASS_INIT(&tag
[0], "ref-auth");
2003 if (n
->prev
&& MDOC__A
== n
->prev
->tok
)
2004 if (NULL
== n
->next
|| MDOC__A
!= n
->next
->tok
)
2005 print_text(h
, "and");
2008 PAIR_CLASS_INIT(&tag
[0], "ref-book");
2012 PAIR_CLASS_INIT(&tag
[0], "ref-city");
2015 PAIR_CLASS_INIT(&tag
[0], "ref-date");
2018 PAIR_CLASS_INIT(&tag
[0], "ref-issue");
2022 PAIR_CLASS_INIT(&tag
[0], "ref-jrnl");
2026 PAIR_CLASS_INIT(&tag
[0], "ref-num");
2029 PAIR_CLASS_INIT(&tag
[0], "ref-opt");
2032 PAIR_CLASS_INIT(&tag
[0], "ref-page");
2035 PAIR_CLASS_INIT(&tag
[0], "ref-corp");
2038 PAIR_CLASS_INIT(&tag
[0], "ref-rep");
2041 PAIR_CLASS_INIT(&tag
[0], "ref-title");
2044 PAIR_CLASS_INIT(&tag
[0], "link-ref");
2047 PAIR_CLASS_INIT(&tag
[0], "ref-vol");
2054 if (MDOC__U
!= n
->tok
) {
2055 print_otag(h
, t
, 1, tag
);
2059 PAIR_HREF_INIT(&tag
[1], n
->child
->string
);
2060 print_otag(h
, TAG_A
, 2, tag
);
2068 mdoc__x_post(MDOC_ARGS
)
2071 if (MDOC__A
== n
->tok
&& n
->next
&& MDOC__A
== n
->next
->tok
)
2072 if (NULL
== n
->next
->next
|| MDOC__A
!= n
->next
->next
->tok
)
2073 if (NULL
== n
->prev
|| MDOC__A
!= n
->prev
->tok
)
2078 if (NULL
== n
->parent
|| MDOC_Rs
!= n
->parent
->tok
)
2081 h
->flags
|= HTML_NOSPACE
;
2082 print_text(h
, n
->next
? "," : ".");
2088 mdoc_bk_pre(MDOC_ARGS
)
2097 if (n
->parent
->args
|| 0 == n
->prev
->nchild
)
2098 h
->flags
|= HTML_PREKEEP
;
2111 mdoc_bk_post(MDOC_ARGS
)
2114 if (MDOC_BODY
== n
->type
)
2115 h
->flags
&= ~(HTML_KEEP
| HTML_PREKEEP
);
2121 mdoc_quote_pre(MDOC_ARGS
)
2123 struct htmlpair tag
;
2125 if (MDOC_BODY
!= n
->type
)
2132 print_text(h
, "\\(la");
2137 print_text(h
, "\\(lC");
2142 print_text(h
, "\\(lB");
2147 print_text(h
, "\\(lB");
2148 h
->flags
|= HTML_NOSPACE
;
2149 PAIR_CLASS_INIT(&tag
, "opt");
2150 print_otag(h
, TAG_SPAN
, 1, &tag
);
2159 print_text(h
, "\\(lq");
2171 print_text(h
, "\\(oq");
2178 h
->flags
|= HTML_NOSPACE
;
2185 mdoc_quote_post(MDOC_ARGS
)
2188 if (MDOC_BODY
!= n
->type
)
2191 h
->flags
|= HTML_NOSPACE
;
2197 print_text(h
, "\\(ra");
2202 print_text(h
, "\\(rC");
2211 print_text(h
, "\\(rB");
2220 print_text(h
, "\\(rq");
2232 print_text(h
, "\\(aq");