1 /* $Id: mdoc_html.c,v 1.48 2009/11/16 08:46:59 kristaps Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
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.
17 #include <sys/types.h>
18 #include <sys/param.h>
35 #define MDOC_ARGS const struct mdoc_meta *m, \
36 const struct mdoc_node *n, \
40 int (*pre)(MDOC_ARGS);
41 void (*post)(MDOC_ARGS);
44 static void print_mdoc(MDOC_ARGS);
45 static void print_mdoc_head(MDOC_ARGS);
46 static void print_mdoc_node(MDOC_ARGS);
47 static void print_mdoc_nodelist(MDOC_ARGS);
49 static void a2width(const char *, struct roffsu *);
50 static void a2offs(const char *, struct roffsu *);
52 static int a2list(const struct mdoc_node *);
54 static void mdoc_root_post(MDOC_ARGS);
55 static int mdoc_root_pre(MDOC_ARGS);
57 static void mdoc__x_post(MDOC_ARGS);
58 static int mdoc__x_pre(MDOC_ARGS);
59 static int mdoc_ad_pre(MDOC_ARGS);
60 static int mdoc_an_pre(MDOC_ARGS);
61 static int mdoc_ap_pre(MDOC_ARGS);
62 static void mdoc_aq_post(MDOC_ARGS);
63 static int mdoc_aq_pre(MDOC_ARGS);
64 static int mdoc_ar_pre(MDOC_ARGS);
65 static int mdoc_bd_pre(MDOC_ARGS);
66 static int mdoc_bf_pre(MDOC_ARGS);
67 static void mdoc_bl_post(MDOC_ARGS);
68 static int mdoc_bl_pre(MDOC_ARGS);
69 static void mdoc_bq_post(MDOC_ARGS);
70 static int mdoc_bq_pre(MDOC_ARGS);
71 static void mdoc_brq_post(MDOC_ARGS);
72 static int mdoc_brq_pre(MDOC_ARGS);
73 static int mdoc_bt_pre(MDOC_ARGS);
74 static int mdoc_bx_pre(MDOC_ARGS);
75 static int mdoc_cd_pre(MDOC_ARGS);
76 static int mdoc_d1_pre(MDOC_ARGS);
77 static void mdoc_dq_post(MDOC_ARGS);
78 static int mdoc_dq_pre(MDOC_ARGS);
79 static int mdoc_dv_pre(MDOC_ARGS);
80 static int mdoc_fa_pre(MDOC_ARGS);
81 static int mdoc_fd_pre(MDOC_ARGS);
82 static int mdoc_fl_pre(MDOC_ARGS);
83 static int mdoc_fn_pre(MDOC_ARGS);
84 static int mdoc_ft_pre(MDOC_ARGS);
85 static int mdoc_em_pre(MDOC_ARGS);
86 static int mdoc_er_pre(MDOC_ARGS);
87 static int mdoc_ev_pre(MDOC_ARGS);
88 static int mdoc_ex_pre(MDOC_ARGS);
89 static void mdoc_fo_post(MDOC_ARGS);
90 static int mdoc_fo_pre(MDOC_ARGS);
91 static int mdoc_ic_pre(MDOC_ARGS);
92 static int mdoc_in_pre(MDOC_ARGS);
93 static int mdoc_it_block_pre(MDOC_ARGS, int, int,
94 struct roffsu *, struct roffsu *);
95 static int mdoc_it_head_pre(MDOC_ARGS, int,
97 static int mdoc_it_body_pre(MDOC_ARGS, int);
98 static int mdoc_it_pre(MDOC_ARGS);
99 static int mdoc_lb_pre(MDOC_ARGS);
100 static int mdoc_li_pre(MDOC_ARGS);
101 static int mdoc_lk_pre(MDOC_ARGS);
102 static int mdoc_mt_pre(MDOC_ARGS);
103 static int mdoc_ms_pre(MDOC_ARGS);
104 static int mdoc_nd_pre(MDOC_ARGS);
105 static int mdoc_nm_pre(MDOC_ARGS);
106 static int mdoc_ns_pre(MDOC_ARGS);
107 static void mdoc_op_post(MDOC_ARGS);
108 static int mdoc_op_pre(MDOC_ARGS);
109 static int mdoc_pa_pre(MDOC_ARGS);
110 static void mdoc_pf_post(MDOC_ARGS);
111 static int mdoc_pf_pre(MDOC_ARGS);
112 static void mdoc_pq_post(MDOC_ARGS);
113 static int mdoc_pq_pre(MDOC_ARGS);
114 static int mdoc_rs_pre(MDOC_ARGS);
115 static int mdoc_rv_pre(MDOC_ARGS);
116 static int mdoc_sh_pre(MDOC_ARGS);
117 static int mdoc_sp_pre(MDOC_ARGS);
118 static void mdoc_sq_post(MDOC_ARGS);
119 static int mdoc_sq_pre(MDOC_ARGS);
120 static int mdoc_ss_pre(MDOC_ARGS);
121 static int mdoc_sx_pre(MDOC_ARGS);
122 static int mdoc_sy_pre(MDOC_ARGS);
123 static int mdoc_ud_pre(MDOC_ARGS);
124 static int mdoc_va_pre(MDOC_ARGS);
125 static int mdoc_vt_pre(MDOC_ARGS);
126 static int mdoc_xr_pre(MDOC_ARGS);
127 static int mdoc_xx_pre(MDOC_ARGS);
130 extern size_t strlcpy(char *, const char *, size_t);
131 extern size_t strlcat(char *, const char *, size_t);
134 static const struct htmlmdoc mdocs[MDOC_MAX] = {
135 {mdoc_ap_pre, NULL}, /* Ap */
136 {NULL, NULL}, /* Dd */
137 {NULL, NULL}, /* Dt */
138 {NULL, NULL}, /* Os */
139 {mdoc_sh_pre, NULL }, /* Sh */
140 {mdoc_ss_pre, NULL }, /* Ss */
141 {mdoc_sp_pre, NULL}, /* Pp */
142 {mdoc_d1_pre, NULL}, /* D1 */
143 {mdoc_d1_pre, NULL}, /* Dl */
144 {mdoc_bd_pre, NULL}, /* Bd */
145 {NULL, NULL}, /* Ed */
146 {mdoc_bl_pre, mdoc_bl_post}, /* Bl */
147 {NULL, NULL}, /* El */
148 {mdoc_it_pre, NULL}, /* It */
149 {mdoc_ad_pre, NULL}, /* Ad */
150 {mdoc_an_pre, NULL}, /* An */
151 {mdoc_ar_pre, NULL}, /* Ar */
152 {mdoc_cd_pre, NULL}, /* Cd */
153 {mdoc_fl_pre, NULL}, /* Cm */
154 {mdoc_dv_pre, NULL}, /* Dv */
155 {mdoc_er_pre, NULL}, /* Er */
156 {mdoc_ev_pre, NULL}, /* Ev */
157 {mdoc_ex_pre, NULL}, /* Ex */
158 {mdoc_fa_pre, NULL}, /* Fa */
159 {mdoc_fd_pre, NULL}, /* Fd */
160 {mdoc_fl_pre, NULL}, /* Fl */
161 {mdoc_fn_pre, NULL}, /* Fn */
162 {mdoc_ft_pre, NULL}, /* Ft */
163 {mdoc_ic_pre, NULL}, /* Ic */
164 {mdoc_in_pre, NULL}, /* In */
165 {mdoc_li_pre, NULL}, /* Li */
166 {mdoc_nd_pre, NULL}, /* Nd */
167 {mdoc_nm_pre, NULL}, /* Nm */
168 {mdoc_op_pre, mdoc_op_post}, /* Op */
169 {NULL, NULL}, /* Ot */
170 {mdoc_pa_pre, NULL}, /* Pa */
171 {mdoc_rv_pre, NULL}, /* Rv */
172 {NULL, NULL}, /* St */
173 {mdoc_va_pre, NULL}, /* Va */
174 {mdoc_vt_pre, NULL}, /* Vt */
175 {mdoc_xr_pre, NULL}, /* Xr */
176 {mdoc__x_pre, mdoc__x_post}, /* %A */
177 {mdoc__x_pre, mdoc__x_post}, /* %B */
178 {mdoc__x_pre, mdoc__x_post}, /* %D */
179 {mdoc__x_pre, mdoc__x_post}, /* %I */
180 {mdoc__x_pre, mdoc__x_post}, /* %J */
181 {mdoc__x_pre, mdoc__x_post}, /* %N */
182 {mdoc__x_pre, mdoc__x_post}, /* %O */
183 {mdoc__x_pre, mdoc__x_post}, /* %P */
184 {mdoc__x_pre, mdoc__x_post}, /* %R */
185 {mdoc__x_pre, mdoc__x_post}, /* %T */
186 {mdoc__x_pre, mdoc__x_post}, /* %V */
187 {NULL, NULL}, /* Ac */
188 {mdoc_aq_pre, mdoc_aq_post}, /* Ao */
189 {mdoc_aq_pre, mdoc_aq_post}, /* Aq */
190 {NULL, NULL}, /* At */
191 {NULL, NULL}, /* Bc */
192 {mdoc_bf_pre, NULL}, /* Bf */
193 {mdoc_bq_pre, mdoc_bq_post}, /* Bo */
194 {mdoc_bq_pre, mdoc_bq_post}, /* Bq */
195 {mdoc_xx_pre, NULL}, /* Bsx */
196 {mdoc_bx_pre, NULL}, /* Bx */
197 {NULL, NULL}, /* Db */
198 {NULL, NULL}, /* Dc */
199 {mdoc_dq_pre, mdoc_dq_post}, /* Do */
200 {mdoc_dq_pre, mdoc_dq_post}, /* Dq */
201 {NULL, NULL}, /* Ec */
202 {NULL, NULL}, /* Ef */
203 {mdoc_em_pre, NULL}, /* Em */
204 {NULL, NULL}, /* Eo */
205 {mdoc_xx_pre, NULL}, /* Fx */
206 {mdoc_ms_pre, NULL}, /* Ms */ /* FIXME: convert to symbol? */
207 {NULL, NULL}, /* No */
208 {mdoc_ns_pre, NULL}, /* Ns */
209 {mdoc_xx_pre, NULL}, /* Nx */
210 {mdoc_xx_pre, NULL}, /* Ox */
211 {NULL, NULL}, /* Pc */
212 {mdoc_pf_pre, mdoc_pf_post}, /* Pf */
213 {mdoc_pq_pre, mdoc_pq_post}, /* Po */
214 {mdoc_pq_pre, mdoc_pq_post}, /* Pq */
215 {NULL, NULL}, /* Qc */
216 {mdoc_sq_pre, mdoc_sq_post}, /* Ql */
217 {mdoc_dq_pre, mdoc_dq_post}, /* Qo */
218 {mdoc_dq_pre, mdoc_dq_post}, /* Qq */
219 {NULL, NULL}, /* Re */
220 {mdoc_rs_pre, NULL}, /* Rs */
221 {NULL, NULL}, /* Sc */
222 {mdoc_sq_pre, mdoc_sq_post}, /* So */
223 {mdoc_sq_pre, mdoc_sq_post}, /* Sq */
224 {NULL, NULL}, /* Sm */ /* FIXME - no idea. */
225 {mdoc_sx_pre, NULL}, /* Sx */
226 {mdoc_sy_pre, NULL}, /* Sy */
227 {NULL, NULL}, /* Tn */
228 {mdoc_xx_pre, NULL}, /* Ux */
229 {NULL, NULL}, /* Xc */
230 {NULL, NULL}, /* Xo */
231 {mdoc_fo_pre, mdoc_fo_post}, /* Fo */
232 {NULL, NULL}, /* Fc */
233 {mdoc_op_pre, mdoc_op_post}, /* Oo */
234 {NULL, NULL}, /* Oc */
235 {NULL, NULL}, /* Bk */
236 {NULL, NULL}, /* Ek */
237 {mdoc_bt_pre, NULL}, /* Bt */
238 {NULL, NULL}, /* Hf */
239 {NULL, NULL}, /* Fr */
240 {mdoc_ud_pre, NULL}, /* Ud */
241 {mdoc_lb_pre, NULL}, /* Lb */
242 {mdoc_sp_pre, NULL}, /* Lp */
243 {mdoc_lk_pre, NULL}, /* Lk */
244 {mdoc_mt_pre, NULL}, /* Mt */
245 {mdoc_brq_pre, mdoc_brq_post}, /* Brq */
246 {mdoc_brq_pre, mdoc_brq_post}, /* Bro */
247 {NULL, NULL}, /* Brc */
248 {mdoc__x_pre, mdoc__x_post}, /* %C */
249 {NULL, NULL}, /* Es */ /* TODO */
250 {NULL, NULL}, /* En */ /* TODO */
251 {mdoc_xx_pre, NULL}, /* Dx */
252 {mdoc__x_pre, mdoc__x_post}, /* %Q */
253 {mdoc_sp_pre, NULL}, /* br */
254 {mdoc_sp_pre, NULL}, /* sp */
255 {mdoc__x_pre, mdoc__x_post}, /* %U */
260 html_mdoc(void *arg, const struct mdoc *m)
265 h = (struct html *)arg;
267 print_gen_doctype(h);
268 t = print_otag(h, TAG_HTML, 0, NULL);
269 print_mdoc(mdoc_meta(m), mdoc_node(m), h);
277 * Return the list type for `Bl', e.g., `Bl -column' returns
278 * MDOC_Column. This can ONLY be run for lists; it will abort() if no
279 * list type is found.
282 a2list(const struct mdoc_node *n)
287 for (i = 0; i < (int)n->args->argc; i++)
288 switch (n->args->argv[i].arg) {
310 return(n->args->argv[i].arg);
321 * Calculate the scaling unit passed in a `-width' argument. This uses
322 * either a native scaling unit (e.g., 1i, 2m) or the string length of
326 a2width(const char *p, struct roffsu *su)
329 if ( ! a2roffsu(p, su, SCALE_MAX)) {
331 su->scale = (int)strlen(p);
337 * Calculate the scaling unit passed in an `-offset' argument. This
338 * uses either a native scaling unit (e.g., 1i, 2m), one of a set of
339 * predefined strings (indent, etc.), or the string length of the value.
342 a2offs(const char *p, struct roffsu *su)
345 /* FIXME: "right"? */
347 if (0 == strcmp(p, "left"))
348 SCALE_HS_INIT(su, 0);
349 else if (0 == strcmp(p, "indent"))
350 SCALE_HS_INIT(su, INDENT);
351 else if (0 == strcmp(p, "indent-two"))
352 SCALE_HS_INIT(su, INDENT * 2);
353 else if ( ! a2roffsu(p, su, SCALE_MAX)) {
355 su->scale = (int)strlen(p);
361 print_mdoc(MDOC_ARGS)
366 t = print_otag(h, TAG_HEAD, 0, NULL);
367 print_mdoc_head(m, n, h);
370 t = print_otag(h, TAG_BODY, 0, NULL);
372 tag.key = ATTR_CLASS;
374 print_otag(h, TAG_DIV, 1, &tag);
376 print_mdoc_nodelist(m, n, h);
383 print_mdoc_head(MDOC_ARGS)
388 buffmt(h, "%s(%d)", m->title, m->msec);
396 print_otag(h, TAG_TITLE, 0, NULL);
397 print_text(h, h->buf);
402 print_mdoc_nodelist(MDOC_ARGS)
405 print_mdoc_node(m, n, h);
407 print_mdoc_nodelist(m, n->next, h);
412 print_mdoc_node(MDOC_ARGS)
423 child = mdoc_root_pre(m, n, h);
426 print_text(h, n->string);
429 if (mdocs[n->tok].pre)
430 child = (*mdocs[n->tok].pre)(m, n, h);
434 if (child && n->child)
435 print_mdoc_nodelist(m, n->child, h);
442 mdoc_root_post(m, n, h);
445 if (mdocs[n->tok].post)
446 (*mdocs[n->tok].post)(m, n, h);
454 mdoc_root_post(MDOC_ARGS)
456 struct htmlpair tag[3];
460 time2a(m->date, b, DATESIZ);
463 * XXX: this should use divs, but in Firefox, divs with nested
464 * divs for some reason puke when trying to put a border line
465 * below. So I use tables, instead.
468 PAIR_CLASS_INIT(&tag[0], "footer");
469 bufcat_style(h, "width", "100%");
470 PAIR_STYLE_INIT(&tag[1], h);
471 PAIR_SUMMARY_INIT(&tag[2], "footer");
473 t = print_otag(h, TAG_TABLE, 3, tag);
474 tt = print_otag(h, TAG_TR, 0, NULL);
477 bufcat_style(h, "width", "50%");
478 PAIR_STYLE_INIT(&tag[0], h);
479 print_otag(h, TAG_TD, 1, tag);
484 bufcat_style(h, "width", "50%");
485 bufcat_style(h, "text-align", "right");
486 PAIR_STYLE_INIT(&tag[0], h);
487 print_otag(h, TAG_TD, 1, tag);
488 print_text(h, m->os);
495 mdoc_root_pre(MDOC_ARGS)
497 struct htmlpair tag[3];
499 char b[BUFSIZ], title[BUFSIZ];
501 (void)strlcpy(b, m->vol, BUFSIZ);
504 (void)strlcat(b, " (", BUFSIZ);
505 (void)strlcat(b, m->arch, BUFSIZ);
506 (void)strlcat(b, ")", BUFSIZ);
509 (void)snprintf(title, BUFSIZ - 1,
510 "%s(%d)", m->title, m->msec);
512 /* XXX: see note in mdoc_root_post() about divs. */
514 PAIR_CLASS_INIT(&tag[0], "header");
515 bufcat_style(h, "width", "100%");
516 PAIR_STYLE_INIT(&tag[1], h);
517 PAIR_SUMMARY_INIT(&tag[2], "header");
519 t = print_otag(h, TAG_TABLE, 3, tag);
521 tt = print_otag(h, TAG_TR, 0, NULL);
524 bufcat_style(h, "width", "10%");
525 PAIR_STYLE_INIT(&tag[0], h);
526 print_otag(h, TAG_TD, 1, tag);
527 print_text(h, title);
531 bufcat_style(h, "text-align", "center");
532 bufcat_style(h, "white-space", "nowrap");
533 bufcat_style(h, "width", "80%");
534 PAIR_STYLE_INIT(&tag[0], h);
535 print_otag(h, TAG_TD, 1, tag);
540 bufcat_style(h, "text-align", "right");
541 bufcat_style(h, "width", "10%");
542 PAIR_STYLE_INIT(&tag[0], h);
543 print_otag(h, TAG_TD, 1, tag);
544 print_text(h, title);
552 mdoc_sh_pre(MDOC_ARGS)
554 struct htmlpair tag[2];
555 const struct mdoc_node *nn;
559 if (MDOC_BODY == n->type) {
560 SCALE_HS_INIT(&su, INDENT);
561 bufcat_su(h, "margin-left", &su);
562 PAIR_CLASS_INIT(&tag[0], "sec-body");
563 PAIR_STYLE_INIT(&tag[1], h);
564 print_otag(h, TAG_DIV, 2, tag);
566 } else if (MDOC_BLOCK == n->type) {
567 PAIR_CLASS_INIT(&tag[0], "sec-block");
568 if (n->prev && NULL == n->prev->body->child) {
569 print_otag(h, TAG_DIV, 1, tag);
573 SCALE_VS_INIT(&su, 1);
574 bufcat_su(h, "margin-top", &su);
576 bufcat_su(h, "margin-bottom", &su);
578 PAIR_STYLE_INIT(&tag[1], h);
579 print_otag(h, TAG_DIV, 2, tag);
584 for (nn = n->child; nn; nn = nn->next) {
585 html_idcat(buf, nn->string, BUFSIZ);
587 html_idcat(buf, " ", BUFSIZ);
591 * TODO: make sure there are no duplicates, as HTML does not
592 * allow for multiple `id' tags of the same name.
595 PAIR_CLASS_INIT(&tag[0], "sec-head");
596 tag[1].key = ATTR_ID;
598 print_otag(h, TAG_DIV, 2, tag);
605 mdoc_ss_pre(MDOC_ARGS)
607 struct htmlpair tag[3];
608 const struct mdoc_node *nn;
612 SCALE_VS_INIT(&su, 1);
614 if (MDOC_BODY == n->type) {
615 PAIR_CLASS_INIT(&tag[0], "ssec-body");
616 if (n->parent->next && n->child) {
617 bufcat_su(h, "margin-bottom", &su);
618 PAIR_STYLE_INIT(&tag[1], h);
619 print_otag(h, TAG_DIV, 2, tag);
621 print_otag(h, TAG_DIV, 1, tag);
623 } else if (MDOC_BLOCK == n->type) {
624 PAIR_CLASS_INIT(&tag[0], "ssec-block");
626 bufcat_su(h, "margin-top", &su);
627 PAIR_STYLE_INIT(&tag[1], h);
628 print_otag(h, TAG_DIV, 2, tag);
630 print_otag(h, TAG_DIV, 1, tag);
634 /* TODO: see note in mdoc_sh_pre() about duplicates. */
637 for (nn = n->child; nn; nn = nn->next) {
638 html_idcat(buf, nn->string, BUFSIZ);
640 html_idcat(buf, " ", BUFSIZ);
643 SCALE_HS_INIT(&su, INDENT - HALFINDENT);
644 su.scale = -su.scale;
645 bufcat_su(h, "margin-left", &su);
647 PAIR_CLASS_INIT(&tag[0], "ssec-head");
648 PAIR_STYLE_INIT(&tag[1], h);
649 tag[2].key = ATTR_ID;
651 print_otag(h, TAG_DIV, 3, tag);
658 mdoc_fl_pre(MDOC_ARGS)
662 PAIR_CLASS_INIT(&tag, "flag");
663 print_otag(h, TAG_SPAN, 1, &tag);
664 if (MDOC_Fl == n->tok) {
665 print_text(h, "\\-");
666 h->flags |= HTML_NOSPACE;
674 mdoc_nd_pre(MDOC_ARGS)
678 if (MDOC_BODY != n->type)
681 /* XXX: this tag in theory can contain block elements. */
683 print_text(h, "\\(em");
684 PAIR_CLASS_INIT(&tag, "desc-body");
685 print_otag(h, TAG_SPAN, 1, &tag);
692 mdoc_op_pre(MDOC_ARGS)
696 if (MDOC_BODY != n->type)
699 /* XXX: this tag in theory can contain block elements. */
701 print_text(h, "\\(lB");
702 h->flags |= HTML_NOSPACE;
703 PAIR_CLASS_INIT(&tag, "opt");
704 print_otag(h, TAG_SPAN, 1, &tag);
711 mdoc_op_post(MDOC_ARGS)
714 if (MDOC_BODY != n->type)
716 h->flags |= HTML_NOSPACE;
717 print_text(h, "\\(rB");
722 mdoc_nm_pre(MDOC_ARGS)
726 if (SEC_SYNOPSIS == n->sec && n->prev) {
727 bufcat_style(h, "clear", "both");
728 PAIR_STYLE_INIT(&tag, h);
729 print_otag(h, TAG_BR, 1, &tag);
732 PAIR_CLASS_INIT(&tag, "name");
733 print_otag(h, TAG_SPAN, 1, &tag);
734 if (NULL == n->child)
735 print_text(h, m->name);
743 mdoc_xr_pre(MDOC_ARGS)
745 struct htmlpair tag[2];
746 const struct mdoc_node *nn;
748 PAIR_CLASS_INIT(&tag[0], "link-man");
751 buffmt_man(h, n->child->string,
753 n->child->next->string : NULL);
754 tag[1].key = ATTR_HREF;
756 print_otag(h, TAG_A, 2, tag);
758 print_otag(h, TAG_A, 1, tag);
761 print_text(h, nn->string);
763 if (NULL == (nn = nn->next))
766 h->flags |= HTML_NOSPACE;
768 h->flags |= HTML_NOSPACE;
769 print_text(h, nn->string);
770 h->flags |= HTML_NOSPACE;
778 mdoc_ns_pre(MDOC_ARGS)
781 h->flags |= HTML_NOSPACE;
788 mdoc_ar_pre(MDOC_ARGS)
792 PAIR_CLASS_INIT(&tag, "arg");
793 print_otag(h, TAG_SPAN, 1, &tag);
800 mdoc_xx_pre(MDOC_ARGS)
828 PAIR_CLASS_INIT(&tag, "unix");
829 print_otag(h, TAG_SPAN, 1, &tag);
837 mdoc_bx_pre(MDOC_ARGS)
839 const struct mdoc_node *nn;
842 PAIR_CLASS_INIT(&tag, "unix");
843 print_otag(h, TAG_SPAN, 1, &tag);
845 for (nn = n->child; nn; nn = nn->next)
846 print_mdoc_node(m, nn, h);
849 h->flags |= HTML_NOSPACE;
851 print_text(h, "BSD");
858 mdoc_it_block_pre(MDOC_ARGS, int type, int comp,
859 struct roffsu *offs, struct roffsu *width)
862 const struct mdoc_node *nn;
865 nn = n->parent->parent;
868 /* XXX: see notes in mdoc_it_pre(). */
870 if (MDOC_Column == type) {
871 /* Don't width-pad on the left. */
872 SCALE_HS_INIT(width, 0);
873 /* Also disallow non-compact. */
876 if (MDOC_Diag == type)
877 /* Mandate non-compact with empty prior. */
878 if (n->prev && NULL == n->prev->body->child)
881 bufcat_style(h, "clear", "both");
883 bufcat_su(h, "margin-left", offs);
884 if (width->scale > 0)
885 bufcat_su(h, "padding-left", width);
887 PAIR_STYLE_INIT(&tag, h);
889 /* Mandate compact following `Ss' and `Sh' starts. */
891 for (nn = n; nn && ! comp; nn = nn->parent) {
892 if (MDOC_BLOCK != nn->type)
894 if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
901 SCALE_VS_INIT(&su, 1);
902 bufcat_su(h, "padding-top", &su);
905 PAIR_STYLE_INIT(&tag, h);
906 print_otag(h, TAG_DIV, 1, &tag);
913 mdoc_it_body_pre(MDOC_ARGS, int type)
927 * XXX: this tricks CSS into aligning the bodies with
928 * the right-padding in the head.
930 SCALE_HS_INIT(&su, 2);
931 bufcat_su(h, "margin-left", &su);
932 PAIR_STYLE_INIT(&tag, h);
933 print_otag(h, TAG_DIV, 1, &tag);
943 mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *width)
953 print_otag(h, TAG_DIV, 0, &tag);
956 bufcat_su(h, "min-width", width);
957 bufcat_style(h, "clear", "none");
958 if (n->next && MDOC_HEAD == n->next->type)
959 bufcat_style(h, "float", "left");
960 PAIR_STYLE_INIT(&tag, h);
961 print_otag(h, TAG_DIV, 1, &tag);
964 bufcat_su(h, "min-width", width);
966 bufcat_su(h, "margin-left", width);
967 if (n->next && n->next->child)
968 bufcat_style(h, "float", "left");
970 /* XXX: buffer if we run into body. */
971 SCALE_HS_INIT(width, 1);
972 bufcat_su(h, "margin-right", width);
973 PAIR_STYLE_INIT(&tag, h);
974 print_otag(h, TAG_DIV, 1, &tag);
980 PAIR_CLASS_INIT(&tag, "diag");
981 print_otag(h, TAG_SPAN, 1, &tag);
986 nbuf[BUFSIZ - 1] = 0;
987 (void)snprintf(nbuf, BUFSIZ - 1, "%d.", ord->pos++);
991 print_text(h, "\\(en");
994 print_text(h, "\\(hy");
997 print_text(h, "\\(bu");
1008 mdoc_it_pre(MDOC_ARGS)
1010 int i, type, wp, comp;
1011 const struct mdoc_node *bl, *nn;
1012 struct roffsu width, offs;
1015 * XXX: be very careful in changing anything, here. Lists in
1016 * mandoc have many peculiarities; furthermore, they don't
1017 * translate well into HTML and require a bit of mangling.
1020 bl = n->parent->parent;
1021 if (MDOC_BLOCK != n->type)
1026 /* Set default width and offset. */
1028 SCALE_HS_INIT(&offs, 0);
1038 SCALE_HS_INIT(&width, 2);
1041 SCALE_HS_INIT(&width, INDENT);
1045 /* Get width, offset, and compact arguments. */
1047 for (wp = -1, comp = i = 0; i < (int)bl->args->argc; i++)
1048 switch (bl->args->argv[i].arg) {
1050 wp = i; /* Save for later. */
1053 a2width(bl->args->argv[i].value[0], &width);
1056 a2offs(bl->args->argv[i].value[0], &offs);
1058 case (MDOC_Compact):
1065 /* Override width in some cases. */
1075 SCALE_HS_INIT(&width, 0);
1078 if (0 == width.scale)
1079 SCALE_HS_INIT(&width, INDENT);
1083 /* Flip to body/block processing. */
1085 if (MDOC_BODY == n->type)
1086 return(mdoc_it_body_pre(m, n, h, type));
1087 if (MDOC_BLOCK == n->type)
1088 return(mdoc_it_block_pre(m, n, h, type, comp,
1091 /* Override column widths. */
1093 if (MDOC_Column == type) {
1094 nn = n->parent->child;
1095 for (i = 0; nn && nn != n; nn = nn->next, i++)
1097 if (i < (int)bl->args->argv[wp].sz)
1098 a2width(bl->args->argv[wp].value[i], &width);
1101 return(mdoc_it_head_pre(m, n, h, type, &width));
1107 mdoc_bl_pre(MDOC_ARGS)
1111 if (MDOC_BLOCK != n->type)
1113 if (MDOC_Enum != a2list(n))
1116 ord = malloc(sizeof(struct ord));
1123 ord->next = h->ords.head;
1131 mdoc_bl_post(MDOC_ARGS)
1135 if (MDOC_BLOCK != n->type)
1137 if (MDOC_Enum != a2list(n))
1142 h->ords.head = ord->next;
1149 mdoc_ex_pre(MDOC_ARGS)
1151 const struct mdoc_node *nn;
1153 struct htmlpair tag;
1155 PAIR_CLASS_INIT(&tag, "utility");
1157 print_text(h, "The");
1158 for (nn = n->child; nn; nn = nn->next) {
1159 t = print_otag(h, TAG_SPAN, 1, &tag);
1160 print_text(h, nn->string);
1163 h->flags |= HTML_NOSPACE;
1165 if (nn->next && NULL == nn->next->next)
1166 print_text(h, ", and");
1170 h->flags &= ~HTML_NOSPACE;
1174 print_text(h, "utilities exit");
1176 print_text(h, "utility exits");
1178 print_text(h, "0 on success, and >0 if an error occurs.");
1185 mdoc_dq_pre(MDOC_ARGS)
1188 if (MDOC_BODY != n->type)
1190 print_text(h, "\\(lq");
1191 h->flags |= HTML_NOSPACE;
1198 mdoc_dq_post(MDOC_ARGS)
1201 if (MDOC_BODY != n->type)
1203 h->flags |= HTML_NOSPACE;
1204 print_text(h, "\\(rq");
1210 mdoc_pq_pre(MDOC_ARGS)
1213 if (MDOC_BODY != n->type)
1215 print_text(h, "\\&(");
1216 h->flags |= HTML_NOSPACE;
1223 mdoc_pq_post(MDOC_ARGS)
1226 if (MDOC_BODY != n->type)
1234 mdoc_sq_pre(MDOC_ARGS)
1237 if (MDOC_BODY != n->type)
1239 print_text(h, "\\(oq");
1240 h->flags |= HTML_NOSPACE;
1247 mdoc_sq_post(MDOC_ARGS)
1250 if (MDOC_BODY != n->type)
1252 h->flags |= HTML_NOSPACE;
1253 print_text(h, "\\(aq");
1259 mdoc_em_pre(MDOC_ARGS)
1261 struct htmlpair tag;
1263 PAIR_CLASS_INIT(&tag, "emph");
1264 print_otag(h, TAG_SPAN, 1, &tag);
1271 mdoc_d1_pre(MDOC_ARGS)
1273 struct htmlpair tag[2];
1276 if (MDOC_BLOCK != n->type)
1279 /* FIXME: D1 shouldn't be literal. */
1281 SCALE_VS_INIT(&su, INDENT - 2);
1282 bufcat_su(h, "margin-left", &su);
1283 PAIR_CLASS_INIT(&tag[0], "lit");
1284 PAIR_STYLE_INIT(&tag[1], h);
1285 print_otag(h, TAG_DIV, 2, tag);
1292 mdoc_sx_pre(MDOC_ARGS)
1294 struct htmlpair tag[2];
1295 const struct mdoc_node *nn;
1298 /* FIXME: duplicates? */
1300 strlcpy(buf, "#", BUFSIZ);
1301 for (nn = n->child; nn; nn = nn->next) {
1302 html_idcat(buf, nn->string, BUFSIZ);
1304 html_idcat(buf, " ", BUFSIZ);
1307 PAIR_CLASS_INIT(&tag[0], "link-sec");
1308 tag[1].key = ATTR_HREF;
1311 print_otag(h, TAG_A, 2, tag);
1318 mdoc_aq_pre(MDOC_ARGS)
1321 if (MDOC_BODY != n->type)
1323 print_text(h, "\\(la");
1324 h->flags |= HTML_NOSPACE;
1331 mdoc_aq_post(MDOC_ARGS)
1334 if (MDOC_BODY != n->type)
1336 h->flags |= HTML_NOSPACE;
1337 print_text(h, "\\(ra");
1343 mdoc_bd_pre(MDOC_ARGS)
1345 struct htmlpair tag[2];
1347 const struct mdoc_node *bl, *nn;
1350 if (MDOC_BLOCK == n->type)
1352 else if (MDOC_HEAD == n->type)
1357 SCALE_VS_INIT(&su, 0);
1360 for (i = 0; i < (int)bl->args->argc; i++)
1361 switch (bl->args->argv[i].arg) {
1363 a2offs(bl->args->argv[i].value[0], &su);
1365 case (MDOC_Compact):
1368 case (MDOC_Centred):
1374 case (MDOC_Unfilled):
1376 case (MDOC_Literal):
1377 type = bl->args->argv[i].arg;
1383 /* FIXME: -centered, etc. formatting. */
1385 if (MDOC_BLOCK == n->type) {
1386 bufcat_su(h, "margin-left", &su);
1387 for (nn = n; nn && ! comp; nn = nn->parent) {
1388 if (MDOC_BLOCK != nn->type)
1390 if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
1396 print_otag(h, TAG_DIV, 0, tag);
1399 SCALE_VS_INIT(&su, 1);
1400 bufcat_su(h, "margin-top", &su);
1401 PAIR_STYLE_INIT(&tag[0], h);
1402 print_otag(h, TAG_DIV, 1, tag);
1406 if (MDOC_Unfilled != type && MDOC_Literal != type)
1409 PAIR_CLASS_INIT(&tag[0], "lit");
1410 bufcat_style(h, "white-space", "pre");
1411 PAIR_STYLE_INIT(&tag[1], h);
1412 print_otag(h, TAG_DIV, 2, tag);
1414 for (nn = n->child; nn; nn = nn->next) {
1415 h->flags |= HTML_NOSPACE;
1416 print_mdoc_node(m, nn, h);
1417 if (NULL == nn->next)
1419 if (nn->prev && nn->prev->line < nn->line)
1420 print_text(h, "\n");
1421 else if (NULL == nn->prev)
1422 print_text(h, "\n");
1431 mdoc_pa_pre(MDOC_ARGS)
1433 struct htmlpair tag;
1435 PAIR_CLASS_INIT(&tag, "file");
1436 print_otag(h, TAG_SPAN, 1, &tag);
1443 mdoc_ad_pre(MDOC_ARGS)
1445 struct htmlpair tag;
1447 PAIR_CLASS_INIT(&tag, "addr");
1448 print_otag(h, TAG_SPAN, 1, &tag);
1455 mdoc_an_pre(MDOC_ARGS)
1457 struct htmlpair tag;
1459 /* TODO: -split and -nosplit (see termp_an_pre()). */
1461 PAIR_CLASS_INIT(&tag, "author");
1462 print_otag(h, TAG_SPAN, 1, &tag);
1469 mdoc_cd_pre(MDOC_ARGS)
1471 struct htmlpair tag;
1473 print_otag(h, TAG_DIV, 0, NULL);
1474 PAIR_CLASS_INIT(&tag, "config");
1475 print_otag(h, TAG_SPAN, 1, &tag);
1482 mdoc_dv_pre(MDOC_ARGS)
1484 struct htmlpair tag;
1486 PAIR_CLASS_INIT(&tag, "define");
1487 print_otag(h, TAG_SPAN, 1, &tag);
1494 mdoc_ev_pre(MDOC_ARGS)
1496 struct htmlpair tag;
1498 PAIR_CLASS_INIT(&tag, "env");
1499 print_otag(h, TAG_SPAN, 1, &tag);
1506 mdoc_er_pre(MDOC_ARGS)
1508 struct htmlpair tag;
1510 PAIR_CLASS_INIT(&tag, "errno");
1511 print_otag(h, TAG_SPAN, 1, &tag);
1518 mdoc_fa_pre(MDOC_ARGS)
1520 const struct mdoc_node *nn;
1521 struct htmlpair tag;
1524 PAIR_CLASS_INIT(&tag, "farg");
1525 if (n->parent->tok != MDOC_Fo) {
1526 print_otag(h, TAG_SPAN, 1, &tag);
1530 for (nn = n->child; nn; nn = nn->next) {
1531 t = print_otag(h, TAG_SPAN, 1, &tag);
1532 print_text(h, nn->string);
1538 if (n->child && n->next && n->next->tok == MDOC_Fa)
1547 mdoc_fd_pre(MDOC_ARGS)
1549 struct htmlpair tag;
1552 if (SEC_SYNOPSIS == n->sec) {
1553 if (n->next && MDOC_Fd != n->next->tok) {
1554 SCALE_VS_INIT(&su, 1);
1555 bufcat_su(h, "margin-bottom", &su);
1556 PAIR_STYLE_INIT(&tag, h);
1557 print_otag(h, TAG_DIV, 1, &tag);
1559 print_otag(h, TAG_DIV, 0, NULL);
1562 PAIR_CLASS_INIT(&tag, "macro");
1563 print_otag(h, TAG_SPAN, 1, &tag);
1570 mdoc_vt_pre(MDOC_ARGS)
1572 struct htmlpair tag;
1575 if (SEC_SYNOPSIS == n->sec) {
1576 if (n->next && MDOC_Vt != n->next->tok) {
1577 SCALE_VS_INIT(&su, 1);
1578 bufcat_su(h, "margin-bottom", &su);
1579 PAIR_STYLE_INIT(&tag, h);
1580 print_otag(h, TAG_DIV, 1, &tag);
1582 print_otag(h, TAG_DIV, 0, NULL);
1585 PAIR_CLASS_INIT(&tag, "type");
1586 print_otag(h, TAG_SPAN, 1, &tag);
1593 mdoc_ft_pre(MDOC_ARGS)
1595 struct htmlpair tag;
1598 if (SEC_SYNOPSIS == n->sec) {
1599 if (n->prev && MDOC_Fo == n->prev->tok) {
1600 SCALE_VS_INIT(&su, 1);
1601 bufcat_su(h, "margin-top", &su);
1602 PAIR_STYLE_INIT(&tag, h);
1603 print_otag(h, TAG_DIV, 1, &tag);
1605 print_otag(h, TAG_DIV, 0, NULL);
1608 PAIR_CLASS_INIT(&tag, "ftype");
1609 print_otag(h, TAG_SPAN, 1, &tag);
1616 mdoc_fn_pre(MDOC_ARGS)
1619 struct htmlpair tag[2];
1620 const struct mdoc_node *nn;
1622 const char *sp, *ep;
1626 if (SEC_SYNOPSIS == n->sec) {
1627 SCALE_HS_INIT(&su, INDENT);
1628 bufcat_su(h, "margin-left", &su);
1629 su.scale = -su.scale;
1630 bufcat_su(h, "text-indent", &su);
1632 SCALE_VS_INIT(&su, 1);
1633 bufcat_su(h, "margin-bottom", &su);
1635 PAIR_STYLE_INIT(&tag[0], h);
1636 print_otag(h, TAG_DIV, 1, tag);
1639 /* Split apart into type and name. */
1640 assert(n->child->string);
1641 sp = n->child->string;
1643 ep = strchr(sp, ' ');
1645 PAIR_CLASS_INIT(&tag[0], "ftype");
1646 t = print_otag(h, TAG_SPAN, 1, tag);
1649 sz = MIN((int)(ep - sp), BUFSIZ - 1);
1650 (void)memcpy(nbuf, sp, (size_t)sz);
1652 print_text(h, nbuf);
1654 ep = strchr(sp, ' ');
1659 PAIR_CLASS_INIT(&tag[0], "fname");
1660 t = print_otag(h, TAG_SPAN, 1, tag);
1663 (void)strlcpy(nbuf, sp, BUFSIZ);
1664 print_text(h, nbuf);
1669 h->flags |= HTML_NOSPACE;
1673 PAIR_CLASS_INIT(&tag[0], "farg");
1674 bufcat_style(h, "white-space", "nowrap");
1675 PAIR_STYLE_INIT(&tag[1], h);
1677 for (nn = n->child->next; nn; nn = nn->next) {
1679 if (SEC_SYNOPSIS == n->sec)
1681 t = print_otag(h, TAG_SPAN, i, tag);
1682 print_text(h, nn->string);
1689 if (SEC_SYNOPSIS == n->sec)
1698 mdoc_sp_pre(MDOC_ARGS)
1701 struct htmlpair tag;
1706 /* FIXME: can this have a scaling indicator? */
1707 len = n->child ? atoi(n->child->string) : 1;
1717 SCALE_VS_INIT(&su, len);
1718 bufcat_su(h, "height", &su);
1719 PAIR_STYLE_INIT(&tag, h);
1720 print_otag(h, TAG_DIV, 1, &tag);
1721 /* So the div isn't empty: */
1722 print_text(h, "\\~");
1731 mdoc_brq_pre(MDOC_ARGS)
1734 if (MDOC_BODY != n->type)
1736 print_text(h, "\\(lC");
1737 h->flags |= HTML_NOSPACE;
1744 mdoc_brq_post(MDOC_ARGS)
1747 if (MDOC_BODY != n->type)
1749 h->flags |= HTML_NOSPACE;
1750 print_text(h, "\\(rC");
1756 mdoc_lk_pre(MDOC_ARGS)
1758 const struct mdoc_node *nn;
1759 struct htmlpair tag[2];
1763 PAIR_CLASS_INIT(&tag[0], "link-ext");
1764 tag[1].key = ATTR_HREF;
1765 tag[1].val = nn->string;
1766 print_otag(h, TAG_A, 2, tag);
1768 if (NULL == nn->next)
1771 for (nn = nn->next; nn; nn = nn->next)
1772 print_text(h, nn->string);
1780 mdoc_mt_pre(MDOC_ARGS)
1782 struct htmlpair tag[2];
1784 const struct mdoc_node *nn;
1786 PAIR_CLASS_INIT(&tag[0], "link-mail");
1788 for (nn = n->child; nn; nn = nn->next) {
1790 bufcat(h, "mailto:");
1791 bufcat(h, nn->string);
1792 PAIR_STYLE_INIT(&tag[1], h);
1793 t = print_otag(h, TAG_A, 2, tag);
1794 print_text(h, nn->string);
1804 mdoc_fo_pre(MDOC_ARGS)
1806 struct htmlpair tag;
1808 if (MDOC_BODY == n->type) {
1809 h->flags |= HTML_NOSPACE;
1811 h->flags |= HTML_NOSPACE;
1813 } else if (MDOC_BLOCK == n->type)
1816 PAIR_CLASS_INIT(&tag, "fname");
1817 print_otag(h, TAG_SPAN, 1, &tag);
1824 mdoc_fo_post(MDOC_ARGS)
1826 if (MDOC_BODY != n->type)
1828 h->flags |= HTML_NOSPACE;
1830 h->flags |= HTML_NOSPACE;
1837 mdoc_in_pre(MDOC_ARGS)
1839 const struct mdoc_node *nn;
1841 struct htmlpair tag[2];
1845 if (SEC_SYNOPSIS == n->sec) {
1846 if (n->next && MDOC_In != n->next->tok) {
1847 SCALE_VS_INIT(&su, 1);
1848 bufcat_su(h, "margin-bottom", &su);
1849 PAIR_STYLE_INIT(&tag[0], h);
1850 print_otag(h, TAG_DIV, 1, tag);
1852 print_otag(h, TAG_DIV, 0, NULL);
1855 /* FIXME: there's a buffer bug in here somewhere. */
1857 PAIR_CLASS_INIT(&tag[0], "includes");
1858 print_otag(h, TAG_SPAN, 1, tag);
1860 if (SEC_SYNOPSIS == n->sec)
1861 print_text(h, "#include");
1864 h->flags |= HTML_NOSPACE;
1866 /* XXX -- see warning in termp_in_post(). */
1868 for (nn = n->child; nn; nn = nn->next) {
1869 PAIR_CLASS_INIT(&tag[0], "link-includes");
1872 if (h->base_includes) {
1873 buffmt_includes(h, nn->string);
1874 tag[i].key = ATTR_HREF;
1875 tag[i++].val = h->buf;
1877 t = print_otag(h, TAG_A, i, tag);
1878 print_mdoc_node(m, nn, h);
1882 h->flags |= HTML_NOSPACE;
1891 mdoc_ic_pre(MDOC_ARGS)
1893 struct htmlpair tag;
1895 PAIR_CLASS_INIT(&tag, "cmd");
1896 print_otag(h, TAG_SPAN, 1, &tag);
1903 mdoc_rv_pre(MDOC_ARGS)
1905 const struct mdoc_node *nn;
1906 struct htmlpair tag;
1909 print_otag(h, TAG_DIV, 0, NULL);
1910 print_text(h, "The");
1912 for (nn = n->child; nn; nn = nn->next) {
1913 PAIR_CLASS_INIT(&tag, "fname");
1914 t = print_otag(h, TAG_SPAN, 1, &tag);
1915 print_text(h, nn->string);
1918 h->flags |= HTML_NOSPACE;
1919 if (nn->next && NULL == nn->next->next)
1920 print_text(h, "(), and");
1922 print_text(h, "(),");
1924 print_text(h, "()");
1928 print_text(h, "functions return");
1930 print_text(h, "function returns");
1932 print_text(h, "the value 0 if successful; otherwise the value "
1933 "-1 is returned and the global variable");
1935 PAIR_CLASS_INIT(&tag, "var");
1936 t = print_otag(h, TAG_SPAN, 1, &tag);
1937 print_text(h, "errno");
1939 print_text(h, "is set to indicate the error.");
1946 mdoc_va_pre(MDOC_ARGS)
1948 struct htmlpair tag;
1950 PAIR_CLASS_INIT(&tag, "var");
1951 print_otag(h, TAG_SPAN, 1, &tag);
1958 mdoc_bq_pre(MDOC_ARGS)
1961 if (MDOC_BODY != n->type)
1963 print_text(h, "\\(lB");
1964 h->flags |= HTML_NOSPACE;
1971 mdoc_bq_post(MDOC_ARGS)
1974 if (MDOC_BODY != n->type)
1976 h->flags |= HTML_NOSPACE;
1977 print_text(h, "\\(rB");
1983 mdoc_ap_pre(MDOC_ARGS)
1986 h->flags |= HTML_NOSPACE;
1987 print_text(h, "\\(aq");
1988 h->flags |= HTML_NOSPACE;
1995 mdoc_bf_pre(MDOC_ARGS)
1998 struct htmlpair tag[2];
2001 if (MDOC_HEAD == n->type)
2003 else if (MDOC_BLOCK != n->type)
2006 PAIR_CLASS_INIT(&tag[0], "lit");
2008 if (n->head->child) {
2009 if ( ! strcmp("Em", n->head->child->string))
2010 PAIR_CLASS_INIT(&tag[0], "emph");
2011 else if ( ! strcmp("Sy", n->head->child->string))
2012 PAIR_CLASS_INIT(&tag[0], "symb");
2013 else if ( ! strcmp("Li", n->head->child->string))
2014 PAIR_CLASS_INIT(&tag[0], "lit");
2017 for (i = 0; i < (int)n->args->argc; i++)
2018 switch (n->args->argv[i].arg) {
2019 case (MDOC_Symbolic):
2020 PAIR_CLASS_INIT(&tag[0], "symb");
2022 case (MDOC_Literal):
2023 PAIR_CLASS_INIT(&tag[0], "lit");
2025 case (MDOC_Emphasis):
2026 PAIR_CLASS_INIT(&tag[0], "emph");
2033 /* FIXME: div's have spaces stripped--we want them. */
2035 bufcat_style(h, "display", "inline");
2036 SCALE_HS_INIT(&su, 1);
2037 bufcat_su(h, "margin-right", &su);
2038 PAIR_STYLE_INIT(&tag[1], h);
2039 print_otag(h, TAG_DIV, 2, tag);
2046 mdoc_ms_pre(MDOC_ARGS)
2048 struct htmlpair tag;
2050 PAIR_CLASS_INIT(&tag, "symb");
2051 print_otag(h, TAG_SPAN, 1, &tag);
2058 mdoc_pf_pre(MDOC_ARGS)
2061 h->flags |= HTML_IGNDELIM;
2068 mdoc_pf_post(MDOC_ARGS)
2071 h->flags &= ~HTML_IGNDELIM;
2072 h->flags |= HTML_NOSPACE;
2078 mdoc_rs_pre(MDOC_ARGS)
2080 struct htmlpair tag;
2083 if (MDOC_BLOCK != n->type)
2086 if (n->prev && SEC_SEE_ALSO == n->sec) {
2087 SCALE_VS_INIT(&su, 1);
2088 bufcat_su(h, "margin-top", &su);
2089 PAIR_STYLE_INIT(&tag, h);
2090 print_otag(h, TAG_DIV, 1, &tag);
2093 PAIR_CLASS_INIT(&tag, "ref");
2094 print_otag(h, TAG_SPAN, 1, &tag);
2102 mdoc_li_pre(MDOC_ARGS)
2104 struct htmlpair tag;
2106 PAIR_CLASS_INIT(&tag, "lit");
2107 print_otag(h, TAG_SPAN, 1, &tag);
2114 mdoc_sy_pre(MDOC_ARGS)
2116 struct htmlpair tag;
2118 PAIR_CLASS_INIT(&tag, "symb");
2119 print_otag(h, TAG_SPAN, 1, &tag);
2126 mdoc_bt_pre(MDOC_ARGS)
2129 print_text(h, "is currently in beta test.");
2136 mdoc_ud_pre(MDOC_ARGS)
2139 print_text(h, "currently under development.");
2146 mdoc_lb_pre(MDOC_ARGS)
2148 struct htmlpair tag;
2150 if (SEC_SYNOPSIS == n->sec)
2151 print_otag(h, TAG_DIV, 0, NULL);
2152 PAIR_CLASS_INIT(&tag, "lib");
2153 print_otag(h, TAG_SPAN, 1, &tag);
2160 mdoc__x_pre(MDOC_ARGS)
2162 struct htmlpair tag[2];
2166 PAIR_CLASS_INIT(&tag[0], "ref-auth");
2169 PAIR_CLASS_INIT(&tag[0], "ref-book");
2172 PAIR_CLASS_INIT(&tag[0], "ref-city");
2175 PAIR_CLASS_INIT(&tag[0], "ref-date");
2178 PAIR_CLASS_INIT(&tag[0], "ref-issue");
2181 PAIR_CLASS_INIT(&tag[0], "ref-jrnl");
2184 PAIR_CLASS_INIT(&tag[0], "ref-num");
2187 PAIR_CLASS_INIT(&tag[0], "ref-opt");
2190 PAIR_CLASS_INIT(&tag[0], "ref-page");
2193 PAIR_CLASS_INIT(&tag[0], "ref-corp");
2196 PAIR_CLASS_INIT(&tag[0], "ref-rep");
2199 PAIR_CLASS_INIT(&tag[0], "ref-title");
2200 print_text(h, "\\(lq");
2201 h->flags |= HTML_NOSPACE;
2204 PAIR_CLASS_INIT(&tag[0], "link-ref");
2207 PAIR_CLASS_INIT(&tag[0], "ref-vol");
2214 if (MDOC__U != n->tok) {
2215 print_otag(h, TAG_SPAN, 1, tag);
2219 PAIR_HREF_INIT(&tag[1], n->child->string);
2220 print_otag(h, TAG_A, 2, tag);
2227 mdoc__x_post(MDOC_ARGS)
2230 h->flags |= HTML_NOSPACE;
2233 print_text(h, "\\(rq");
2234 h->flags |= HTML_NOSPACE;
2239 print_text(h, n->next ? "," : ".");