]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_html.c
1 /* $Id: mdoc_html.c,v 1.139 2010/12/24 22:47:37 kristaps Exp $ */
3 * Copyright (c) 2008, 2009, 2010 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
)
420 child
= mdoc_root_pre(m
, n
, h
);
423 print_text(h
, n
->string
);
426 if (mdocs
[n
->tok
].pre
&& ENDBODY_NOT
== n
->end
)
427 child
= (*mdocs
[n
->tok
].pre
)(m
, n
, h
);
431 if (HTML_KEEP
& h
->flags
) {
432 if (n
->prev
&& n
->prev
->line
!= n
->line
) {
433 h
->flags
&= ~HTML_KEEP
;
434 h
->flags
|= HTML_PREKEEP
;
435 } else if (NULL
== n
->prev
) {
436 if (n
->parent
&& n
->parent
->line
!= n
->line
) {
437 h
->flags
&= ~HTML_KEEP
;
438 h
->flags
|= HTML_PREKEEP
;
443 if (child
&& n
->child
)
444 print_mdoc_nodelist(m
, n
->child
, h
);
451 mdoc_root_post(m
, n
, h
);
454 if (mdocs
[n
->tok
].post
&& ENDBODY_NOT
== n
->end
)
455 (*mdocs
[n
->tok
].post
)(m
, n
, h
);
462 mdoc_root_post(MDOC_ARGS
)
464 struct htmlpair tag
[3];
468 time2a(m
->date
, b
, DATESIZ
);
470 PAIR_SUMMARY_INIT(&tag
[0], "Document Footer");
471 PAIR_CLASS_INIT(&tag
[1], "foot");
472 if (NULL
== h
->style
) {
473 PAIR_INIT(&tag
[2], ATTR_WIDTH
, "100%");
474 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
475 PAIR_INIT(&tag
[0], ATTR_WIDTH
, "50%");
476 print_otag(h
, TAG_COL
, 1, tag
);
477 print_otag(h
, TAG_COL
, 1, tag
);
479 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
481 t
= print_otag(h
, TAG_TBODY
, 0, NULL
);
483 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
485 PAIR_CLASS_INIT(&tag
[0], "foot-date");
486 print_otag(h
, TAG_TD
, 1, tag
);
491 PAIR_CLASS_INIT(&tag
[0], "foot-os");
492 if (NULL
== h
->style
) {
493 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "right");
494 print_otag(h
, TAG_TD
, 2, tag
);
496 print_otag(h
, TAG_TD
, 1, tag
);
498 print_text(h
, m
->os
);
505 mdoc_root_pre(MDOC_ARGS
)
507 struct htmlpair tag
[3];
509 char b
[BUFSIZ
], title
[BUFSIZ
];
511 strlcpy(b
, m
->vol
, BUFSIZ
);
514 strlcat(b
, " (", BUFSIZ
);
515 strlcat(b
, m
->arch
, BUFSIZ
);
516 strlcat(b
, ")", BUFSIZ
);
519 snprintf(title
, BUFSIZ
- 1, "%s(%s)", m
->title
, m
->msec
);
521 PAIR_SUMMARY_INIT(&tag
[0], "Document Header");
522 PAIR_CLASS_INIT(&tag
[1], "head");
523 if (NULL
== h
->style
) {
524 PAIR_INIT(&tag
[2], ATTR_WIDTH
, "100%");
525 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
526 PAIR_INIT(&tag
[0], ATTR_WIDTH
, "30%");
527 print_otag(h
, TAG_COL
, 1, tag
);
528 print_otag(h
, TAG_COL
, 1, tag
);
529 print_otag(h
, TAG_COL
, 1, tag
);
531 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
533 print_otag(h
, TAG_TBODY
, 0, NULL
);
535 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
537 PAIR_CLASS_INIT(&tag
[0], "head-ltitle");
538 print_otag(h
, TAG_TD
, 1, tag
);
540 print_text(h
, title
);
543 PAIR_CLASS_INIT(&tag
[0], "head-vol");
544 if (NULL
== h
->style
) {
545 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "center");
546 print_otag(h
, TAG_TD
, 2, tag
);
548 print_otag(h
, TAG_TD
, 1, tag
);
553 PAIR_CLASS_INIT(&tag
[0], "head-rtitle");
554 if (NULL
== h
->style
) {
555 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "right");
556 print_otag(h
, TAG_TD
, 2, tag
);
558 print_otag(h
, TAG_TD
, 1, tag
);
560 print_text(h
, title
);
568 mdoc_sh_pre(MDOC_ARGS
)
573 if (MDOC_BLOCK
== n
->type
) {
574 PAIR_CLASS_INIT(&tag
, "section");
575 print_otag(h
, TAG_DIV
, 1, &tag
);
577 } else if (MDOC_BODY
== n
->type
)
581 for (n
= n
->child
; n
; n
= n
->next
) {
582 html_idcat(buf
, n
->string
, BUFSIZ
);
584 html_idcat(buf
, " ", BUFSIZ
);
587 PAIR_ID_INIT(&tag
, buf
);
588 print_otag(h
, TAG_H1
, 1, &tag
);
595 mdoc_ss_pre(MDOC_ARGS
)
600 if (MDOC_BLOCK
== n
->type
) {
601 PAIR_CLASS_INIT(&tag
, "subsection");
602 print_otag(h
, TAG_DIV
, 1, &tag
);
604 } else if (MDOC_BODY
== n
->type
)
608 for (n
= n
->child
; n
; n
= n
->next
) {
609 html_idcat(buf
, n
->string
, BUFSIZ
);
611 html_idcat(buf
, " ", BUFSIZ
);
614 PAIR_ID_INIT(&tag
, buf
);
615 print_otag(h
, TAG_H2
, 1, &tag
);
622 mdoc_fl_pre(MDOC_ARGS
)
626 PAIR_CLASS_INIT(&tag
, "flag");
627 print_otag(h
, TAG_B
, 1, &tag
);
629 /* `Cm' has no leading hyphen. */
631 if (MDOC_Cm
== n
->tok
)
634 print_text(h
, "\\-");
637 h
->flags
|= HTML_NOSPACE
;
638 else if (n
->next
&& n
->next
->line
== n
->line
)
639 h
->flags
|= HTML_NOSPACE
;
647 mdoc_nd_pre(MDOC_ARGS
)
651 if (MDOC_BODY
!= n
->type
)
654 /* XXX: this tag in theory can contain block elements. */
656 print_text(h
, "\\(em");
657 PAIR_CLASS_INIT(&tag
, "desc");
658 print_otag(h
, TAG_SPAN
, 1, &tag
);
664 mdoc_nm_pre(MDOC_ARGS
)
673 PAIR_CLASS_INIT(&tag
, "name");
674 print_otag(h
, TAG_B
, 1, &tag
);
675 if (NULL
== n
->child
&& m
->name
)
676 print_text(h
, m
->name
);
679 print_otag(h
, TAG_TD
, 0, NULL
);
680 if (NULL
== n
->child
&& m
->name
)
681 print_text(h
, m
->name
);
684 print_otag(h
, TAG_TD
, 0, NULL
);
691 PAIR_CLASS_INIT(&tag
, "synopsis");
692 print_otag(h
, TAG_TABLE
, 1, &tag
);
694 for (len
= 0, n
= n
->child
; n
; n
= n
->next
)
695 if (MDOC_TEXT
== n
->type
)
696 len
+= strlen(n
->string
);
698 if (0 == len
&& m
->name
)
699 len
= strlen(m
->name
);
701 SCALE_HS_INIT(&su
, (double)len
);
702 bufcat_su(h
, "width", &su
);
703 PAIR_STYLE_INIT(&tag
, h
);
704 print_otag(h
, TAG_COL
, 1, &tag
);
705 print_otag(h
, TAG_COL
, 0, NULL
);
706 print_otag(h
, TAG_TBODY
, 0, NULL
);
707 print_otag(h
, TAG_TR
, 0, NULL
);
714 mdoc_xr_pre(MDOC_ARGS
)
716 struct htmlpair tag
[2];
717 const struct mdoc_node
*nn
;
719 if (NULL
== n
->child
)
722 PAIR_CLASS_INIT(&tag
[0], "link-man");
725 buffmt_man(h
, n
->child
->string
,
727 n
->child
->next
->string
: NULL
);
728 PAIR_HREF_INIT(&tag
[1], h
->buf
);
729 print_otag(h
, TAG_A
, 2, tag
);
731 print_otag(h
, TAG_A
, 1, tag
);
734 print_text(h
, nn
->string
);
736 if (NULL
== (nn
= nn
->next
))
739 h
->flags
|= HTML_NOSPACE
;
741 h
->flags
|= HTML_NOSPACE
;
742 print_text(h
, nn
->string
);
743 h
->flags
|= HTML_NOSPACE
;
751 mdoc_ns_pre(MDOC_ARGS
)
754 h
->flags
|= HTML_NOSPACE
;
761 mdoc_ar_pre(MDOC_ARGS
)
765 PAIR_CLASS_INIT(&tag
, "arg");
766 print_otag(h
, TAG_I
, 1, &tag
);
773 mdoc_xx_pre(MDOC_ARGS
)
801 PAIR_CLASS_INIT(&tag
, "unix");
802 print_otag(h
, TAG_SPAN
, 1, &tag
);
810 mdoc_bx_pre(MDOC_ARGS
)
812 const struct mdoc_node
*nn
;
815 PAIR_CLASS_INIT(&tag
, "unix");
816 print_otag(h
, TAG_SPAN
, 1, &tag
);
818 for (nn
= n
->child
; nn
; nn
= nn
->next
)
819 print_mdoc_node(m
, nn
, h
);
822 h
->flags
|= HTML_NOSPACE
;
824 print_text(h
, "BSD");
829 mdoc_it_pre(MDOC_ARGS
)
833 struct htmlpair tag
[2];
834 const struct mdoc_node
*bl
;
837 while (bl
&& MDOC_Bl
!= bl
->tok
)
842 type
= bl
->norm
->Bl
.type
;
845 PAIR_CLASS_INIT(&tag
[0], lists
[type
]);
847 if (MDOC_HEAD
== n
->type
) {
868 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
869 bufcat_su(h
, "margin-top", &su
);
870 PAIR_STYLE_INIT(&tag
[1], h
);
871 print_otag(h
, TAG_DT
, 2, tag
);
872 if (LIST_diag
!= type
)
874 PAIR_CLASS_INIT(&tag
[0], "diag");
875 print_otag(h
, TAG_B
, 1, tag
);
882 } else if (MDOC_BODY
== n
->type
) {
893 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
894 bufcat_su(h
, "margin-top", &su
);
895 PAIR_STYLE_INIT(&tag
[1], h
);
896 print_otag(h
, TAG_LI
, 2, tag
);
907 if (NULL
== bl
->norm
->Bl
.width
) {
908 print_otag(h
, TAG_DD
, 1, tag
);
911 a2width(bl
->norm
->Bl
.width
, &su
);
912 bufcat_su(h
, "margin-left", &su
);
913 PAIR_STYLE_INIT(&tag
[1], h
);
914 print_otag(h
, TAG_DD
, 2, tag
);
917 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
918 bufcat_su(h
, "margin-top", &su
);
919 PAIR_STYLE_INIT(&tag
[1], h
);
920 print_otag(h
, TAG_TD
, 2, tag
);
928 print_otag(h
, TAG_TR
, 1, tag
);
940 mdoc_bl_pre(MDOC_ARGS
)
943 struct htmlpair tag
[3];
947 if (MDOC_BODY
== n
->type
) {
948 if (LIST_column
== n
->norm
->Bl
.type
)
949 print_otag(h
, TAG_TBODY
, 0, NULL
);
953 if (MDOC_HEAD
== n
->type
) {
954 if (LIST_column
!= n
->norm
->Bl
.type
)
958 * For each column, print out the <COL> tag with our
959 * suggested width. The last column gets min-width, as
960 * in terminal mode it auto-sizes to the width of the
961 * screen and we want to preserve that behaviour.
964 for (i
= 0; i
< n
->norm
->Bl
.ncols
; i
++) {
965 a2width(n
->norm
->Bl
.cols
[i
], &su
);
967 if (i
< n
->norm
->Bl
.ncols
- 1)
968 bufcat_su(h
, "width", &su
);
970 bufcat_su(h
, "min-width", &su
);
971 PAIR_STYLE_INIT(&tag
[0], h
);
972 print_otag(h
, TAG_COL
, 1, tag
);
978 SCALE_VS_INIT(&su
, 0);
979 bufcat_su(h
, "margin-top", &su
);
980 bufcat_su(h
, "margin-bottom", &su
);
981 PAIR_STYLE_INIT(&tag
[0], h
);
983 assert(lists
[n
->norm
->Bl
.type
]);
984 strlcpy(buf
, "list ", BUFSIZ
);
985 strlcat(buf
, lists
[n
->norm
->Bl
.type
], BUFSIZ
);
986 PAIR_INIT(&tag
[1], ATTR_CLASS
, buf
);
988 /* Set the block's left-hand margin. */
990 if (n
->norm
->Bl
.offs
) {
991 a2offs(n
->norm
->Bl
.offs
, &su
);
992 bufcat_su(h
, "margin-left", &su
);
995 switch (n
->norm
->Bl
.type
) {
1003 print_otag(h
, TAG_UL
, 2, tag
);
1006 print_otag(h
, TAG_OL
, 2, tag
);
1017 print_otag(h
, TAG_DL
, 2, tag
);
1020 print_otag(h
, TAG_TABLE
, 2, tag
);
1032 mdoc_ex_pre(MDOC_ARGS
)
1034 const struct mdoc_node
*nn
;
1036 struct htmlpair tag
;
1039 print_otag(h
, TAG_BR
, 0, NULL
);
1041 PAIR_CLASS_INIT(&tag
, "utility");
1043 print_text(h
, "The");
1044 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1045 t
= print_otag(h
, TAG_B
, 1, &tag
);
1046 print_text(h
, nn
->string
);
1049 h
->flags
|= HTML_NOSPACE
;
1051 if (nn
->next
&& NULL
== nn
->next
->next
)
1052 print_text(h
, ", and");
1056 h
->flags
&= ~HTML_NOSPACE
;
1059 if (n
->child
&& n
->child
->next
)
1060 print_text(h
, "utilities exit");
1062 print_text(h
, "utility exits");
1064 print_text(h
, "0 on success, and >0 if an error occurs.");
1071 mdoc_em_pre(MDOC_ARGS
)
1073 struct htmlpair tag
;
1075 PAIR_CLASS_INIT(&tag
, "emph");
1076 print_otag(h
, TAG_SPAN
, 1, &tag
);
1083 mdoc_d1_pre(MDOC_ARGS
)
1085 struct htmlpair tag
[2];
1088 if (MDOC_BLOCK
!= n
->type
)
1091 SCALE_VS_INIT(&su
, 0);
1092 bufcat_su(h
, "margin-top", &su
);
1093 bufcat_su(h
, "margin-bottom", &su
);
1094 PAIR_STYLE_INIT(&tag
[0], h
);
1095 print_otag(h
, TAG_BLOCKQUOTE
, 1, tag
);
1097 /* BLOCKQUOTE needs a block body. */
1099 PAIR_CLASS_INIT(&tag
[0], "display");
1100 print_otag(h
, TAG_DIV
, 1, tag
);
1102 if (MDOC_Dl
== n
->tok
) {
1103 PAIR_CLASS_INIT(&tag
[0], "lit");
1104 print_otag(h
, TAG_CODE
, 1, tag
);
1113 mdoc_sx_pre(MDOC_ARGS
)
1115 struct htmlpair tag
[2];
1116 const struct mdoc_node
*nn
;
1119 strlcpy(buf
, "#", BUFSIZ
);
1120 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1121 html_idcat(buf
, nn
->string
, BUFSIZ
);
1123 html_idcat(buf
, " ", BUFSIZ
);
1126 PAIR_CLASS_INIT(&tag
[0], "link-sec");
1127 PAIR_HREF_INIT(&tag
[1], buf
);
1129 print_otag(h
, TAG_I
, 1, tag
);
1130 print_otag(h
, TAG_A
, 2, tag
);
1137 mdoc_bd_pre(MDOC_ARGS
)
1139 struct htmlpair tag
[2];
1141 const struct mdoc_node
*nn
;
1144 if (MDOC_HEAD
== n
->type
)
1147 if (MDOC_BLOCK
== n
->type
) {
1148 comp
= n
->norm
->Bd
.comp
;
1149 for (nn
= n
; nn
&& ! comp
; nn
= nn
->parent
) {
1150 if (MDOC_BLOCK
!= nn
->type
)
1152 if (MDOC_Ss
== nn
->tok
|| MDOC_Sh
== nn
->tok
)
1158 print_otag(h
, TAG_P
, 0, NULL
);
1162 SCALE_HS_INIT(&su
, 0);
1163 if (n
->norm
->Bd
.offs
)
1164 a2offs(n
->norm
->Bd
.offs
, &su
);
1166 bufcat_su(h
, "margin-left", &su
);
1167 PAIR_STYLE_INIT(&tag
[0], h
);
1169 if (DISP_unfilled
!= n
->norm
->Bd
.type
&&
1170 DISP_literal
!= n
->norm
->Bd
.type
) {
1171 PAIR_CLASS_INIT(&tag
[1], "display");
1172 print_otag(h
, TAG_DIV
, 2, tag
);
1176 PAIR_CLASS_INIT(&tag
[1], "lit display");
1177 print_otag(h
, TAG_PRE
, 2, tag
);
1179 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1180 print_mdoc_node(m
, nn
, h
);
1182 * If the printed node flushes its own line, then we
1183 * needn't do it here as well. This is hacky, but the
1184 * notion of selective eoln whitespace is pretty dumb
1185 * anyway, so don't sweat it.
1207 if (nn
->next
&& nn
->next
->line
== nn
->line
)
1210 print_text(h
, "\n");
1212 h
->flags
|= HTML_NOSPACE
;
1221 mdoc_pa_pre(MDOC_ARGS
)
1223 struct htmlpair tag
;
1225 PAIR_CLASS_INIT(&tag
, "file");
1226 print_otag(h
, TAG_I
, 1, &tag
);
1233 mdoc_ad_pre(MDOC_ARGS
)
1235 struct htmlpair tag
;
1237 PAIR_CLASS_INIT(&tag
, "addr");
1238 print_otag(h
, TAG_I
, 1, &tag
);
1245 mdoc_an_pre(MDOC_ARGS
)
1247 struct htmlpair tag
;
1249 /* TODO: -split and -nosplit (see termp_an_pre()). */
1251 PAIR_CLASS_INIT(&tag
, "author");
1252 print_otag(h
, TAG_SPAN
, 1, &tag
);
1259 mdoc_cd_pre(MDOC_ARGS
)
1261 struct htmlpair tag
;
1264 PAIR_CLASS_INIT(&tag
, "config");
1265 print_otag(h
, TAG_B
, 1, &tag
);
1272 mdoc_dv_pre(MDOC_ARGS
)
1274 struct htmlpair tag
;
1276 PAIR_CLASS_INIT(&tag
, "define");
1277 print_otag(h
, TAG_SPAN
, 1, &tag
);
1284 mdoc_ev_pre(MDOC_ARGS
)
1286 struct htmlpair tag
;
1288 PAIR_CLASS_INIT(&tag
, "env");
1289 print_otag(h
, TAG_SPAN
, 1, &tag
);
1296 mdoc_er_pre(MDOC_ARGS
)
1298 struct htmlpair tag
;
1300 PAIR_CLASS_INIT(&tag
, "errno");
1301 print_otag(h
, TAG_SPAN
, 1, &tag
);
1308 mdoc_fa_pre(MDOC_ARGS
)
1310 const struct mdoc_node
*nn
;
1311 struct htmlpair tag
;
1314 PAIR_CLASS_INIT(&tag
, "farg");
1315 if (n
->parent
->tok
!= MDOC_Fo
) {
1316 print_otag(h
, TAG_I
, 1, &tag
);
1320 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1321 t
= print_otag(h
, TAG_I
, 1, &tag
);
1322 print_text(h
, nn
->string
);
1328 if (n
->child
&& n
->next
&& n
->next
->tok
== MDOC_Fa
)
1337 mdoc_fd_pre(MDOC_ARGS
)
1339 struct htmlpair tag
;
1343 PAIR_CLASS_INIT(&tag
, "macro");
1344 print_otag(h
, TAG_B
, 1, &tag
);
1351 mdoc_vt_pre(MDOC_ARGS
)
1353 struct htmlpair tag
;
1355 if (MDOC_BLOCK
== n
->type
) {
1358 } else if (MDOC_ELEM
== n
->type
) {
1360 } else if (MDOC_HEAD
== n
->type
)
1363 PAIR_CLASS_INIT(&tag
, "type");
1364 print_otag(h
, TAG_SPAN
, 1, &tag
);
1371 mdoc_ft_pre(MDOC_ARGS
)
1373 struct htmlpair tag
;
1376 PAIR_CLASS_INIT(&tag
, "ftype");
1377 print_otag(h
, TAG_I
, 1, &tag
);
1384 mdoc_fn_pre(MDOC_ARGS
)
1387 struct htmlpair tag
[2];
1388 const struct mdoc_node
*nn
;
1390 const char *sp
, *ep
;
1395 /* Split apart into type and name. */
1396 assert(n
->child
->string
);
1397 sp
= n
->child
->string
;
1399 ep
= strchr(sp
, ' ');
1401 PAIR_CLASS_INIT(&tag
[0], "ftype");
1402 t
= print_otag(h
, TAG_I
, 1, tag
);
1405 sz
= MIN((int)(ep
- sp
), BUFSIZ
- 1);
1406 (void)memcpy(nbuf
, sp
, (size_t)sz
);
1408 print_text(h
, nbuf
);
1410 ep
= strchr(sp
, ' ');
1415 PAIR_CLASS_INIT(&tag
[0], "fname");
1418 * FIXME: only refer to IDs that we know exist.
1422 if (MDOC_SYNPRETTY
& n
->flags
) {
1424 html_idcat(nbuf
, sp
, BUFSIZ
);
1425 PAIR_ID_INIT(&tag
[1], nbuf
);
1427 strlcpy(nbuf
, "#", BUFSIZ
);
1428 html_idcat(nbuf
, sp
, BUFSIZ
);
1429 PAIR_HREF_INIT(&tag
[1], nbuf
);
1433 t
= print_otag(h
, TAG_B
, 1, tag
);
1436 strlcpy(nbuf
, sp
, BUFSIZ
);
1437 print_text(h
, nbuf
);
1442 h
->flags
|= HTML_NOSPACE
;
1446 PAIR_CLASS_INIT(&tag
[0], "farg");
1447 bufcat_style(h
, "white-space", "nowrap");
1448 PAIR_STYLE_INIT(&tag
[1], h
);
1450 for (nn
= n
->child
->next
; nn
; nn
= nn
->next
) {
1452 if (MDOC_SYNPRETTY
& n
->flags
)
1454 t
= print_otag(h
, TAG_I
, i
, tag
);
1455 print_text(h
, nn
->string
);
1462 if (MDOC_SYNPRETTY
& n
->flags
)
1471 mdoc_sm_pre(MDOC_ARGS
)
1474 assert(n
->child
&& MDOC_TEXT
== n
->child
->type
);
1475 if (0 == strcmp("on", n
->child
->string
)) {
1477 * FIXME: no p->col to check. Thus, if we have
1484 * the "3" is preceded by a space.
1486 h
->flags
&= ~HTML_NOSPACE
;
1487 h
->flags
&= ~HTML_NONOSPACE
;
1489 h
->flags
|= HTML_NONOSPACE
;
1496 mdoc_pp_pre(MDOC_ARGS
)
1499 print_otag(h
, TAG_P
, 0, NULL
);
1506 mdoc_sp_pre(MDOC_ARGS
)
1509 struct htmlpair tag
;
1511 SCALE_VS_INIT(&su
, 1);
1513 if (MDOC_sp
== n
->tok
) {
1515 a2roffsu(n
->child
->string
, &su
, SCALE_VS
);
1519 bufcat_su(h
, "height", &su
);
1520 PAIR_STYLE_INIT(&tag
, h
);
1521 print_otag(h
, TAG_DIV
, 1, &tag
);
1523 /* So the div isn't empty: */
1524 print_text(h
, "\\~");
1532 mdoc_lk_pre(MDOC_ARGS
)
1534 const struct mdoc_node
*nn
;
1535 struct htmlpair tag
[2];
1539 PAIR_CLASS_INIT(&tag
[0], "link-ext");
1540 PAIR_HREF_INIT(&tag
[1], nn
->string
);
1541 print_otag(h
, TAG_A
, 2, tag
);
1543 if (NULL
== nn
|| NULL
== nn
->next
)
1546 for (nn
= nn
->next
; nn
; nn
= nn
->next
)
1547 print_text(h
, nn
->string
);
1555 mdoc_mt_pre(MDOC_ARGS
)
1557 struct htmlpair tag
[2];
1559 const struct mdoc_node
*nn
;
1561 PAIR_CLASS_INIT(&tag
[0], "link-mail");
1563 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1565 bufcat(h
, "mailto:");
1566 bufcat(h
, nn
->string
);
1567 PAIR_HREF_INIT(&tag
[1], h
->buf
);
1568 t
= print_otag(h
, TAG_A
, 2, tag
);
1569 print_text(h
, nn
->string
);
1579 mdoc_fo_pre(MDOC_ARGS
)
1581 struct htmlpair tag
;
1584 if (MDOC_BODY
== n
->type
) {
1585 h
->flags
|= HTML_NOSPACE
;
1587 h
->flags
|= HTML_NOSPACE
;
1589 } else if (MDOC_BLOCK
== n
->type
) {
1594 /* XXX: we drop non-initial arguments as per groff. */
1597 assert(n
->child
->string
);
1599 PAIR_CLASS_INIT(&tag
, "fname");
1600 t
= print_otag(h
, TAG_B
, 1, &tag
);
1601 print_text(h
, n
->child
->string
);
1609 mdoc_fo_post(MDOC_ARGS
)
1612 if (MDOC_BODY
!= n
->type
)
1621 mdoc_in_pre(MDOC_ARGS
)
1623 const struct mdoc_node
*nn
;
1625 struct htmlpair tag
[2];
1630 PAIR_CLASS_INIT(&tag
[0], "includes");
1631 print_otag(h
, TAG_B
, 1, tag
);
1633 if (MDOC_SYNPRETTY
& n
->flags
&& MDOC_LINE
& n
->flags
)
1634 print_text(h
, "#include");
1637 h
->flags
|= HTML_NOSPACE
;
1639 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1640 PAIR_CLASS_INIT(&tag
[0], "link-includes");
1643 if (h
->base_includes
) {
1644 buffmt_includes(h
, nn
->string
);
1645 PAIR_HREF_INIT(&tag
[i
], h
->buf
);
1648 t
= print_otag(h
, TAG_A
, i
, tag
);
1649 print_mdoc_node(m
, nn
, h
);
1653 h
->flags
|= HTML_NOSPACE
;
1662 mdoc_ic_pre(MDOC_ARGS
)
1664 struct htmlpair tag
;
1666 PAIR_CLASS_INIT(&tag
, "cmd");
1667 print_otag(h
, TAG_B
, 1, &tag
);
1674 mdoc_rv_pre(MDOC_ARGS
)
1676 const struct mdoc_node
*nn
;
1677 struct htmlpair tag
;
1681 print_otag(h
, TAG_BR
, 0, NULL
);
1683 print_text(h
, "The");
1685 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1686 PAIR_CLASS_INIT(&tag
, "fname");
1687 t
= print_otag(h
, TAG_B
, 1, &tag
);
1688 print_text(h
, nn
->string
);
1691 h
->flags
|= HTML_NOSPACE
;
1692 if (nn
->next
&& NULL
== nn
->next
->next
)
1693 print_text(h
, "(), and");
1695 print_text(h
, "(),");
1697 print_text(h
, "()");
1700 if (n
->child
&& n
->child
->next
)
1701 print_text(h
, "functions return");
1703 print_text(h
, "function returns");
1705 print_text(h
, "the value 0 if successful; otherwise the value "
1706 "-1 is returned and the global variable");
1708 PAIR_CLASS_INIT(&tag
, "var");
1709 t
= print_otag(h
, TAG_B
, 1, &tag
);
1710 print_text(h
, "errno");
1712 print_text(h
, "is set to indicate the error.");
1719 mdoc_va_pre(MDOC_ARGS
)
1721 struct htmlpair tag
;
1723 PAIR_CLASS_INIT(&tag
, "var");
1724 print_otag(h
, TAG_B
, 1, &tag
);
1731 mdoc_ap_pre(MDOC_ARGS
)
1734 h
->flags
|= HTML_NOSPACE
;
1735 print_text(h
, "\\(aq");
1736 h
->flags
|= HTML_NOSPACE
;
1743 mdoc_bf_pre(MDOC_ARGS
)
1745 struct htmlpair tag
[2];
1748 if (MDOC_HEAD
== n
->type
)
1750 else if (MDOC_BODY
!= n
->type
)
1753 if (FONT_Em
== n
->norm
->Bf
.font
)
1754 PAIR_CLASS_INIT(&tag
[0], "emph");
1755 else if (FONT_Sy
== n
->norm
->Bf
.font
)
1756 PAIR_CLASS_INIT(&tag
[0], "symb");
1757 else if (FONT_Li
== n
->norm
->Bf
.font
)
1758 PAIR_CLASS_INIT(&tag
[0], "lit");
1760 PAIR_CLASS_INIT(&tag
[0], "none");
1763 * We want this to be inline-formatted, but needs to be div to
1764 * accept block children.
1766 bufcat_style(h
, "display", "inline");
1767 SCALE_HS_INIT(&su
, 1);
1768 /* Needs a left-margin for spacing. */
1769 bufcat_su(h
, "margin-left", &su
);
1770 PAIR_STYLE_INIT(&tag
[1], h
);
1771 print_otag(h
, TAG_DIV
, 2, tag
);
1778 mdoc_ms_pre(MDOC_ARGS
)
1780 struct htmlpair tag
;
1782 PAIR_CLASS_INIT(&tag
, "symb");
1783 print_otag(h
, TAG_SPAN
, 1, &tag
);
1790 mdoc_igndelim_pre(MDOC_ARGS
)
1793 h
->flags
|= HTML_IGNDELIM
;
1800 mdoc_pf_post(MDOC_ARGS
)
1803 h
->flags
|= HTML_NOSPACE
;
1809 mdoc_rs_pre(MDOC_ARGS
)
1811 struct htmlpair tag
;
1813 if (MDOC_BLOCK
!= n
->type
)
1816 if (n
->prev
&& SEC_SEE_ALSO
== n
->sec
)
1817 print_otag(h
, TAG_P
, 0, NULL
);
1819 PAIR_CLASS_INIT(&tag
, "ref");
1820 print_otag(h
, TAG_SPAN
, 1, &tag
);
1828 mdoc_li_pre(MDOC_ARGS
)
1830 struct htmlpair tag
;
1832 PAIR_CLASS_INIT(&tag
, "lit");
1833 print_otag(h
, TAG_SPAN
, 1, &tag
);
1840 mdoc_sy_pre(MDOC_ARGS
)
1842 struct htmlpair tag
;
1844 PAIR_CLASS_INIT(&tag
, "symb");
1845 print_otag(h
, TAG_SPAN
, 1, &tag
);
1852 mdoc_bt_pre(MDOC_ARGS
)
1855 print_text(h
, "is currently in beta test.");
1862 mdoc_ud_pre(MDOC_ARGS
)
1865 print_text(h
, "currently under development.");
1872 mdoc_lb_pre(MDOC_ARGS
)
1874 struct htmlpair tag
;
1876 if (SEC_LIBRARY
== n
->sec
&& MDOC_LINE
& n
->flags
&& n
->prev
)
1877 print_otag(h
, TAG_BR
, 0, NULL
);
1879 PAIR_CLASS_INIT(&tag
, "lib");
1880 print_otag(h
, TAG_SPAN
, 1, &tag
);
1887 mdoc__x_pre(MDOC_ARGS
)
1889 struct htmlpair tag
[2];
1896 PAIR_CLASS_INIT(&tag
[0], "ref-auth");
1897 if (n
->prev
&& MDOC__A
== n
->prev
->tok
)
1898 if (NULL
== n
->next
|| MDOC__A
!= n
->next
->tok
)
1899 print_text(h
, "and");
1902 PAIR_CLASS_INIT(&tag
[0], "ref-book");
1906 PAIR_CLASS_INIT(&tag
[0], "ref-city");
1909 PAIR_CLASS_INIT(&tag
[0], "ref-date");
1912 PAIR_CLASS_INIT(&tag
[0], "ref-issue");
1916 PAIR_CLASS_INIT(&tag
[0], "ref-jrnl");
1920 PAIR_CLASS_INIT(&tag
[0], "ref-num");
1923 PAIR_CLASS_INIT(&tag
[0], "ref-opt");
1926 PAIR_CLASS_INIT(&tag
[0], "ref-page");
1929 PAIR_CLASS_INIT(&tag
[0], "ref-corp");
1932 PAIR_CLASS_INIT(&tag
[0], "ref-rep");
1935 PAIR_CLASS_INIT(&tag
[0], "ref-title");
1938 PAIR_CLASS_INIT(&tag
[0], "link-ref");
1941 PAIR_CLASS_INIT(&tag
[0], "ref-vol");
1948 if (MDOC__U
!= n
->tok
) {
1949 print_otag(h
, t
, 1, tag
);
1953 PAIR_HREF_INIT(&tag
[1], n
->child
->string
);
1954 print_otag(h
, TAG_A
, 2, tag
);
1962 mdoc__x_post(MDOC_ARGS
)
1965 if (MDOC__A
== n
->tok
&& n
->next
&& MDOC__A
== n
->next
->tok
)
1966 if (NULL
== n
->next
->next
|| MDOC__A
!= n
->next
->next
->tok
)
1967 if (NULL
== n
->prev
|| MDOC__A
!= n
->prev
->tok
)
1972 if (NULL
== n
->parent
|| MDOC_Rs
!= n
->parent
->tok
)
1975 print_text(h
, n
->next
? "," : ".");
1981 mdoc_bk_pre(MDOC_ARGS
)
1990 if (n
->parent
->args
|| 0 == n
->prev
->nchild
)
1991 h
->flags
|= HTML_PREKEEP
;
2004 mdoc_bk_post(MDOC_ARGS
)
2007 if (MDOC_BODY
== n
->type
)
2008 h
->flags
&= ~(HTML_KEEP
| HTML_PREKEEP
);
2014 mdoc_quote_pre(MDOC_ARGS
)
2016 struct htmlpair tag
;
2018 if (MDOC_BODY
!= n
->type
)
2025 print_text(h
, "\\(la");
2030 print_text(h
, "\\(lC");
2035 print_text(h
, "\\(lB");
2040 print_text(h
, "\\(lB");
2041 h
->flags
|= HTML_NOSPACE
;
2042 PAIR_CLASS_INIT(&tag
, "opt");
2043 print_otag(h
, TAG_SPAN
, 1, &tag
);
2052 print_text(h
, "\\(lq");
2064 print_text(h
, "\\(oq");
2071 h
->flags
|= HTML_NOSPACE
;
2078 mdoc_quote_post(MDOC_ARGS
)
2081 if (MDOC_BODY
!= n
->type
)
2084 h
->flags
|= HTML_NOSPACE
;
2090 print_text(h
, "\\(ra");
2095 print_text(h
, "\\(rC");
2104 print_text(h
, "\\(rB");
2113 print_text(h
, "\\(rq");
2125 print_text(h
, "\\(aq");