]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_html.c
1 /* $Id: mdoc_html.c,v 1.150 2011/02/02 21:40:45 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 /* No tables in this mode... */
424 assert(NULL
== h
->tblt
);
427 * Make sure that if we're in a literal mode already
428 * (i.e., within a <PRE>) don't print the newline.
430 if (' ' == *n
->string
&& MDOC_LINE
& n
->flags
)
431 if ( ! (HTML_LITERAL
& h
->flags
))
432 print_otag(h
, TAG_BR
, 0, NULL
);
433 print_text(h
, n
->string
);
437 * This will take care of initialising all of the table
438 * state data for the first table, then tearing it down
441 print_tbl(h
, n
->span
);
445 * Close out the current table, if it's open, and unset
446 * the "meta" table state. This will be reopened on the
447 * next table element.
454 assert(NULL
== h
->tblt
);
455 if (mdocs
[n
->tok
].pre
&& ENDBODY_NOT
== n
->end
)
456 child
= (*mdocs
[n
->tok
].pre
)(m
, n
, h
);
460 if (HTML_KEEP
& h
->flags
) {
461 if (n
->prev
&& n
->prev
->line
!= n
->line
) {
462 h
->flags
&= ~HTML_KEEP
;
463 h
->flags
|= HTML_PREKEEP
;
464 } else if (NULL
== n
->prev
) {
465 if (n
->parent
&& n
->parent
->line
!= n
->line
) {
466 h
->flags
&= ~HTML_KEEP
;
467 h
->flags
|= HTML_PREKEEP
;
472 if (child
&& n
->child
)
473 print_mdoc_nodelist(m
, n
->child
, h
);
480 mdoc_root_post(m
, n
, h
);
483 if (mdocs
[n
->tok
].post
&& ENDBODY_NOT
== n
->end
)
484 (*mdocs
[n
->tok
].post
)(m
, n
, h
);
491 mdoc_root_post(MDOC_ARGS
)
493 struct htmlpair tag
[3];
497 time2a(m
->date
, b
, DATESIZ
);
499 PAIR_SUMMARY_INIT(&tag
[0], "Document Footer");
500 PAIR_CLASS_INIT(&tag
[1], "foot");
501 if (NULL
== h
->style
) {
502 PAIR_INIT(&tag
[2], ATTR_WIDTH
, "100%");
503 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
504 PAIR_INIT(&tag
[0], ATTR_WIDTH
, "50%");
505 print_otag(h
, TAG_COL
, 1, tag
);
506 print_otag(h
, TAG_COL
, 1, tag
);
508 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
510 t
= print_otag(h
, TAG_TBODY
, 0, NULL
);
512 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
514 PAIR_CLASS_INIT(&tag
[0], "foot-date");
515 print_otag(h
, TAG_TD
, 1, tag
);
520 PAIR_CLASS_INIT(&tag
[0], "foot-os");
521 if (NULL
== h
->style
) {
522 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "right");
523 print_otag(h
, TAG_TD
, 2, tag
);
525 print_otag(h
, TAG_TD
, 1, tag
);
527 print_text(h
, m
->os
);
534 mdoc_root_pre(MDOC_ARGS
)
536 struct htmlpair tag
[3];
538 char b
[BUFSIZ
], title
[BUFSIZ
];
540 strlcpy(b
, m
->vol
, BUFSIZ
);
543 strlcat(b
, " (", BUFSIZ
);
544 strlcat(b
, m
->arch
, BUFSIZ
);
545 strlcat(b
, ")", BUFSIZ
);
548 snprintf(title
, BUFSIZ
- 1, "%s(%s)", m
->title
, m
->msec
);
550 PAIR_SUMMARY_INIT(&tag
[0], "Document Header");
551 PAIR_CLASS_INIT(&tag
[1], "head");
552 if (NULL
== h
->style
) {
553 PAIR_INIT(&tag
[2], ATTR_WIDTH
, "100%");
554 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
555 PAIR_INIT(&tag
[0], ATTR_WIDTH
, "30%");
556 print_otag(h
, TAG_COL
, 1, tag
);
557 print_otag(h
, TAG_COL
, 1, tag
);
558 print_otag(h
, TAG_COL
, 1, tag
);
560 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
562 print_otag(h
, TAG_TBODY
, 0, NULL
);
564 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
566 PAIR_CLASS_INIT(&tag
[0], "head-ltitle");
567 print_otag(h
, TAG_TD
, 1, tag
);
569 print_text(h
, title
);
572 PAIR_CLASS_INIT(&tag
[0], "head-vol");
573 if (NULL
== h
->style
) {
574 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "center");
575 print_otag(h
, TAG_TD
, 2, tag
);
577 print_otag(h
, TAG_TD
, 1, tag
);
582 PAIR_CLASS_INIT(&tag
[0], "head-rtitle");
583 if (NULL
== h
->style
) {
584 PAIR_INIT(&tag
[1], ATTR_ALIGN
, "right");
585 print_otag(h
, TAG_TD
, 2, tag
);
587 print_otag(h
, TAG_TD
, 1, tag
);
589 print_text(h
, title
);
597 mdoc_sh_pre(MDOC_ARGS
)
602 if (MDOC_BLOCK
== n
->type
) {
603 PAIR_CLASS_INIT(&tag
, "section");
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_H1
, 1, &tag
);
624 mdoc_ss_pre(MDOC_ARGS
)
629 if (MDOC_BLOCK
== n
->type
) {
630 PAIR_CLASS_INIT(&tag
, "subsection");
631 print_otag(h
, TAG_DIV
, 1, &tag
);
633 } else if (MDOC_BODY
== n
->type
)
637 for (n
= n
->child
; n
; n
= n
->next
) {
638 html_idcat(buf
, n
->string
, BUFSIZ
);
640 html_idcat(buf
, " ", BUFSIZ
);
643 PAIR_ID_INIT(&tag
, buf
);
644 print_otag(h
, TAG_H2
, 1, &tag
);
651 mdoc_fl_pre(MDOC_ARGS
)
655 PAIR_CLASS_INIT(&tag
, "flag");
656 print_otag(h
, TAG_B
, 1, &tag
);
658 /* `Cm' has no leading hyphen. */
660 if (MDOC_Cm
== n
->tok
)
663 print_text(h
, "\\-");
666 h
->flags
|= HTML_NOSPACE
;
667 else if (n
->next
&& n
->next
->line
== n
->line
)
668 h
->flags
|= HTML_NOSPACE
;
676 mdoc_nd_pre(MDOC_ARGS
)
680 if (MDOC_BODY
!= n
->type
)
683 /* XXX: this tag in theory can contain block elements. */
685 print_text(h
, "\\(em");
686 PAIR_CLASS_INIT(&tag
, "desc");
687 print_otag(h
, TAG_SPAN
, 1, &tag
);
693 mdoc_nm_pre(MDOC_ARGS
)
702 PAIR_CLASS_INIT(&tag
, "name");
703 print_otag(h
, TAG_B
, 1, &tag
);
704 if (NULL
== n
->child
&& m
->name
)
705 print_text(h
, m
->name
);
708 print_otag(h
, TAG_TD
, 0, NULL
);
709 if (NULL
== n
->child
&& m
->name
)
710 print_text(h
, m
->name
);
713 print_otag(h
, TAG_TD
, 0, NULL
);
720 PAIR_CLASS_INIT(&tag
, "synopsis");
721 print_otag(h
, TAG_TABLE
, 1, &tag
);
723 for (len
= 0, n
= n
->child
; n
; n
= n
->next
)
724 if (MDOC_TEXT
== n
->type
)
725 len
+= strlen(n
->string
);
727 if (0 == len
&& m
->name
)
728 len
= strlen(m
->name
);
730 SCALE_HS_INIT(&su
, (double)len
);
731 bufcat_su(h
, "width", &su
);
732 PAIR_STYLE_INIT(&tag
, h
);
733 print_otag(h
, TAG_COL
, 1, &tag
);
734 print_otag(h
, TAG_COL
, 0, NULL
);
735 print_otag(h
, TAG_TBODY
, 0, NULL
);
736 print_otag(h
, TAG_TR
, 0, NULL
);
743 mdoc_xr_pre(MDOC_ARGS
)
745 struct htmlpair tag
[2];
746 const struct mdoc_node
*nn
;
748 if (NULL
== n
->child
)
751 PAIR_CLASS_INIT(&tag
[0], "link-man");
754 buffmt_man(h
, n
->child
->string
,
756 n
->child
->next
->string
: NULL
);
757 PAIR_HREF_INIT(&tag
[1], h
->buf
);
758 print_otag(h
, TAG_A
, 2, tag
);
760 print_otag(h
, TAG_A
, 1, tag
);
763 print_text(h
, nn
->string
);
765 if (NULL
== (nn
= nn
->next
))
768 h
->flags
|= HTML_NOSPACE
;
770 h
->flags
|= HTML_NOSPACE
;
771 print_text(h
, nn
->string
);
772 h
->flags
|= HTML_NOSPACE
;
780 mdoc_ns_pre(MDOC_ARGS
)
783 if ( ! (MDOC_LINE
& n
->flags
))
784 h
->flags
|= HTML_NOSPACE
;
791 mdoc_ar_pre(MDOC_ARGS
)
795 PAIR_CLASS_INIT(&tag
, "arg");
796 print_otag(h
, TAG_I
, 1, &tag
);
803 mdoc_xx_pre(MDOC_ARGS
)
831 PAIR_CLASS_INIT(&tag
, "unix");
832 print_otag(h
, TAG_SPAN
, 1, &tag
);
836 h
->flags
|= HTML_KEEP
;
837 print_text(h
, n
->child
->string
);
838 h
->flags
&= ~HTML_KEEP
;
846 mdoc_bx_pre(MDOC_ARGS
)
850 PAIR_CLASS_INIT(&tag
, "unix");
851 print_otag(h
, TAG_SPAN
, 1, &tag
);
853 if (NULL
!= (n
= n
->child
)) {
854 print_text(h
, n
->string
);
855 h
->flags
|= HTML_NOSPACE
;
856 print_text(h
, "BSD");
858 print_text(h
, "BSD");
862 if (NULL
!= (n
= n
->next
)) {
863 h
->flags
|= HTML_NOSPACE
;
865 h
->flags
|= HTML_NOSPACE
;
866 print_text(h
, n
->string
);
874 mdoc_it_pre(MDOC_ARGS
)
878 struct htmlpair tag
[2];
879 const struct mdoc_node
*bl
;
882 while (bl
&& MDOC_Bl
!= bl
->tok
)
887 type
= bl
->norm
->Bl
.type
;
890 PAIR_CLASS_INIT(&tag
[0], lists
[type
]);
892 if (MDOC_HEAD
== n
->type
) {
913 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
914 bufcat_su(h
, "margin-top", &su
);
915 PAIR_STYLE_INIT(&tag
[1], h
);
916 print_otag(h
, TAG_DT
, 2, tag
);
917 if (LIST_diag
!= type
)
919 PAIR_CLASS_INIT(&tag
[0], "diag");
920 print_otag(h
, TAG_B
, 1, tag
);
927 } else if (MDOC_BODY
== n
->type
) {
938 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
939 bufcat_su(h
, "margin-top", &su
);
940 PAIR_STYLE_INIT(&tag
[1], h
);
941 print_otag(h
, TAG_LI
, 2, tag
);
952 if (NULL
== bl
->norm
->Bl
.width
) {
953 print_otag(h
, TAG_DD
, 1, tag
);
956 a2width(bl
->norm
->Bl
.width
, &su
);
957 bufcat_su(h
, "margin-left", &su
);
958 PAIR_STYLE_INIT(&tag
[1], h
);
959 print_otag(h
, TAG_DD
, 2, tag
);
962 SCALE_VS_INIT(&su
, ! bl
->norm
->Bl
.comp
);
963 bufcat_su(h
, "margin-top", &su
);
964 PAIR_STYLE_INIT(&tag
[1], h
);
965 print_otag(h
, TAG_TD
, 2, tag
);
973 print_otag(h
, TAG_TR
, 1, tag
);
985 mdoc_bl_pre(MDOC_ARGS
)
988 struct htmlpair tag
[3];
992 if (MDOC_BODY
== n
->type
) {
993 if (LIST_column
== n
->norm
->Bl
.type
)
994 print_otag(h
, TAG_TBODY
, 0, NULL
);
998 if (MDOC_HEAD
== n
->type
) {
999 if (LIST_column
!= n
->norm
->Bl
.type
)
1003 * For each column, print out the <COL> tag with our
1004 * suggested width. The last column gets min-width, as
1005 * in terminal mode it auto-sizes to the width of the
1006 * screen and we want to preserve that behaviour.
1009 for (i
= 0; i
< (int)n
->norm
->Bl
.ncols
; i
++) {
1010 a2width(n
->norm
->Bl
.cols
[i
], &su
);
1012 if (i
< (int)n
->norm
->Bl
.ncols
- 1)
1013 bufcat_su(h
, "width", &su
);
1015 bufcat_su(h
, "min-width", &su
);
1016 PAIR_STYLE_INIT(&tag
[0], h
);
1017 print_otag(h
, TAG_COL
, 1, tag
);
1023 SCALE_VS_INIT(&su
, 0);
1024 bufcat_su(h
, "margin-top", &su
);
1025 bufcat_su(h
, "margin-bottom", &su
);
1026 PAIR_STYLE_INIT(&tag
[0], h
);
1028 assert(lists
[n
->norm
->Bl
.type
]);
1029 strlcpy(buf
, "list ", BUFSIZ
);
1030 strlcat(buf
, lists
[n
->norm
->Bl
.type
], BUFSIZ
);
1031 PAIR_INIT(&tag
[1], ATTR_CLASS
, buf
);
1033 /* Set the block's left-hand margin. */
1035 if (n
->norm
->Bl
.offs
) {
1036 a2offs(n
->norm
->Bl
.offs
, &su
);
1037 bufcat_su(h
, "margin-left", &su
);
1040 switch (n
->norm
->Bl
.type
) {
1048 print_otag(h
, TAG_UL
, 2, tag
);
1051 print_otag(h
, TAG_OL
, 2, tag
);
1062 print_otag(h
, TAG_DL
, 2, tag
);
1065 print_otag(h
, TAG_TABLE
, 2, tag
);
1077 mdoc_ex_pre(MDOC_ARGS
)
1079 const struct mdoc_node
*nn
;
1081 struct htmlpair tag
;
1084 print_otag(h
, TAG_BR
, 0, NULL
);
1086 PAIR_CLASS_INIT(&tag
, "utility");
1088 print_text(h
, "The");
1089 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1090 t
= print_otag(h
, TAG_B
, 1, &tag
);
1091 print_text(h
, nn
->string
);
1094 h
->flags
|= HTML_NOSPACE
;
1096 if (nn
->next
&& NULL
== nn
->next
->next
)
1097 print_text(h
, ", and");
1101 h
->flags
&= ~HTML_NOSPACE
;
1104 if (n
->child
&& n
->child
->next
)
1105 print_text(h
, "utilities exit");
1107 print_text(h
, "utility exits");
1109 print_text(h
, "0 on success, and >0 if an error occurs.");
1116 mdoc_em_pre(MDOC_ARGS
)
1118 struct htmlpair tag
;
1120 PAIR_CLASS_INIT(&tag
, "emph");
1121 print_otag(h
, TAG_SPAN
, 1, &tag
);
1128 mdoc_d1_pre(MDOC_ARGS
)
1130 struct htmlpair tag
[2];
1133 if (MDOC_BLOCK
!= n
->type
)
1136 SCALE_VS_INIT(&su
, 0);
1137 bufcat_su(h
, "margin-top", &su
);
1138 bufcat_su(h
, "margin-bottom", &su
);
1139 PAIR_STYLE_INIT(&tag
[0], h
);
1140 print_otag(h
, TAG_BLOCKQUOTE
, 1, tag
);
1142 /* BLOCKQUOTE needs a block body. */
1144 PAIR_CLASS_INIT(&tag
[0], "display");
1145 print_otag(h
, TAG_DIV
, 1, tag
);
1147 if (MDOC_Dl
== n
->tok
) {
1148 PAIR_CLASS_INIT(&tag
[0], "lit");
1149 print_otag(h
, TAG_CODE
, 1, tag
);
1158 mdoc_sx_pre(MDOC_ARGS
)
1160 struct htmlpair tag
[2];
1161 const struct mdoc_node
*nn
;
1164 strlcpy(buf
, "#", BUFSIZ
);
1165 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1166 html_idcat(buf
, nn
->string
, BUFSIZ
);
1168 html_idcat(buf
, " ", BUFSIZ
);
1171 PAIR_CLASS_INIT(&tag
[0], "link-sec");
1172 PAIR_HREF_INIT(&tag
[1], buf
);
1174 print_otag(h
, TAG_I
, 1, tag
);
1175 print_otag(h
, TAG_A
, 2, tag
);
1182 mdoc_bd_pre(MDOC_ARGS
)
1184 struct htmlpair tag
[2];
1186 const struct mdoc_node
*nn
;
1189 if (MDOC_HEAD
== n
->type
)
1192 if (MDOC_BLOCK
== n
->type
) {
1193 comp
= n
->norm
->Bd
.comp
;
1194 for (nn
= n
; nn
&& ! comp
; nn
= nn
->parent
) {
1195 if (MDOC_BLOCK
!= nn
->type
)
1197 if (MDOC_Ss
== nn
->tok
|| MDOC_Sh
== nn
->tok
)
1203 print_otag(h
, TAG_P
, 0, NULL
);
1207 SCALE_HS_INIT(&su
, 0);
1208 if (n
->norm
->Bd
.offs
)
1209 a2offs(n
->norm
->Bd
.offs
, &su
);
1211 bufcat_su(h
, "margin-left", &su
);
1212 PAIR_STYLE_INIT(&tag
[0], h
);
1214 if (DISP_unfilled
!= n
->norm
->Bd
.type
&&
1215 DISP_literal
!= n
->norm
->Bd
.type
) {
1216 PAIR_CLASS_INIT(&tag
[1], "display");
1217 print_otag(h
, TAG_DIV
, 2, tag
);
1221 PAIR_CLASS_INIT(&tag
[1], "lit display");
1222 print_otag(h
, TAG_PRE
, 2, tag
);
1224 /* This can be recursive: save & set our literal state. */
1226 sv
= h
->flags
& HTML_LITERAL
;
1227 h
->flags
|= HTML_LITERAL
;
1229 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1230 print_mdoc_node(m
, nn
, h
);
1232 * If the printed node flushes its own line, then we
1233 * needn't do it here as well. This is hacky, but the
1234 * notion of selective eoln whitespace is pretty dumb
1235 * anyway, so don't sweat it.
1257 if (nn
->next
&& nn
->next
->line
== nn
->line
)
1260 print_text(h
, "\n");
1262 h
->flags
|= HTML_NOSPACE
;
1266 h
->flags
&= ~HTML_LITERAL
;
1274 mdoc_pa_pre(MDOC_ARGS
)
1276 struct htmlpair tag
;
1278 PAIR_CLASS_INIT(&tag
, "file");
1279 print_otag(h
, TAG_I
, 1, &tag
);
1286 mdoc_ad_pre(MDOC_ARGS
)
1288 struct htmlpair tag
;
1290 PAIR_CLASS_INIT(&tag
, "addr");
1291 print_otag(h
, TAG_I
, 1, &tag
);
1298 mdoc_an_pre(MDOC_ARGS
)
1300 struct htmlpair tag
;
1302 /* TODO: -split and -nosplit (see termp_an_pre()). */
1304 PAIR_CLASS_INIT(&tag
, "author");
1305 print_otag(h
, TAG_SPAN
, 1, &tag
);
1312 mdoc_cd_pre(MDOC_ARGS
)
1314 struct htmlpair tag
;
1317 PAIR_CLASS_INIT(&tag
, "config");
1318 print_otag(h
, TAG_B
, 1, &tag
);
1325 mdoc_dv_pre(MDOC_ARGS
)
1327 struct htmlpair tag
;
1329 PAIR_CLASS_INIT(&tag
, "define");
1330 print_otag(h
, TAG_SPAN
, 1, &tag
);
1337 mdoc_ev_pre(MDOC_ARGS
)
1339 struct htmlpair tag
;
1341 PAIR_CLASS_INIT(&tag
, "env");
1342 print_otag(h
, TAG_SPAN
, 1, &tag
);
1349 mdoc_er_pre(MDOC_ARGS
)
1351 struct htmlpair tag
;
1353 PAIR_CLASS_INIT(&tag
, "errno");
1354 print_otag(h
, TAG_SPAN
, 1, &tag
);
1361 mdoc_fa_pre(MDOC_ARGS
)
1363 const struct mdoc_node
*nn
;
1364 struct htmlpair tag
;
1367 PAIR_CLASS_INIT(&tag
, "farg");
1368 if (n
->parent
->tok
!= MDOC_Fo
) {
1369 print_otag(h
, TAG_I
, 1, &tag
);
1373 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1374 t
= print_otag(h
, TAG_I
, 1, &tag
);
1375 print_text(h
, nn
->string
);
1381 if (n
->child
&& n
->next
&& n
->next
->tok
== MDOC_Fa
)
1390 mdoc_fd_pre(MDOC_ARGS
)
1392 struct htmlpair tag
;
1396 PAIR_CLASS_INIT(&tag
, "macro");
1397 print_otag(h
, TAG_B
, 1, &tag
);
1404 mdoc_vt_pre(MDOC_ARGS
)
1406 struct htmlpair tag
;
1408 if (MDOC_BLOCK
== n
->type
) {
1411 } else if (MDOC_ELEM
== n
->type
) {
1413 } else if (MDOC_HEAD
== n
->type
)
1416 PAIR_CLASS_INIT(&tag
, "type");
1417 print_otag(h
, TAG_SPAN
, 1, &tag
);
1424 mdoc_ft_pre(MDOC_ARGS
)
1426 struct htmlpair tag
;
1429 PAIR_CLASS_INIT(&tag
, "ftype");
1430 print_otag(h
, TAG_I
, 1, &tag
);
1437 mdoc_fn_pre(MDOC_ARGS
)
1440 struct htmlpair tag
[2];
1441 const struct mdoc_node
*nn
;
1443 const char *sp
, *ep
;
1448 /* Split apart into type and name. */
1449 assert(n
->child
->string
);
1450 sp
= n
->child
->string
;
1452 ep
= strchr(sp
, ' ');
1454 PAIR_CLASS_INIT(&tag
[0], "ftype");
1455 t
= print_otag(h
, TAG_I
, 1, tag
);
1458 sz
= MIN((int)(ep
- sp
), BUFSIZ
- 1);
1459 (void)memcpy(nbuf
, sp
, (size_t)sz
);
1461 print_text(h
, nbuf
);
1463 ep
= strchr(sp
, ' ');
1468 PAIR_CLASS_INIT(&tag
[0], "fname");
1471 * FIXME: only refer to IDs that we know exist.
1475 if (MDOC_SYNPRETTY
& n
->flags
) {
1477 html_idcat(nbuf
, sp
, BUFSIZ
);
1478 PAIR_ID_INIT(&tag
[1], nbuf
);
1480 strlcpy(nbuf
, "#", BUFSIZ
);
1481 html_idcat(nbuf
, sp
, BUFSIZ
);
1482 PAIR_HREF_INIT(&tag
[1], nbuf
);
1486 t
= print_otag(h
, TAG_B
, 1, tag
);
1489 strlcpy(nbuf
, sp
, BUFSIZ
);
1490 print_text(h
, nbuf
);
1495 h
->flags
|= HTML_NOSPACE
;
1499 PAIR_CLASS_INIT(&tag
[0], "farg");
1500 bufcat_style(h
, "white-space", "nowrap");
1501 PAIR_STYLE_INIT(&tag
[1], h
);
1503 for (nn
= n
->child
->next
; nn
; nn
= nn
->next
) {
1505 if (MDOC_SYNPRETTY
& n
->flags
)
1507 t
= print_otag(h
, TAG_I
, i
, tag
);
1508 print_text(h
, nn
->string
);
1515 if (MDOC_SYNPRETTY
& n
->flags
)
1524 mdoc_sm_pre(MDOC_ARGS
)
1527 assert(n
->child
&& MDOC_TEXT
== n
->child
->type
);
1528 if (0 == strcmp("on", n
->child
->string
)) {
1530 * FIXME: no p->col to check. Thus, if we have
1537 * the "3" is preceded by a space.
1539 h
->flags
&= ~HTML_NOSPACE
;
1540 h
->flags
&= ~HTML_NONOSPACE
;
1542 h
->flags
|= HTML_NONOSPACE
;
1549 mdoc_pp_pre(MDOC_ARGS
)
1552 print_otag(h
, TAG_P
, 0, NULL
);
1559 mdoc_sp_pre(MDOC_ARGS
)
1562 struct htmlpair tag
;
1564 SCALE_VS_INIT(&su
, 1);
1566 if (MDOC_sp
== n
->tok
) {
1568 a2roffsu(n
->child
->string
, &su
, SCALE_VS
);
1572 bufcat_su(h
, "height", &su
);
1573 PAIR_STYLE_INIT(&tag
, h
);
1574 print_otag(h
, TAG_DIV
, 1, &tag
);
1576 /* So the div isn't empty: */
1577 print_text(h
, "\\~");
1585 mdoc_lk_pre(MDOC_ARGS
)
1587 const struct mdoc_node
*nn
;
1588 struct htmlpair tag
[2];
1592 PAIR_CLASS_INIT(&tag
[0], "link-ext");
1593 PAIR_HREF_INIT(&tag
[1], nn
->string
);
1594 print_otag(h
, TAG_A
, 2, tag
);
1596 if (NULL
== nn
|| NULL
== nn
->next
)
1599 for (nn
= nn
->next
; nn
; nn
= nn
->next
)
1600 print_text(h
, nn
->string
);
1608 mdoc_mt_pre(MDOC_ARGS
)
1610 struct htmlpair tag
[2];
1612 const struct mdoc_node
*nn
;
1614 PAIR_CLASS_INIT(&tag
[0], "link-mail");
1616 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1618 bufcat(h
, "mailto:");
1619 bufcat(h
, nn
->string
);
1620 PAIR_HREF_INIT(&tag
[1], h
->buf
);
1621 t
= print_otag(h
, TAG_A
, 2, tag
);
1622 print_text(h
, nn
->string
);
1632 mdoc_fo_pre(MDOC_ARGS
)
1634 struct htmlpair tag
;
1637 if (MDOC_BODY
== n
->type
) {
1638 h
->flags
|= HTML_NOSPACE
;
1640 h
->flags
|= HTML_NOSPACE
;
1642 } else if (MDOC_BLOCK
== n
->type
) {
1647 /* XXX: we drop non-initial arguments as per groff. */
1650 assert(n
->child
->string
);
1652 PAIR_CLASS_INIT(&tag
, "fname");
1653 t
= print_otag(h
, TAG_B
, 1, &tag
);
1654 print_text(h
, n
->child
->string
);
1662 mdoc_fo_post(MDOC_ARGS
)
1665 if (MDOC_BODY
!= n
->type
)
1674 mdoc_in_pre(MDOC_ARGS
)
1676 const struct mdoc_node
*nn
;
1678 struct htmlpair tag
[2];
1683 PAIR_CLASS_INIT(&tag
[0], "includes");
1684 print_otag(h
, TAG_B
, 1, tag
);
1686 if (MDOC_SYNPRETTY
& n
->flags
&& MDOC_LINE
& n
->flags
)
1687 print_text(h
, "#include");
1690 h
->flags
|= HTML_NOSPACE
;
1692 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1693 PAIR_CLASS_INIT(&tag
[0], "link-includes");
1696 if (h
->base_includes
) {
1697 buffmt_includes(h
, nn
->string
);
1698 PAIR_HREF_INIT(&tag
[i
], h
->buf
);
1701 t
= print_otag(h
, TAG_A
, i
, tag
);
1702 print_mdoc_node(m
, nn
, h
);
1706 h
->flags
|= HTML_NOSPACE
;
1715 mdoc_ic_pre(MDOC_ARGS
)
1717 struct htmlpair tag
;
1719 PAIR_CLASS_INIT(&tag
, "cmd");
1720 print_otag(h
, TAG_B
, 1, &tag
);
1727 mdoc_rv_pre(MDOC_ARGS
)
1729 const struct mdoc_node
*nn
;
1730 struct htmlpair tag
;
1734 print_otag(h
, TAG_BR
, 0, NULL
);
1736 print_text(h
, "The");
1738 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1739 PAIR_CLASS_INIT(&tag
, "fname");
1740 t
= print_otag(h
, TAG_B
, 1, &tag
);
1741 print_text(h
, nn
->string
);
1744 h
->flags
|= HTML_NOSPACE
;
1745 if (nn
->next
&& NULL
== nn
->next
->next
)
1746 print_text(h
, "(), and");
1748 print_text(h
, "(),");
1750 print_text(h
, "()");
1753 if (n
->child
&& n
->child
->next
)
1754 print_text(h
, "functions return");
1756 print_text(h
, "function returns");
1758 print_text(h
, "the value 0 if successful; otherwise the value "
1759 "-1 is returned and the global variable");
1761 PAIR_CLASS_INIT(&tag
, "var");
1762 t
= print_otag(h
, TAG_B
, 1, &tag
);
1763 print_text(h
, "errno");
1765 print_text(h
, "is set to indicate the error.");
1772 mdoc_va_pre(MDOC_ARGS
)
1774 struct htmlpair tag
;
1776 PAIR_CLASS_INIT(&tag
, "var");
1777 print_otag(h
, TAG_B
, 1, &tag
);
1784 mdoc_ap_pre(MDOC_ARGS
)
1787 h
->flags
|= HTML_NOSPACE
;
1788 print_text(h
, "\\(aq");
1789 h
->flags
|= HTML_NOSPACE
;
1796 mdoc_bf_pre(MDOC_ARGS
)
1798 struct htmlpair tag
[2];
1801 if (MDOC_HEAD
== n
->type
)
1803 else if (MDOC_BODY
!= n
->type
)
1806 if (FONT_Em
== n
->norm
->Bf
.font
)
1807 PAIR_CLASS_INIT(&tag
[0], "emph");
1808 else if (FONT_Sy
== n
->norm
->Bf
.font
)
1809 PAIR_CLASS_INIT(&tag
[0], "symb");
1810 else if (FONT_Li
== n
->norm
->Bf
.font
)
1811 PAIR_CLASS_INIT(&tag
[0], "lit");
1813 PAIR_CLASS_INIT(&tag
[0], "none");
1816 * We want this to be inline-formatted, but needs to be div to
1817 * accept block children.
1819 bufcat_style(h
, "display", "inline");
1820 SCALE_HS_INIT(&su
, 1);
1821 /* Needs a left-margin for spacing. */
1822 bufcat_su(h
, "margin-left", &su
);
1823 PAIR_STYLE_INIT(&tag
[1], h
);
1824 print_otag(h
, TAG_DIV
, 2, tag
);
1831 mdoc_ms_pre(MDOC_ARGS
)
1833 struct htmlpair tag
;
1835 PAIR_CLASS_INIT(&tag
, "symb");
1836 print_otag(h
, TAG_SPAN
, 1, &tag
);
1843 mdoc_igndelim_pre(MDOC_ARGS
)
1846 h
->flags
|= HTML_IGNDELIM
;
1853 mdoc_pf_post(MDOC_ARGS
)
1856 h
->flags
|= HTML_NOSPACE
;
1862 mdoc_rs_pre(MDOC_ARGS
)
1864 struct htmlpair tag
;
1866 if (MDOC_BLOCK
!= n
->type
)
1869 if (n
->prev
&& SEC_SEE_ALSO
== n
->sec
)
1870 print_otag(h
, TAG_P
, 0, NULL
);
1872 PAIR_CLASS_INIT(&tag
, "ref");
1873 print_otag(h
, TAG_SPAN
, 1, &tag
);
1881 mdoc_li_pre(MDOC_ARGS
)
1883 struct htmlpair tag
;
1885 PAIR_CLASS_INIT(&tag
, "lit");
1886 print_otag(h
, TAG_SPAN
, 1, &tag
);
1893 mdoc_sy_pre(MDOC_ARGS
)
1895 struct htmlpair tag
;
1897 PAIR_CLASS_INIT(&tag
, "symb");
1898 print_otag(h
, TAG_SPAN
, 1, &tag
);
1905 mdoc_bt_pre(MDOC_ARGS
)
1908 print_text(h
, "is currently in beta test.");
1915 mdoc_ud_pre(MDOC_ARGS
)
1918 print_text(h
, "currently under development.");
1925 mdoc_lb_pre(MDOC_ARGS
)
1927 struct htmlpair tag
;
1929 if (SEC_LIBRARY
== n
->sec
&& MDOC_LINE
& n
->flags
&& n
->prev
)
1930 print_otag(h
, TAG_BR
, 0, NULL
);
1932 PAIR_CLASS_INIT(&tag
, "lib");
1933 print_otag(h
, TAG_SPAN
, 1, &tag
);
1940 mdoc__x_pre(MDOC_ARGS
)
1942 struct htmlpair tag
[2];
1949 PAIR_CLASS_INIT(&tag
[0], "ref-auth");
1950 if (n
->prev
&& MDOC__A
== n
->prev
->tok
)
1951 if (NULL
== n
->next
|| MDOC__A
!= n
->next
->tok
)
1952 print_text(h
, "and");
1955 PAIR_CLASS_INIT(&tag
[0], "ref-book");
1959 PAIR_CLASS_INIT(&tag
[0], "ref-city");
1962 PAIR_CLASS_INIT(&tag
[0], "ref-date");
1965 PAIR_CLASS_INIT(&tag
[0], "ref-issue");
1969 PAIR_CLASS_INIT(&tag
[0], "ref-jrnl");
1973 PAIR_CLASS_INIT(&tag
[0], "ref-num");
1976 PAIR_CLASS_INIT(&tag
[0], "ref-opt");
1979 PAIR_CLASS_INIT(&tag
[0], "ref-page");
1982 PAIR_CLASS_INIT(&tag
[0], "ref-corp");
1985 PAIR_CLASS_INIT(&tag
[0], "ref-rep");
1988 PAIR_CLASS_INIT(&tag
[0], "ref-title");
1991 PAIR_CLASS_INIT(&tag
[0], "link-ref");
1994 PAIR_CLASS_INIT(&tag
[0], "ref-vol");
2001 if (MDOC__U
!= n
->tok
) {
2002 print_otag(h
, t
, 1, tag
);
2006 PAIR_HREF_INIT(&tag
[1], n
->child
->string
);
2007 print_otag(h
, TAG_A
, 2, tag
);
2015 mdoc__x_post(MDOC_ARGS
)
2018 if (MDOC__A
== n
->tok
&& n
->next
&& MDOC__A
== n
->next
->tok
)
2019 if (NULL
== n
->next
->next
|| MDOC__A
!= n
->next
->next
->tok
)
2020 if (NULL
== n
->prev
|| MDOC__A
!= n
->prev
->tok
)
2025 if (NULL
== n
->parent
|| MDOC_Rs
!= n
->parent
->tok
)
2028 print_text(h
, n
->next
? "," : ".");
2034 mdoc_bk_pre(MDOC_ARGS
)
2043 if (n
->parent
->args
|| 0 == n
->prev
->nchild
)
2044 h
->flags
|= HTML_PREKEEP
;
2057 mdoc_bk_post(MDOC_ARGS
)
2060 if (MDOC_BODY
== n
->type
)
2061 h
->flags
&= ~(HTML_KEEP
| HTML_PREKEEP
);
2067 mdoc_quote_pre(MDOC_ARGS
)
2069 struct htmlpair tag
;
2071 if (MDOC_BODY
!= n
->type
)
2078 print_text(h
, "\\(la");
2083 print_text(h
, "\\(lC");
2088 print_text(h
, "\\(lB");
2093 print_text(h
, "\\(lB");
2094 h
->flags
|= HTML_NOSPACE
;
2095 PAIR_CLASS_INIT(&tag
, "opt");
2096 print_otag(h
, TAG_SPAN
, 1, &tag
);
2105 print_text(h
, "\\(lq");
2117 print_text(h
, "\\(oq");
2124 h
->flags
|= HTML_NOSPACE
;
2131 mdoc_quote_post(MDOC_ARGS
)
2134 if (MDOC_BODY
!= n
->type
)
2137 h
->flags
|= HTML_NOSPACE
;
2143 print_text(h
, "\\(ra");
2148 print_text(h
, "\\(rC");
2157 print_text(h
, "\\(rB");
2166 print_text(h
, "\\(rq");
2178 print_text(h
, "\\(aq");