]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_html.c
1 /* $Id: mdoc_html.c,v 1.140 2011/01/01 12:18: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
);
428 if (mdocs
[n
->tok
].pre
&& ENDBODY_NOT
== n
->end
)
429 child
= (*mdocs
[n
->tok
].pre
)(m
, n
, h
);
433 if (HTML_KEEP
& h
->flags
) {
434 if (n
->prev
&& n
->prev
->line
!= n
->line
) {
435 h
->flags
&= ~HTML_KEEP
;
436 h
->flags
|= HTML_PREKEEP
;
437 } else if (NULL
== n
->prev
) {
438 if (n
->parent
&& n
->parent
->line
!= n
->line
) {
439 h
->flags
&= ~HTML_KEEP
;
440 h
->flags
|= HTML_PREKEEP
;
445 if (child
&& n
->child
)
446 print_mdoc_nodelist(m
, n
->child
, h
);
453 mdoc_root_post(m
, n
, h
);
456 if (mdocs
[n
->tok
].post
&& ENDBODY_NOT
== n
->end
)
457 (*mdocs
[n
->tok
].post
)(m
, n
, h
);
464 mdoc_root_post(MDOC_ARGS
)
466 struct htmlpair tag
[3];
470 time2a(m
->date
, b
, DATESIZ
);
472 PAIR_SUMMARY_INIT(&tag
[0], "Document Footer");
473 PAIR_CLASS_INIT(&tag
[1], "foot");
474 if (NULL
== h
->style
) {
475 PAIR_INIT(&tag
[2], ATTR_WIDTH
, "100%");
476 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
477 PAIR_INIT(&tag
[0], ATTR_WIDTH
, "50%");
478 print_otag(h
, TAG_COL
, 1, tag
);
479 print_otag(h
, TAG_COL
, 1, tag
);
481 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
483 t
= print_otag(h
, TAG_TBODY
, 0, NULL
);
485 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
487 PAIR_CLASS_INIT(&tag
[0], "foot-date");
488 print_otag(h
, TAG_TD
, 1, tag
);
493 PAIR_CLASS_INIT(&tag
[0], "foot-os");
494 if (NULL
== h
->style
) {
495 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "right");
496 print_otag(h
, TAG_TD
, 2, tag
);
498 print_otag(h
, TAG_TD
, 1, tag
);
500 print_text(h
, m
->os
);
507 mdoc_root_pre(MDOC_ARGS
)
509 struct htmlpair tag
[3];
511 char b
[BUFSIZ
], title
[BUFSIZ
];
513 strlcpy(b
, m
->vol
, BUFSIZ
);
516 strlcat(b
, " (", BUFSIZ
);
517 strlcat(b
, m
->arch
, BUFSIZ
);
518 strlcat(b
, ")", BUFSIZ
);
521 snprintf(title
, BUFSIZ
- 1, "%s(%s)", m
->title
, m
->msec
);
523 PAIR_SUMMARY_INIT(&tag
[0], "Document Header");
524 PAIR_CLASS_INIT(&tag
[1], "head");
525 if (NULL
== h
->style
) {
526 PAIR_INIT(&tag
[2], ATTR_WIDTH
, "100%");
527 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
528 PAIR_INIT(&tag
[0], ATTR_WIDTH
, "30%");
529 print_otag(h
, TAG_COL
, 1, tag
);
530 print_otag(h
, TAG_COL
, 1, tag
);
531 print_otag(h
, TAG_COL
, 1, tag
);
533 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
535 print_otag(h
, TAG_TBODY
, 0, NULL
);
537 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
539 PAIR_CLASS_INIT(&tag
[0], "head-ltitle");
540 print_otag(h
, TAG_TD
, 1, tag
);
542 print_text(h
, title
);
545 PAIR_CLASS_INIT(&tag
[0], "head-vol");
546 if (NULL
== h
->style
) {
547 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "center");
548 print_otag(h
, TAG_TD
, 2, tag
);
550 print_otag(h
, TAG_TD
, 1, tag
);
555 PAIR_CLASS_INIT(&tag
[0], "head-rtitle");
556 if (NULL
== h
->style
) {
557 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "right");
558 print_otag(h
, TAG_TD
, 2, tag
);
560 print_otag(h
, TAG_TD
, 1, tag
);
562 print_text(h
, title
);
570 mdoc_sh_pre(MDOC_ARGS
)
575 if (MDOC_BLOCK
== n
->type
) {
576 PAIR_CLASS_INIT(&tag
, "section");
577 print_otag(h
, TAG_DIV
, 1, &tag
);
579 } else if (MDOC_BODY
== n
->type
)
583 for (n
= n
->child
; n
; n
= n
->next
) {
584 html_idcat(buf
, n
->string
, BUFSIZ
);
586 html_idcat(buf
, " ", BUFSIZ
);
589 PAIR_ID_INIT(&tag
, buf
);
590 print_otag(h
, TAG_H1
, 1, &tag
);
597 mdoc_ss_pre(MDOC_ARGS
)
602 if (MDOC_BLOCK
== n
->type
) {
603 PAIR_CLASS_INIT(&tag
, "subsection");
604 print_otag(h
, TAG_DIV
, 1, &tag
);
606 } else if (MDOC_BODY
== n
->type
)
610 for (n
= n
->child
; n
; n
= n
->next
) {
611 html_idcat(buf
, n
->string
, BUFSIZ
);
613 html_idcat(buf
, " ", BUFSIZ
);
616 PAIR_ID_INIT(&tag
, buf
);
617 print_otag(h
, TAG_H2
, 1, &tag
);
624 mdoc_fl_pre(MDOC_ARGS
)
628 PAIR_CLASS_INIT(&tag
, "flag");
629 print_otag(h
, TAG_B
, 1, &tag
);
631 /* `Cm' has no leading hyphen. */
633 if (MDOC_Cm
== n
->tok
)
636 print_text(h
, "\\-");
639 h
->flags
|= HTML_NOSPACE
;
640 else if (n
->next
&& n
->next
->line
== n
->line
)
641 h
->flags
|= HTML_NOSPACE
;
649 mdoc_nd_pre(MDOC_ARGS
)
653 if (MDOC_BODY
!= n
->type
)
656 /* XXX: this tag in theory can contain block elements. */
658 print_text(h
, "\\(em");
659 PAIR_CLASS_INIT(&tag
, "desc");
660 print_otag(h
, TAG_SPAN
, 1, &tag
);
666 mdoc_nm_pre(MDOC_ARGS
)
675 PAIR_CLASS_INIT(&tag
, "name");
676 print_otag(h
, TAG_B
, 1, &tag
);
677 if (NULL
== n
->child
&& m
->name
)
678 print_text(h
, m
->name
);
681 print_otag(h
, TAG_TD
, 0, NULL
);
682 if (NULL
== n
->child
&& m
->name
)
683 print_text(h
, m
->name
);
686 print_otag(h
, TAG_TD
, 0, NULL
);
693 PAIR_CLASS_INIT(&tag
, "synopsis");
694 print_otag(h
, TAG_TABLE
, 1, &tag
);
696 for (len
= 0, n
= n
->child
; n
; n
= n
->next
)
697 if (MDOC_TEXT
== n
->type
)
698 len
+= strlen(n
->string
);
700 if (0 == len
&& m
->name
)
701 len
= strlen(m
->name
);
703 SCALE_HS_INIT(&su
, (double)len
);
704 bufcat_su(h
, "width", &su
);
705 PAIR_STYLE_INIT(&tag
, h
);
706 print_otag(h
, TAG_COL
, 1, &tag
);
707 print_otag(h
, TAG_COL
, 0, NULL
);
708 print_otag(h
, TAG_TBODY
, 0, NULL
);
709 print_otag(h
, TAG_TR
, 0, NULL
);
716 mdoc_xr_pre(MDOC_ARGS
)
718 struct htmlpair tag
[2];
719 const struct mdoc_node
*nn
;
721 if (NULL
== n
->child
)
724 PAIR_CLASS_INIT(&tag
[0], "link-man");
727 buffmt_man(h
, n
->child
->string
,
729 n
->child
->next
->string
: NULL
);
730 PAIR_HREF_INIT(&tag
[1], h
->buf
);
731 print_otag(h
, TAG_A
, 2, tag
);
733 print_otag(h
, TAG_A
, 1, tag
);
736 print_text(h
, nn
->string
);
738 if (NULL
== (nn
= nn
->next
))
741 h
->flags
|= HTML_NOSPACE
;
743 h
->flags
|= HTML_NOSPACE
;
744 print_text(h
, nn
->string
);
745 h
->flags
|= HTML_NOSPACE
;
753 mdoc_ns_pre(MDOC_ARGS
)
756 h
->flags
|= HTML_NOSPACE
;
763 mdoc_ar_pre(MDOC_ARGS
)
767 PAIR_CLASS_INIT(&tag
, "arg");
768 print_otag(h
, TAG_I
, 1, &tag
);
775 mdoc_xx_pre(MDOC_ARGS
)
803 PAIR_CLASS_INIT(&tag
, "unix");
804 print_otag(h
, TAG_SPAN
, 1, &tag
);
812 mdoc_bx_pre(MDOC_ARGS
)
814 const struct mdoc_node
*nn
;
817 PAIR_CLASS_INIT(&tag
, "unix");
818 print_otag(h
, TAG_SPAN
, 1, &tag
);
820 for (nn
= n
->child
; nn
; nn
= nn
->next
)
821 print_mdoc_node(m
, nn
, h
);
824 h
->flags
|= HTML_NOSPACE
;
826 print_text(h
, "BSD");
831 mdoc_it_pre(MDOC_ARGS
)
835 struct htmlpair tag
[2];
836 const struct mdoc_node
*bl
;
839 while (bl
&& MDOC_Bl
!= bl
->tok
)
844 type
= bl
->norm
->Bl
.type
;
847 PAIR_CLASS_INIT(&tag
[0], lists
[type
]);
849 if (MDOC_HEAD
== n
->type
) {
870 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
871 bufcat_su(h
, "margin-top", &su
);
872 PAIR_STYLE_INIT(&tag
[1], h
);
873 print_otag(h
, TAG_DT
, 2, tag
);
874 if (LIST_diag
!= type
)
876 PAIR_CLASS_INIT(&tag
[0], "diag");
877 print_otag(h
, TAG_B
, 1, tag
);
884 } else if (MDOC_BODY
== n
->type
) {
895 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
896 bufcat_su(h
, "margin-top", &su
);
897 PAIR_STYLE_INIT(&tag
[1], h
);
898 print_otag(h
, TAG_LI
, 2, tag
);
909 if (NULL
== bl
->norm
->Bl
.width
) {
910 print_otag(h
, TAG_DD
, 1, tag
);
913 a2width(bl
->norm
->Bl
.width
, &su
);
914 bufcat_su(h
, "margin-left", &su
);
915 PAIR_STYLE_INIT(&tag
[1], h
);
916 print_otag(h
, TAG_DD
, 2, tag
);
919 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
920 bufcat_su(h
, "margin-top", &su
);
921 PAIR_STYLE_INIT(&tag
[1], h
);
922 print_otag(h
, TAG_TD
, 2, tag
);
930 print_otag(h
, TAG_TR
, 1, tag
);
942 mdoc_bl_pre(MDOC_ARGS
)
945 struct htmlpair tag
[3];
949 if (MDOC_BODY
== n
->type
) {
950 if (LIST_column
== n
->norm
->Bl
.type
)
951 print_otag(h
, TAG_TBODY
, 0, NULL
);
955 if (MDOC_HEAD
== n
->type
) {
956 if (LIST_column
!= n
->norm
->Bl
.type
)
960 * For each column, print out the <COL> tag with our
961 * suggested width. The last column gets min-width, as
962 * in terminal mode it auto-sizes to the width of the
963 * screen and we want to preserve that behaviour.
966 for (i
= 0; i
< n
->norm
->Bl
.ncols
; i
++) {
967 a2width(n
->norm
->Bl
.cols
[i
], &su
);
969 if (i
< n
->norm
->Bl
.ncols
- 1)
970 bufcat_su(h
, "width", &su
);
972 bufcat_su(h
, "min-width", &su
);
973 PAIR_STYLE_INIT(&tag
[0], h
);
974 print_otag(h
, TAG_COL
, 1, tag
);
980 SCALE_VS_INIT(&su
, 0);
981 bufcat_su(h
, "margin-top", &su
);
982 bufcat_su(h
, "margin-bottom", &su
);
983 PAIR_STYLE_INIT(&tag
[0], h
);
985 assert(lists
[n
->norm
->Bl
.type
]);
986 strlcpy(buf
, "list ", BUFSIZ
);
987 strlcat(buf
, lists
[n
->norm
->Bl
.type
], BUFSIZ
);
988 PAIR_INIT(&tag
[1], ATTR_CLASS
, buf
);
990 /* Set the block's left-hand margin. */
992 if (n
->norm
->Bl
.offs
) {
993 a2offs(n
->norm
->Bl
.offs
, &su
);
994 bufcat_su(h
, "margin-left", &su
);
997 switch (n
->norm
->Bl
.type
) {
1005 print_otag(h
, TAG_UL
, 2, tag
);
1008 print_otag(h
, TAG_OL
, 2, tag
);
1019 print_otag(h
, TAG_DL
, 2, tag
);
1022 print_otag(h
, TAG_TABLE
, 2, tag
);
1034 mdoc_ex_pre(MDOC_ARGS
)
1036 const struct mdoc_node
*nn
;
1038 struct htmlpair tag
;
1041 print_otag(h
, TAG_BR
, 0, NULL
);
1043 PAIR_CLASS_INIT(&tag
, "utility");
1045 print_text(h
, "The");
1046 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1047 t
= print_otag(h
, TAG_B
, 1, &tag
);
1048 print_text(h
, nn
->string
);
1051 h
->flags
|= HTML_NOSPACE
;
1053 if (nn
->next
&& NULL
== nn
->next
->next
)
1054 print_text(h
, ", and");
1058 h
->flags
&= ~HTML_NOSPACE
;
1061 if (n
->child
&& n
->child
->next
)
1062 print_text(h
, "utilities exit");
1064 print_text(h
, "utility exits");
1066 print_text(h
, "0 on success, and >0 if an error occurs.");
1073 mdoc_em_pre(MDOC_ARGS
)
1075 struct htmlpair tag
;
1077 PAIR_CLASS_INIT(&tag
, "emph");
1078 print_otag(h
, TAG_SPAN
, 1, &tag
);
1085 mdoc_d1_pre(MDOC_ARGS
)
1087 struct htmlpair tag
[2];
1090 if (MDOC_BLOCK
!= n
->type
)
1093 SCALE_VS_INIT(&su
, 0);
1094 bufcat_su(h
, "margin-top", &su
);
1095 bufcat_su(h
, "margin-bottom", &su
);
1096 PAIR_STYLE_INIT(&tag
[0], h
);
1097 print_otag(h
, TAG_BLOCKQUOTE
, 1, tag
);
1099 /* BLOCKQUOTE needs a block body. */
1101 PAIR_CLASS_INIT(&tag
[0], "display");
1102 print_otag(h
, TAG_DIV
, 1, tag
);
1104 if (MDOC_Dl
== n
->tok
) {
1105 PAIR_CLASS_INIT(&tag
[0], "lit");
1106 print_otag(h
, TAG_CODE
, 1, tag
);
1115 mdoc_sx_pre(MDOC_ARGS
)
1117 struct htmlpair tag
[2];
1118 const struct mdoc_node
*nn
;
1121 strlcpy(buf
, "#", BUFSIZ
);
1122 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1123 html_idcat(buf
, nn
->string
, BUFSIZ
);
1125 html_idcat(buf
, " ", BUFSIZ
);
1128 PAIR_CLASS_INIT(&tag
[0], "link-sec");
1129 PAIR_HREF_INIT(&tag
[1], buf
);
1131 print_otag(h
, TAG_I
, 1, tag
);
1132 print_otag(h
, TAG_A
, 2, tag
);
1139 mdoc_bd_pre(MDOC_ARGS
)
1141 struct htmlpair tag
[2];
1143 const struct mdoc_node
*nn
;
1146 if (MDOC_HEAD
== n
->type
)
1149 if (MDOC_BLOCK
== n
->type
) {
1150 comp
= n
->norm
->Bd
.comp
;
1151 for (nn
= n
; nn
&& ! comp
; nn
= nn
->parent
) {
1152 if (MDOC_BLOCK
!= nn
->type
)
1154 if (MDOC_Ss
== nn
->tok
|| MDOC_Sh
== nn
->tok
)
1160 print_otag(h
, TAG_P
, 0, NULL
);
1164 SCALE_HS_INIT(&su
, 0);
1165 if (n
->norm
->Bd
.offs
)
1166 a2offs(n
->norm
->Bd
.offs
, &su
);
1168 bufcat_su(h
, "margin-left", &su
);
1169 PAIR_STYLE_INIT(&tag
[0], h
);
1171 if (DISP_unfilled
!= n
->norm
->Bd
.type
&&
1172 DISP_literal
!= n
->norm
->Bd
.type
) {
1173 PAIR_CLASS_INIT(&tag
[1], "display");
1174 print_otag(h
, TAG_DIV
, 2, tag
);
1178 PAIR_CLASS_INIT(&tag
[1], "lit display");
1179 print_otag(h
, TAG_PRE
, 2, tag
);
1181 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1182 print_mdoc_node(m
, nn
, h
);
1184 * If the printed node flushes its own line, then we
1185 * needn't do it here as well. This is hacky, but the
1186 * notion of selective eoln whitespace is pretty dumb
1187 * anyway, so don't sweat it.
1209 if (nn
->next
&& nn
->next
->line
== nn
->line
)
1212 print_text(h
, "\n");
1214 h
->flags
|= HTML_NOSPACE
;
1223 mdoc_pa_pre(MDOC_ARGS
)
1225 struct htmlpair tag
;
1227 PAIR_CLASS_INIT(&tag
, "file");
1228 print_otag(h
, TAG_I
, 1, &tag
);
1235 mdoc_ad_pre(MDOC_ARGS
)
1237 struct htmlpair tag
;
1239 PAIR_CLASS_INIT(&tag
, "addr");
1240 print_otag(h
, TAG_I
, 1, &tag
);
1247 mdoc_an_pre(MDOC_ARGS
)
1249 struct htmlpair tag
;
1251 /* TODO: -split and -nosplit (see termp_an_pre()). */
1253 PAIR_CLASS_INIT(&tag
, "author");
1254 print_otag(h
, TAG_SPAN
, 1, &tag
);
1261 mdoc_cd_pre(MDOC_ARGS
)
1263 struct htmlpair tag
;
1266 PAIR_CLASS_INIT(&tag
, "config");
1267 print_otag(h
, TAG_B
, 1, &tag
);
1274 mdoc_dv_pre(MDOC_ARGS
)
1276 struct htmlpair tag
;
1278 PAIR_CLASS_INIT(&tag
, "define");
1279 print_otag(h
, TAG_SPAN
, 1, &tag
);
1286 mdoc_ev_pre(MDOC_ARGS
)
1288 struct htmlpair tag
;
1290 PAIR_CLASS_INIT(&tag
, "env");
1291 print_otag(h
, TAG_SPAN
, 1, &tag
);
1298 mdoc_er_pre(MDOC_ARGS
)
1300 struct htmlpair tag
;
1302 PAIR_CLASS_INIT(&tag
, "errno");
1303 print_otag(h
, TAG_SPAN
, 1, &tag
);
1310 mdoc_fa_pre(MDOC_ARGS
)
1312 const struct mdoc_node
*nn
;
1313 struct htmlpair tag
;
1316 PAIR_CLASS_INIT(&tag
, "farg");
1317 if (n
->parent
->tok
!= MDOC_Fo
) {
1318 print_otag(h
, TAG_I
, 1, &tag
);
1322 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1323 t
= print_otag(h
, TAG_I
, 1, &tag
);
1324 print_text(h
, nn
->string
);
1330 if (n
->child
&& n
->next
&& n
->next
->tok
== MDOC_Fa
)
1339 mdoc_fd_pre(MDOC_ARGS
)
1341 struct htmlpair tag
;
1345 PAIR_CLASS_INIT(&tag
, "macro");
1346 print_otag(h
, TAG_B
, 1, &tag
);
1353 mdoc_vt_pre(MDOC_ARGS
)
1355 struct htmlpair tag
;
1357 if (MDOC_BLOCK
== n
->type
) {
1360 } else if (MDOC_ELEM
== n
->type
) {
1362 } else if (MDOC_HEAD
== n
->type
)
1365 PAIR_CLASS_INIT(&tag
, "type");
1366 print_otag(h
, TAG_SPAN
, 1, &tag
);
1373 mdoc_ft_pre(MDOC_ARGS
)
1375 struct htmlpair tag
;
1378 PAIR_CLASS_INIT(&tag
, "ftype");
1379 print_otag(h
, TAG_I
, 1, &tag
);
1386 mdoc_fn_pre(MDOC_ARGS
)
1389 struct htmlpair tag
[2];
1390 const struct mdoc_node
*nn
;
1392 const char *sp
, *ep
;
1397 /* Split apart into type and name. */
1398 assert(n
->child
->string
);
1399 sp
= n
->child
->string
;
1401 ep
= strchr(sp
, ' ');
1403 PAIR_CLASS_INIT(&tag
[0], "ftype");
1404 t
= print_otag(h
, TAG_I
, 1, tag
);
1407 sz
= MIN((int)(ep
- sp
), BUFSIZ
- 1);
1408 (void)memcpy(nbuf
, sp
, (size_t)sz
);
1410 print_text(h
, nbuf
);
1412 ep
= strchr(sp
, ' ');
1417 PAIR_CLASS_INIT(&tag
[0], "fname");
1420 * FIXME: only refer to IDs that we know exist.
1424 if (MDOC_SYNPRETTY
& n
->flags
) {
1426 html_idcat(nbuf
, sp
, BUFSIZ
);
1427 PAIR_ID_INIT(&tag
[1], nbuf
);
1429 strlcpy(nbuf
, "#", BUFSIZ
);
1430 html_idcat(nbuf
, sp
, BUFSIZ
);
1431 PAIR_HREF_INIT(&tag
[1], nbuf
);
1435 t
= print_otag(h
, TAG_B
, 1, tag
);
1438 strlcpy(nbuf
, sp
, BUFSIZ
);
1439 print_text(h
, nbuf
);
1444 h
->flags
|= HTML_NOSPACE
;
1448 PAIR_CLASS_INIT(&tag
[0], "farg");
1449 bufcat_style(h
, "white-space", "nowrap");
1450 PAIR_STYLE_INIT(&tag
[1], h
);
1452 for (nn
= n
->child
->next
; nn
; nn
= nn
->next
) {
1454 if (MDOC_SYNPRETTY
& n
->flags
)
1456 t
= print_otag(h
, TAG_I
, i
, tag
);
1457 print_text(h
, nn
->string
);
1464 if (MDOC_SYNPRETTY
& n
->flags
)
1473 mdoc_sm_pre(MDOC_ARGS
)
1476 assert(n
->child
&& MDOC_TEXT
== n
->child
->type
);
1477 if (0 == strcmp("on", n
->child
->string
)) {
1479 * FIXME: no p->col to check. Thus, if we have
1486 * the "3" is preceded by a space.
1488 h
->flags
&= ~HTML_NOSPACE
;
1489 h
->flags
&= ~HTML_NONOSPACE
;
1491 h
->flags
|= HTML_NONOSPACE
;
1498 mdoc_pp_pre(MDOC_ARGS
)
1501 print_otag(h
, TAG_P
, 0, NULL
);
1508 mdoc_sp_pre(MDOC_ARGS
)
1511 struct htmlpair tag
;
1513 SCALE_VS_INIT(&su
, 1);
1515 if (MDOC_sp
== n
->tok
) {
1517 a2roffsu(n
->child
->string
, &su
, SCALE_VS
);
1521 bufcat_su(h
, "height", &su
);
1522 PAIR_STYLE_INIT(&tag
, h
);
1523 print_otag(h
, TAG_DIV
, 1, &tag
);
1525 /* So the div isn't empty: */
1526 print_text(h
, "\\~");
1534 mdoc_lk_pre(MDOC_ARGS
)
1536 const struct mdoc_node
*nn
;
1537 struct htmlpair tag
[2];
1541 PAIR_CLASS_INIT(&tag
[0], "link-ext");
1542 PAIR_HREF_INIT(&tag
[1], nn
->string
);
1543 print_otag(h
, TAG_A
, 2, tag
);
1545 if (NULL
== nn
|| NULL
== nn
->next
)
1548 for (nn
= nn
->next
; nn
; nn
= nn
->next
)
1549 print_text(h
, nn
->string
);
1557 mdoc_mt_pre(MDOC_ARGS
)
1559 struct htmlpair tag
[2];
1561 const struct mdoc_node
*nn
;
1563 PAIR_CLASS_INIT(&tag
[0], "link-mail");
1565 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1567 bufcat(h
, "mailto:");
1568 bufcat(h
, nn
->string
);
1569 PAIR_HREF_INIT(&tag
[1], h
->buf
);
1570 t
= print_otag(h
, TAG_A
, 2, tag
);
1571 print_text(h
, nn
->string
);
1581 mdoc_fo_pre(MDOC_ARGS
)
1583 struct htmlpair tag
;
1586 if (MDOC_BODY
== n
->type
) {
1587 h
->flags
|= HTML_NOSPACE
;
1589 h
->flags
|= HTML_NOSPACE
;
1591 } else if (MDOC_BLOCK
== n
->type
) {
1596 /* XXX: we drop non-initial arguments as per groff. */
1599 assert(n
->child
->string
);
1601 PAIR_CLASS_INIT(&tag
, "fname");
1602 t
= print_otag(h
, TAG_B
, 1, &tag
);
1603 print_text(h
, n
->child
->string
);
1611 mdoc_fo_post(MDOC_ARGS
)
1614 if (MDOC_BODY
!= n
->type
)
1623 mdoc_in_pre(MDOC_ARGS
)
1625 const struct mdoc_node
*nn
;
1627 struct htmlpair tag
[2];
1632 PAIR_CLASS_INIT(&tag
[0], "includes");
1633 print_otag(h
, TAG_B
, 1, tag
);
1635 if (MDOC_SYNPRETTY
& n
->flags
&& MDOC_LINE
& n
->flags
)
1636 print_text(h
, "#include");
1639 h
->flags
|= HTML_NOSPACE
;
1641 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1642 PAIR_CLASS_INIT(&tag
[0], "link-includes");
1645 if (h
->base_includes
) {
1646 buffmt_includes(h
, nn
->string
);
1647 PAIR_HREF_INIT(&tag
[i
], h
->buf
);
1650 t
= print_otag(h
, TAG_A
, i
, tag
);
1651 print_mdoc_node(m
, nn
, h
);
1655 h
->flags
|= HTML_NOSPACE
;
1664 mdoc_ic_pre(MDOC_ARGS
)
1666 struct htmlpair tag
;
1668 PAIR_CLASS_INIT(&tag
, "cmd");
1669 print_otag(h
, TAG_B
, 1, &tag
);
1676 mdoc_rv_pre(MDOC_ARGS
)
1678 const struct mdoc_node
*nn
;
1679 struct htmlpair tag
;
1683 print_otag(h
, TAG_BR
, 0, NULL
);
1685 print_text(h
, "The");
1687 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1688 PAIR_CLASS_INIT(&tag
, "fname");
1689 t
= print_otag(h
, TAG_B
, 1, &tag
);
1690 print_text(h
, nn
->string
);
1693 h
->flags
|= HTML_NOSPACE
;
1694 if (nn
->next
&& NULL
== nn
->next
->next
)
1695 print_text(h
, "(), and");
1697 print_text(h
, "(),");
1699 print_text(h
, "()");
1702 if (n
->child
&& n
->child
->next
)
1703 print_text(h
, "functions return");
1705 print_text(h
, "function returns");
1707 print_text(h
, "the value 0 if successful; otherwise the value "
1708 "-1 is returned and the global variable");
1710 PAIR_CLASS_INIT(&tag
, "var");
1711 t
= print_otag(h
, TAG_B
, 1, &tag
);
1712 print_text(h
, "errno");
1714 print_text(h
, "is set to indicate the error.");
1721 mdoc_va_pre(MDOC_ARGS
)
1723 struct htmlpair tag
;
1725 PAIR_CLASS_INIT(&tag
, "var");
1726 print_otag(h
, TAG_B
, 1, &tag
);
1733 mdoc_ap_pre(MDOC_ARGS
)
1736 h
->flags
|= HTML_NOSPACE
;
1737 print_text(h
, "\\(aq");
1738 h
->flags
|= HTML_NOSPACE
;
1745 mdoc_bf_pre(MDOC_ARGS
)
1747 struct htmlpair tag
[2];
1750 if (MDOC_HEAD
== n
->type
)
1752 else if (MDOC_BODY
!= n
->type
)
1755 if (FONT_Em
== n
->norm
->Bf
.font
)
1756 PAIR_CLASS_INIT(&tag
[0], "emph");
1757 else if (FONT_Sy
== n
->norm
->Bf
.font
)
1758 PAIR_CLASS_INIT(&tag
[0], "symb");
1759 else if (FONT_Li
== n
->norm
->Bf
.font
)
1760 PAIR_CLASS_INIT(&tag
[0], "lit");
1762 PAIR_CLASS_INIT(&tag
[0], "none");
1765 * We want this to be inline-formatted, but needs to be div to
1766 * accept block children.
1768 bufcat_style(h
, "display", "inline");
1769 SCALE_HS_INIT(&su
, 1);
1770 /* Needs a left-margin for spacing. */
1771 bufcat_su(h
, "margin-left", &su
);
1772 PAIR_STYLE_INIT(&tag
[1], h
);
1773 print_otag(h
, TAG_DIV
, 2, tag
);
1780 mdoc_ms_pre(MDOC_ARGS
)
1782 struct htmlpair tag
;
1784 PAIR_CLASS_INIT(&tag
, "symb");
1785 print_otag(h
, TAG_SPAN
, 1, &tag
);
1792 mdoc_igndelim_pre(MDOC_ARGS
)
1795 h
->flags
|= HTML_IGNDELIM
;
1802 mdoc_pf_post(MDOC_ARGS
)
1805 h
->flags
|= HTML_NOSPACE
;
1811 mdoc_rs_pre(MDOC_ARGS
)
1813 struct htmlpair tag
;
1815 if (MDOC_BLOCK
!= n
->type
)
1818 if (n
->prev
&& SEC_SEE_ALSO
== n
->sec
)
1819 print_otag(h
, TAG_P
, 0, NULL
);
1821 PAIR_CLASS_INIT(&tag
, "ref");
1822 print_otag(h
, TAG_SPAN
, 1, &tag
);
1830 mdoc_li_pre(MDOC_ARGS
)
1832 struct htmlpair tag
;
1834 PAIR_CLASS_INIT(&tag
, "lit");
1835 print_otag(h
, TAG_SPAN
, 1, &tag
);
1842 mdoc_sy_pre(MDOC_ARGS
)
1844 struct htmlpair tag
;
1846 PAIR_CLASS_INIT(&tag
, "symb");
1847 print_otag(h
, TAG_SPAN
, 1, &tag
);
1854 mdoc_bt_pre(MDOC_ARGS
)
1857 print_text(h
, "is currently in beta test.");
1864 mdoc_ud_pre(MDOC_ARGS
)
1867 print_text(h
, "currently under development.");
1874 mdoc_lb_pre(MDOC_ARGS
)
1876 struct htmlpair tag
;
1878 if (SEC_LIBRARY
== n
->sec
&& MDOC_LINE
& n
->flags
&& n
->prev
)
1879 print_otag(h
, TAG_BR
, 0, NULL
);
1881 PAIR_CLASS_INIT(&tag
, "lib");
1882 print_otag(h
, TAG_SPAN
, 1, &tag
);
1889 mdoc__x_pre(MDOC_ARGS
)
1891 struct htmlpair tag
[2];
1898 PAIR_CLASS_INIT(&tag
[0], "ref-auth");
1899 if (n
->prev
&& MDOC__A
== n
->prev
->tok
)
1900 if (NULL
== n
->next
|| MDOC__A
!= n
->next
->tok
)
1901 print_text(h
, "and");
1904 PAIR_CLASS_INIT(&tag
[0], "ref-book");
1908 PAIR_CLASS_INIT(&tag
[0], "ref-city");
1911 PAIR_CLASS_INIT(&tag
[0], "ref-date");
1914 PAIR_CLASS_INIT(&tag
[0], "ref-issue");
1918 PAIR_CLASS_INIT(&tag
[0], "ref-jrnl");
1922 PAIR_CLASS_INIT(&tag
[0], "ref-num");
1925 PAIR_CLASS_INIT(&tag
[0], "ref-opt");
1928 PAIR_CLASS_INIT(&tag
[0], "ref-page");
1931 PAIR_CLASS_INIT(&tag
[0], "ref-corp");
1934 PAIR_CLASS_INIT(&tag
[0], "ref-rep");
1937 PAIR_CLASS_INIT(&tag
[0], "ref-title");
1940 PAIR_CLASS_INIT(&tag
[0], "link-ref");
1943 PAIR_CLASS_INIT(&tag
[0], "ref-vol");
1950 if (MDOC__U
!= n
->tok
) {
1951 print_otag(h
, t
, 1, tag
);
1955 PAIR_HREF_INIT(&tag
[1], n
->child
->string
);
1956 print_otag(h
, TAG_A
, 2, tag
);
1964 mdoc__x_post(MDOC_ARGS
)
1967 if (MDOC__A
== n
->tok
&& n
->next
&& MDOC__A
== n
->next
->tok
)
1968 if (NULL
== n
->next
->next
|| MDOC__A
!= n
->next
->next
->tok
)
1969 if (NULL
== n
->prev
|| MDOC__A
!= n
->prev
->tok
)
1974 if (NULL
== n
->parent
|| MDOC_Rs
!= n
->parent
->tok
)
1977 print_text(h
, n
->next
? "," : ".");
1983 mdoc_bk_pre(MDOC_ARGS
)
1992 if (n
->parent
->args
|| 0 == n
->prev
->nchild
)
1993 h
->flags
|= HTML_PREKEEP
;
2006 mdoc_bk_post(MDOC_ARGS
)
2009 if (MDOC_BODY
== n
->type
)
2010 h
->flags
&= ~(HTML_KEEP
| HTML_PREKEEP
);
2016 mdoc_quote_pre(MDOC_ARGS
)
2018 struct htmlpair tag
;
2020 if (MDOC_BODY
!= n
->type
)
2027 print_text(h
, "\\(la");
2032 print_text(h
, "\\(lC");
2037 print_text(h
, "\\(lB");
2042 print_text(h
, "\\(lB");
2043 h
->flags
|= HTML_NOSPACE
;
2044 PAIR_CLASS_INIT(&tag
, "opt");
2045 print_otag(h
, TAG_SPAN
, 1, &tag
);
2054 print_text(h
, "\\(lq");
2066 print_text(h
, "\\(oq");
2073 h
->flags
|= HTML_NOSPACE
;
2080 mdoc_quote_post(MDOC_ARGS
)
2083 if (MDOC_BODY
!= n
->type
)
2086 h
->flags
|= HTML_NOSPACE
;
2092 print_text(h
, "\\(ra");
2097 print_text(h
, "\\(rC");
2106 print_text(h
, "\\(rB");
2115 print_text(h
, "\\(rq");
2127 print_text(h
, "\\(aq");