1 /* $Id: mdoc_html.c,v 1.2 2009/10/27 21:40:07 schwarze 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>
36 #define MDOC_ARGS const struct mdoc_meta *m, \
37 const struct mdoc_node *n, \
41 int (*pre)(MDOC_ARGS);
42 void (*post)(MDOC_ARGS);
45 static void print_mdoc(MDOC_ARGS);
46 static void print_mdoc_head(MDOC_ARGS);
47 static void print_mdoc_node(MDOC_ARGS);
48 static void print_mdoc_nodelist(MDOC_ARGS);
50 static void a2width(const char *, struct roffsu *);
51 static void a2offs(const char *, struct roffsu *);
53 static int a2list(const struct mdoc_node *);
55 static void mdoc_root_post(MDOC_ARGS);
56 static int mdoc_root_pre(MDOC_ARGS);
58 static void mdoc__x_post(MDOC_ARGS);
59 static int mdoc__x_pre(MDOC_ARGS);
60 static int mdoc_ad_pre(MDOC_ARGS);
61 static int mdoc_an_pre(MDOC_ARGS);
62 static int mdoc_ap_pre(MDOC_ARGS);
63 static void mdoc_aq_post(MDOC_ARGS);
64 static int mdoc_aq_pre(MDOC_ARGS);
65 static int mdoc_ar_pre(MDOC_ARGS);
66 static int mdoc_bd_pre(MDOC_ARGS);
67 static int mdoc_bf_pre(MDOC_ARGS);
68 static void mdoc_bl_post(MDOC_ARGS);
69 static int mdoc_bl_pre(MDOC_ARGS);
70 static void mdoc_bq_post(MDOC_ARGS);
71 static int mdoc_bq_pre(MDOC_ARGS);
72 static void mdoc_brq_post(MDOC_ARGS);
73 static int mdoc_brq_pre(MDOC_ARGS);
74 static int mdoc_bt_pre(MDOC_ARGS);
75 static int mdoc_bx_pre(MDOC_ARGS);
76 static int mdoc_cd_pre(MDOC_ARGS);
77 static int mdoc_d1_pre(MDOC_ARGS);
78 static void mdoc_dq_post(MDOC_ARGS);
79 static int mdoc_dq_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_in_pre(MDOC_ARGS);
94 static int mdoc_it_block_pre(MDOC_ARGS, int, int,
95 struct roffsu *, struct roffsu *);
96 static int mdoc_it_head_pre(MDOC_ARGS, int,
98 static int mdoc_it_body_pre(MDOC_ARGS, int);
99 static int mdoc_it_pre(MDOC_ARGS);
100 static int mdoc_lb_pre(MDOC_ARGS);
101 static int mdoc_li_pre(MDOC_ARGS);
102 static int mdoc_lk_pre(MDOC_ARGS);
103 static int mdoc_mt_pre(MDOC_ARGS);
104 static int mdoc_ms_pre(MDOC_ARGS);
105 static int mdoc_nd_pre(MDOC_ARGS);
106 static int mdoc_nm_pre(MDOC_ARGS);
107 static int mdoc_ns_pre(MDOC_ARGS);
108 static void mdoc_op_post(MDOC_ARGS);
109 static int mdoc_op_pre(MDOC_ARGS);
110 static int mdoc_pa_pre(MDOC_ARGS);
111 static void mdoc_pf_post(MDOC_ARGS);
112 static int mdoc_pf_pre(MDOC_ARGS);
113 static void mdoc_pq_post(MDOC_ARGS);
114 static int mdoc_pq_pre(MDOC_ARGS);
115 static int mdoc_rs_pre(MDOC_ARGS);
116 static int mdoc_rv_pre(MDOC_ARGS);
117 static int mdoc_sh_pre(MDOC_ARGS);
118 static int mdoc_sp_pre(MDOC_ARGS);
119 static void mdoc_sq_post(MDOC_ARGS);
120 static int mdoc_sq_pre(MDOC_ARGS);
121 static int mdoc_ss_pre(MDOC_ARGS);
122 static int mdoc_sx_pre(MDOC_ARGS);
123 static int mdoc_sy_pre(MDOC_ARGS);
124 static int mdoc_ud_pre(MDOC_ARGS);
125 static int mdoc_va_pre(MDOC_ARGS);
126 static int mdoc_vt_pre(MDOC_ARGS);
127 static int mdoc_xr_pre(MDOC_ARGS);
128 static int mdoc_xx_pre(MDOC_ARGS);
130 static const struct htmlmdoc mdocs[MDOC_MAX] = {
131 {mdoc_ap_pre, NULL}, /* Ap */
132 {NULL, NULL}, /* Dd */
133 {NULL, NULL}, /* Dt */
134 {NULL, NULL}, /* Os */
135 {mdoc_sh_pre, NULL }, /* Sh */
136 {mdoc_ss_pre, NULL }, /* Ss */
137 {mdoc_sp_pre, NULL}, /* Pp */
138 {mdoc_d1_pre, NULL}, /* D1 */
139 {mdoc_d1_pre, NULL}, /* Dl */
140 {mdoc_bd_pre, NULL}, /* Bd */
141 {NULL, NULL}, /* Ed */
142 {mdoc_bl_pre, mdoc_bl_post}, /* Bl */
143 {NULL, NULL}, /* El */
144 {mdoc_it_pre, NULL}, /* It */
145 {mdoc_ad_pre, NULL}, /* Ad */
146 {mdoc_an_pre, NULL}, /* An */
147 {mdoc_ar_pre, NULL}, /* Ar */
148 {mdoc_cd_pre, NULL}, /* Cd */
149 {mdoc_fl_pre, NULL}, /* Cm */
150 {mdoc_dv_pre, NULL}, /* Dv */
151 {mdoc_er_pre, NULL}, /* Er */
152 {mdoc_ev_pre, NULL}, /* Ev */
153 {mdoc_ex_pre, NULL}, /* Ex */
154 {mdoc_fa_pre, NULL}, /* Fa */
155 {mdoc_fd_pre, NULL}, /* Fd */
156 {mdoc_fl_pre, NULL}, /* Fl */
157 {mdoc_fn_pre, NULL}, /* Fn */
158 {mdoc_ft_pre, NULL}, /* Ft */
159 {mdoc_ic_pre, NULL}, /* Ic */
160 {mdoc_in_pre, NULL}, /* In */
161 {mdoc_li_pre, NULL}, /* Li */
162 {mdoc_nd_pre, NULL}, /* Nd */
163 {mdoc_nm_pre, NULL}, /* Nm */
164 {mdoc_op_pre, mdoc_op_post}, /* Op */
165 {NULL, NULL}, /* Ot */
166 {mdoc_pa_pre, NULL}, /* Pa */
167 {mdoc_rv_pre, NULL}, /* Rv */
168 {NULL, NULL}, /* St */
169 {mdoc_va_pre, NULL}, /* Va */
170 {mdoc_vt_pre, NULL}, /* Vt */
171 {mdoc_xr_pre, NULL}, /* Xr */
172 {mdoc__x_pre, mdoc__x_post}, /* %A */
173 {mdoc__x_pre, mdoc__x_post}, /* %B */
174 {mdoc__x_pre, mdoc__x_post}, /* %D */
175 {mdoc__x_pre, mdoc__x_post}, /* %I */
176 {mdoc__x_pre, mdoc__x_post}, /* %J */
177 {mdoc__x_pre, mdoc__x_post}, /* %N */
178 {mdoc__x_pre, mdoc__x_post}, /* %O */
179 {mdoc__x_pre, mdoc__x_post}, /* %P */
180 {mdoc__x_pre, mdoc__x_post}, /* %R */
181 {mdoc__x_pre, mdoc__x_post}, /* %T */
182 {mdoc__x_pre, mdoc__x_post}, /* %V */
183 {NULL, NULL}, /* Ac */
184 {mdoc_aq_pre, mdoc_aq_post}, /* Ao */
185 {mdoc_aq_pre, mdoc_aq_post}, /* Aq */
186 {NULL, NULL}, /* At */
187 {NULL, NULL}, /* Bc */
188 {mdoc_bf_pre, NULL}, /* Bf */
189 {mdoc_bq_pre, mdoc_bq_post}, /* Bo */
190 {mdoc_bq_pre, mdoc_bq_post}, /* Bq */
191 {mdoc_xx_pre, NULL}, /* Bsx */
192 {mdoc_bx_pre, NULL}, /* Bx */
193 {NULL, NULL}, /* Db */
194 {NULL, NULL}, /* Dc */
195 {mdoc_dq_pre, mdoc_dq_post}, /* Do */
196 {mdoc_dq_pre, mdoc_dq_post}, /* Dq */
197 {NULL, NULL}, /* Ec */
198 {NULL, NULL}, /* Ef */
199 {mdoc_em_pre, NULL}, /* Em */
200 {NULL, NULL}, /* Eo */
201 {mdoc_xx_pre, NULL}, /* Fx */
202 {mdoc_ms_pre, NULL}, /* Ms */ /* FIXME: convert to symbol? */
203 {NULL, NULL}, /* No */
204 {mdoc_ns_pre, NULL}, /* Ns */
205 {mdoc_xx_pre, NULL}, /* Nx */
206 {mdoc_xx_pre, NULL}, /* Ox */
207 {NULL, NULL}, /* Pc */
208 {mdoc_pf_pre, mdoc_pf_post}, /* Pf */
209 {mdoc_pq_pre, mdoc_pq_post}, /* Po */
210 {mdoc_pq_pre, mdoc_pq_post}, /* Pq */
211 {NULL, NULL}, /* Qc */
212 {mdoc_sq_pre, mdoc_sq_post}, /* Ql */
213 {mdoc_dq_pre, mdoc_dq_post}, /* Qo */
214 {mdoc_dq_pre, mdoc_dq_post}, /* Qq */
215 {NULL, NULL}, /* Re */
216 {mdoc_rs_pre, NULL}, /* Rs */
217 {NULL, NULL}, /* Sc */
218 {mdoc_sq_pre, mdoc_sq_post}, /* So */
219 {mdoc_sq_pre, mdoc_sq_post}, /* Sq */
220 {NULL, NULL}, /* Sm */ /* FIXME - no idea. */
221 {mdoc_sx_pre, NULL}, /* Sx */
222 {mdoc_sy_pre, NULL}, /* Sy */
223 {NULL, NULL}, /* Tn */
224 {mdoc_xx_pre, NULL}, /* Ux */
225 {NULL, NULL}, /* Xc */
226 {NULL, NULL}, /* Xo */
227 {mdoc_fo_pre, mdoc_fo_post}, /* Fo */
228 {NULL, NULL}, /* Fc */
229 {mdoc_op_pre, mdoc_op_post}, /* Oo */
230 {NULL, NULL}, /* Oc */
231 {NULL, NULL}, /* Bk */
232 {NULL, NULL}, /* Ek */
233 {mdoc_bt_pre, NULL}, /* Bt */
234 {NULL, NULL}, /* Hf */
235 {NULL, NULL}, /* Fr */
236 {mdoc_ud_pre, NULL}, /* Ud */
237 {mdoc_lb_pre, NULL}, /* Lb */
238 {mdoc_sp_pre, NULL}, /* Lp */
239 {mdoc_lk_pre, NULL}, /* Lk */
240 {mdoc_mt_pre, NULL}, /* Mt */
241 {mdoc_brq_pre, mdoc_brq_post}, /* Brq */
242 {mdoc_brq_pre, mdoc_brq_post}, /* Bro */
243 {NULL, NULL}, /* Brc */
244 {mdoc__x_pre, mdoc__x_post}, /* %C */
245 {NULL, NULL}, /* Es */ /* TODO */
246 {NULL, NULL}, /* En */ /* TODO */
247 {mdoc_xx_pre, NULL}, /* Dx */
248 {mdoc__x_pre, mdoc__x_post}, /* %Q */
249 {mdoc_sp_pre, NULL}, /* br */
250 {mdoc_sp_pre, NULL}, /* sp */
251 {mdoc__x_pre, mdoc__x_post}, /* %U */
256 html_mdoc(void *arg, const struct mdoc *m)
261 h = (struct html *)arg;
263 print_gen_doctype(h);
264 t = print_otag(h, TAG_HTML, 0, NULL);
265 print_mdoc(mdoc_meta(m), mdoc_node(m), h);
273 * Return the list type for `Bl', e.g., `Bl -column' returns
274 * MDOC_Column. This can ONLY be run for lists; it will abort() if no
275 * list type is found.
278 a2list(const struct mdoc_node *n)
283 for (i = 0; i < (int)n->args->argc; i++)
284 switch (n->args->argv[i].arg) {
306 return(n->args->argv[i].arg);
317 * Calculate the scaling unit passed in a `-width' argument. This uses
318 * either a native scaling unit (e.g., 1i, 2m) or the string length of
322 a2width(const char *p, struct roffsu *su)
325 if ( ! a2roffsu(p, su, SCALE_MAX)) {
327 su->scale = (int)strlen(p);
333 * Calculate the scaling unit passed in an `-offset' argument. This
334 * uses either a native scaling unit (e.g., 1i, 2m), one of a set of
335 * predefined strings (indent, etc.), or the string length of the value.
338 a2offs(const char *p, struct roffsu *su)
341 /* FIXME: "right"? */
343 if (0 == strcmp(p, "left"))
344 SCALE_HS_INIT(su, 0);
345 else if (0 == strcmp(p, "indent"))
346 SCALE_HS_INIT(su, INDENT);
347 else if (0 == strcmp(p, "indent-two"))
348 SCALE_HS_INIT(su, INDENT * 2);
349 else if ( ! a2roffsu(p, su, SCALE_MAX)) {
351 su->scale = (int)strlen(p);
357 print_mdoc(MDOC_ARGS)
362 t = print_otag(h, TAG_HEAD, 0, NULL);
363 print_mdoc_head(m, n, h);
366 t = print_otag(h, TAG_BODY, 0, NULL);
368 tag.key = ATTR_CLASS;
370 print_otag(h, TAG_DIV, 1, &tag);
372 print_mdoc_nodelist(m, n, h);
379 print_mdoc_head(MDOC_ARGS)
384 buffmt(h, "%s(%d)", m->title, m->msec);
392 print_otag(h, TAG_TITLE, 0, NULL);
393 print_text(h, h->buf);
398 print_mdoc_nodelist(MDOC_ARGS)
401 print_mdoc_node(m, n, h);
403 print_mdoc_nodelist(m, n->next, h);
408 print_mdoc_node(MDOC_ARGS)
419 child = mdoc_root_pre(m, n, h);
422 print_text(h, n->string);
425 if (mdocs[n->tok].pre)
426 child = (*mdocs[n->tok].pre)(m, n, h);
430 if (child && n->child)
431 print_mdoc_nodelist(m, n->child, h);
438 mdoc_root_post(m, n, h);
443 if (mdocs[n->tok].post)
444 (*mdocs[n->tok].post)(m, n, h);
452 mdoc_root_post(MDOC_ARGS)
454 struct htmlpair tag[2];
458 time2a(m->date, b, DATESIZ);
461 * XXX: this should use divs, but in Firefox, divs with nested
462 * divs for some reason puke when trying to put a border line
463 * below. So I use tables, instead.
466 PAIR_CLASS_INIT(&tag[0], "footer");
467 bufcat_style(h, "width", "100%");
468 PAIR_STYLE_INIT(&tag[1], h);
469 t = print_otag(h, TAG_TABLE, 2, tag);
470 tt = print_otag(h, TAG_TR, 0, NULL);
473 bufcat_style(h, "width", "50%");
474 PAIR_STYLE_INIT(&tag[0], h);
475 print_otag(h, TAG_TD, 1, tag);
480 bufcat_style(h, "width", "50%");
481 bufcat_style(h, "text-align", "right");
482 PAIR_STYLE_INIT(&tag[0], h);
483 print_otag(h, TAG_TD, 1, tag);
484 print_text(h, m->os);
491 mdoc_root_pre(MDOC_ARGS)
493 struct htmlpair tag[2];
495 char b[BUFSIZ], title[BUFSIZ];
497 (void)strlcpy(b, m->vol, BUFSIZ);
500 (void)strlcat(b, " (", BUFSIZ);
501 (void)strlcat(b, m->arch, BUFSIZ);
502 (void)strlcat(b, ")", BUFSIZ);
505 (void)snprintf(title, BUFSIZ - 1,
506 "%s(%d)", m->title, m->msec);
508 /* XXX: see note in mdoc_root_post() about divs. */
510 PAIR_CLASS_INIT(&tag[0], "header");
511 bufcat_style(h, "width", "100%");
512 PAIR_STYLE_INIT(&tag[1], h);
513 t = print_otag(h, TAG_TABLE, 2, tag);
514 tt = print_otag(h, TAG_TR, 0, NULL);
517 bufcat_style(h, "width", "10%");
518 PAIR_STYLE_INIT(&tag[0], h);
519 print_otag(h, TAG_TD, 1, tag);
520 print_text(h, title);
524 bufcat_style(h, "text-align", "center");
525 bufcat_style(h, "white-space", "nowrap");
526 bufcat_style(h, "width", "80%");
527 PAIR_STYLE_INIT(&tag[0], h);
528 print_otag(h, TAG_TD, 1, tag);
533 bufcat_style(h, "text-align", "right");
534 bufcat_style(h, "width", "10%");
535 PAIR_STYLE_INIT(&tag[0], h);
536 print_otag(h, TAG_TD, 1, tag);
537 print_text(h, title);
545 mdoc_sh_pre(MDOC_ARGS)
547 struct htmlpair tag[2];
548 const struct mdoc_node *nn;
552 if (MDOC_BODY == n->type) {
553 SCALE_HS_INIT(&su, INDENT);
554 bufcat_su(h, "margin-left", &su);
555 PAIR_CLASS_INIT(&tag[0], "sec-body");
556 PAIR_STYLE_INIT(&tag[1], h);
557 print_otag(h, TAG_DIV, 2, tag);
559 } else if (MDOC_BLOCK == n->type) {
560 PAIR_CLASS_INIT(&tag[0], "sec-block");
561 if (n->prev && NULL == n->prev->body->child) {
562 print_otag(h, TAG_DIV, 1, tag);
566 SCALE_VS_INIT(&su, 1);
567 bufcat_su(h, "margin-top", &su);
569 bufcat_su(h, "margin-bottom", &su);
571 PAIR_STYLE_INIT(&tag[1], h);
572 print_otag(h, TAG_DIV, 2, tag);
577 for (nn = n->child; nn; nn = nn->next) {
578 (void)strlcat(lbuf, nn->string, BUFSIZ);
580 (void)strlcat(lbuf, "_", BUFSIZ);
584 * TODO: make sure there are no duplicates, as HTML does not
585 * allow for multiple `id' tags of the same name.
588 PAIR_CLASS_INIT(&tag[0], "sec-head");
589 tag[1].key = ATTR_ID;
591 print_otag(h, TAG_DIV, 2, tag);
598 mdoc_ss_pre(MDOC_ARGS)
600 struct htmlpair tag[3];
601 const struct mdoc_node *nn;
605 SCALE_VS_INIT(&su, 1);
607 if (MDOC_BODY == n->type) {
608 PAIR_CLASS_INIT(&tag[0], "ssec-body");
609 if (n->parent->next && n->child) {
610 bufcat_su(h, "margin-bottom", &su);
611 PAIR_STYLE_INIT(&tag[1], h);
612 print_otag(h, TAG_DIV, 2, tag);
614 print_otag(h, TAG_DIV, 1, tag);
616 } else if (MDOC_BLOCK == n->type) {
617 PAIR_CLASS_INIT(&tag[0], "ssec-block");
619 bufcat_su(h, "margin-top", &su);
620 PAIR_STYLE_INIT(&tag[1], h);
621 print_otag(h, TAG_DIV, 2, tag);
623 print_otag(h, TAG_DIV, 1, tag);
627 /* TODO: see note in mdoc_sh_pre() about duplicates. */
630 for (nn = n->child; nn; nn = nn->next) {
631 (void)strlcat(lbuf, nn->string, BUFSIZ);
633 (void)strlcat(lbuf, "_", BUFSIZ);
636 SCALE_HS_INIT(&su, INDENT - HALFINDENT);
637 su.scale = -su.scale;
638 bufcat_su(h, "margin-left", &su);
640 PAIR_CLASS_INIT(&tag[0], "ssec-head");
641 PAIR_STYLE_INIT(&tag[1], h);
642 tag[2].key = ATTR_ID;
644 print_otag(h, TAG_DIV, 3, tag);
651 mdoc_fl_pre(MDOC_ARGS)
655 PAIR_CLASS_INIT(&tag, "flag");
656 print_otag(h, TAG_SPAN, 1, &tag);
657 if (MDOC_Fl == n->tok) {
658 print_text(h, "\\-");
659 h->flags |= HTML_NOSPACE;
667 mdoc_nd_pre(MDOC_ARGS)
671 if (MDOC_BODY != n->type)
674 /* XXX: this tag in theory can contain block elements. */
676 print_text(h, "\\(em");
677 PAIR_CLASS_INIT(&tag, "desc-body");
678 print_otag(h, TAG_SPAN, 1, &tag);
685 mdoc_op_pre(MDOC_ARGS)
689 if (MDOC_BODY != n->type)
692 /* XXX: this tag in theory can contain block elements. */
694 print_text(h, "\\(lB");
695 h->flags |= HTML_NOSPACE;
696 PAIR_CLASS_INIT(&tag, "opt");
697 print_otag(h, TAG_SPAN, 1, &tag);
704 mdoc_op_post(MDOC_ARGS)
707 if (MDOC_BODY != n->type)
709 h->flags |= HTML_NOSPACE;
710 print_text(h, "\\(rB");
715 mdoc_nm_pre(MDOC_ARGS)
719 if ( ! (HTML_NEWLINE & h->flags))
720 if (SEC_SYNOPSIS == n->sec) {
721 bufcat_style(h, "clear", "both");
722 PAIR_STYLE_INIT(&tag, h);
723 print_otag(h, TAG_BR, 1, &tag);
726 PAIR_CLASS_INIT(&tag, "name");
727 print_otag(h, TAG_SPAN, 1, &tag);
728 if (NULL == n->child)
729 print_text(h, m->name);
737 mdoc_xr_pre(MDOC_ARGS)
739 struct htmlpair tag[2];
740 const struct mdoc_node *nn;
742 PAIR_CLASS_INIT(&tag[0], "link-man");
745 buffmt_man(h, n->child->string,
747 n->child->next->string : NULL);
748 tag[1].key = ATTR_HREF;
750 print_otag(h, TAG_A, 2, tag);
752 print_otag(h, TAG_A, 1, tag);
755 print_text(h, nn->string);
757 if (NULL == (nn = nn->next))
760 h->flags |= HTML_NOSPACE;
762 h->flags |= HTML_NOSPACE;
763 print_text(h, nn->string);
764 h->flags |= HTML_NOSPACE;
772 mdoc_ns_pre(MDOC_ARGS)
775 h->flags |= HTML_NOSPACE;
782 mdoc_ar_pre(MDOC_ARGS)
786 PAIR_CLASS_INIT(&tag, "arg");
787 print_otag(h, TAG_SPAN, 1, &tag);
794 mdoc_xx_pre(MDOC_ARGS)
822 PAIR_CLASS_INIT(&tag, "unix");
823 print_otag(h, TAG_SPAN, 1, &tag);
831 mdoc_bx_pre(MDOC_ARGS)
833 const struct mdoc_node *nn;
836 PAIR_CLASS_INIT(&tag, "unix");
837 print_otag(h, TAG_SPAN, 1, &tag);
839 for (nn = n->child; nn; nn = nn->next)
840 print_mdoc_node(m, nn, h);
843 h->flags |= HTML_NOSPACE;
845 print_text(h, "BSD");
852 mdoc_it_block_pre(MDOC_ARGS, int type, int comp,
853 struct roffsu *offs, struct roffsu *width)
856 const struct mdoc_node *nn;
859 nn = n->parent->parent;
862 /* XXX: see notes in mdoc_it_pre(). */
864 if (MDOC_Column == type) {
865 /* Don't width-pad on the left. */
866 SCALE_HS_INIT(width, 0);
867 /* Also disallow non-compact. */
870 if (MDOC_Diag == type)
871 /* Mandate non-compact with empty prior. */
872 if (n->prev && NULL == n->prev->body->child)
875 bufcat_style(h, "clear", "both");
877 bufcat_su(h, "margin-left", offs);
878 if (width->scale > 0)
879 bufcat_su(h, "padding-left", width);
881 PAIR_STYLE_INIT(&tag, h);
883 /* Mandate compact following `Ss' and `Sh' starts. */
885 for (nn = n; nn && ! comp; nn = nn->parent) {
886 if (MDOC_BLOCK != nn->type)
888 if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
895 SCALE_VS_INIT(&su, 1);
896 bufcat_su(h, "padding-top", &su);
899 PAIR_STYLE_INIT(&tag, h);
900 print_otag(h, TAG_DIV, 1, &tag);
907 mdoc_it_body_pre(MDOC_ARGS, int type)
921 * XXX: this tricks CSS into aligning the bodies with
922 * the right-padding in the head.
924 SCALE_HS_INIT(&su, 2);
925 bufcat_su(h, "margin-left", &su);
926 PAIR_STYLE_INIT(&tag, h);
927 print_otag(h, TAG_DIV, 1, &tag);
937 mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *width)
947 print_otag(h, TAG_DIV, 0, NULL);
950 bufcat_su(h, "min-width", width);
951 bufcat_style(h, "clear", "none");
952 if (n->next && MDOC_HEAD == n->next->type)
953 bufcat_style(h, "float", "left");
954 PAIR_STYLE_INIT(&tag, h);
955 print_otag(h, TAG_DIV, 1, &tag);
958 bufcat_su(h, "min-width", width);
960 bufcat_su(h, "margin-left", width);
961 if (n->next && n->next->child)
962 bufcat_style(h, "float", "left");
964 /* XXX: buffer if we run into body. */
965 SCALE_HS_INIT(width, 1);
966 bufcat_su(h, "margin-right", width);
967 PAIR_STYLE_INIT(&tag, h);
968 print_otag(h, TAG_DIV, 1, &tag);
974 PAIR_CLASS_INIT(&tag, "diag");
975 print_otag(h, TAG_SPAN, 1, &tag);
980 nbuf[BUFSIZ - 1] = 0;
981 (void)snprintf(nbuf, BUFSIZ - 1, "%d.", ord->pos++);
985 print_text(h, "\\(en");
988 print_text(h, "\\(hy");
991 print_text(h, "\\(bu");
1002 mdoc_it_pre(MDOC_ARGS)
1004 int i, type, wp, comp;
1005 const struct mdoc_node *bl, *nn;
1006 struct roffsu width, offs;
1009 * XXX: be very careful in changing anything, here. Lists in
1010 * mandoc have many peculiarities; furthermore, they don't
1011 * translate well into HTML and require a bit of mangling.
1014 bl = n->parent->parent;
1015 if (MDOC_BLOCK != n->type)
1020 /* Set default width and offset. */
1022 SCALE_HS_INIT(&offs, 0);
1032 SCALE_HS_INIT(&width, 2);
1035 SCALE_HS_INIT(&width, INDENT);
1039 /* Get width, offset, and compact arguments. */
1041 for (wp = -1, comp = i = 0; i < (int)bl->args->argc; i++)
1042 switch (bl->args->argv[i].arg) {
1044 wp = i; /* Save for later. */
1047 a2width(bl->args->argv[i].value[0], &width);
1050 a2offs(bl->args->argv[i].value[0], &offs);
1052 case (MDOC_Compact):
1059 /* Override width in some cases. */
1067 SCALE_HS_INIT(&width, 0);
1070 if (0 == width.scale)
1071 SCALE_HS_INIT(&width, INDENT);
1075 /* Flip to body/block processing. */
1077 if (MDOC_BODY == n->type)
1078 return(mdoc_it_body_pre(m, n, h, type));
1079 if (MDOC_BLOCK == n->type)
1080 return(mdoc_it_block_pre(m, n, h, type, comp,
1083 /* Override column widths. */
1085 if (MDOC_Column == type) {
1086 nn = n->parent->child;
1087 for (i = 0; nn && nn != n; nn = nn->next, i++)
1089 if (i < (int)bl->args->argv[wp].sz)
1090 a2width(bl->args->argv[wp].value[i], &width);
1093 return(mdoc_it_head_pre(m, n, h, type, &width));
1099 mdoc_bl_pre(MDOC_ARGS)
1103 if (MDOC_BLOCK != n->type)
1105 if (MDOC_Enum != a2list(n))
1108 ord = malloc(sizeof(struct ord));
1110 err(EXIT_FAILURE, "malloc");
1113 ord->next = h->ords.head;
1121 mdoc_bl_post(MDOC_ARGS)
1125 if (MDOC_BLOCK != n->type)
1127 if (MDOC_Enum != a2list(n))
1132 h->ords.head = ord->next;
1139 mdoc_ex_pre(MDOC_ARGS)
1141 const struct mdoc_node *nn;
1143 struct htmlpair tag;
1145 PAIR_CLASS_INIT(&tag, "utility");
1147 print_text(h, "The");
1148 for (nn = n->child; nn; nn = nn->next) {
1149 t = print_otag(h, TAG_SPAN, 1, &tag);
1150 print_text(h, nn->string);
1153 h->flags |= HTML_NOSPACE;
1155 if (nn->next && NULL == nn->next->next)
1156 print_text(h, ", and");
1160 h->flags &= ~HTML_NOSPACE;
1164 print_text(h, "utilities exit");
1166 print_text(h, "utility exits");
1168 print_text(h, "0 on success, and >0 if an error occurs.");
1175 mdoc_dq_pre(MDOC_ARGS)
1178 if (MDOC_BODY != n->type)
1180 print_text(h, "\\(lq");
1181 h->flags |= HTML_NOSPACE;
1188 mdoc_dq_post(MDOC_ARGS)
1191 if (MDOC_BODY != n->type)
1193 h->flags |= HTML_NOSPACE;
1194 print_text(h, "\\(rq");
1200 mdoc_pq_pre(MDOC_ARGS)
1203 if (MDOC_BODY != n->type)
1205 print_text(h, "\\&(");
1206 h->flags |= HTML_NOSPACE;
1213 mdoc_pq_post(MDOC_ARGS)
1216 if (MDOC_BODY != n->type)
1224 mdoc_sq_pre(MDOC_ARGS)
1227 if (MDOC_BODY != n->type)
1229 print_text(h, "\\(oq");
1230 h->flags |= HTML_NOSPACE;
1237 mdoc_sq_post(MDOC_ARGS)
1240 if (MDOC_BODY != n->type)
1242 h->flags |= HTML_NOSPACE;
1243 print_text(h, "\\(aq");
1249 mdoc_em_pre(MDOC_ARGS)
1251 struct htmlpair tag;
1253 PAIR_CLASS_INIT(&tag, "emph");
1254 print_otag(h, TAG_SPAN, 1, &tag);
1261 mdoc_d1_pre(MDOC_ARGS)
1263 struct htmlpair tag[2];
1266 if (MDOC_BLOCK != n->type)
1269 /* FIXME: D1 shouldn't be literal. */
1271 SCALE_VS_INIT(&su, INDENT - 2);
1272 bufcat_su(h, "margin-left", &su);
1273 PAIR_CLASS_INIT(&tag[0], "lit");
1274 PAIR_STYLE_INIT(&tag[1], h);
1275 print_otag(h, TAG_DIV, 2, tag);
1282 mdoc_sx_pre(MDOC_ARGS)
1284 struct htmlpair tag[2];
1285 const struct mdoc_node *nn;
1288 /* FIXME: duplicates? */
1290 (void)strlcpy(buf, "#", BUFSIZ);
1291 for (nn = n->child; nn; nn = nn->next) {
1292 (void)strlcat(buf, nn->string, BUFSIZ);
1294 (void)strlcat(buf, "_", BUFSIZ);
1297 PAIR_CLASS_INIT(&tag[0], "link-sec");
1298 tag[1].key = ATTR_HREF;
1301 print_otag(h, TAG_A, 2, tag);
1308 mdoc_aq_pre(MDOC_ARGS)
1311 if (MDOC_BODY != n->type)
1313 print_text(h, "\\(la");
1314 h->flags |= HTML_NOSPACE;
1321 mdoc_aq_post(MDOC_ARGS)
1324 if (MDOC_BODY != n->type)
1326 h->flags |= HTML_NOSPACE;
1327 print_text(h, "\\(ra");
1333 mdoc_bd_pre(MDOC_ARGS)
1335 struct htmlpair tag[2];
1337 const struct mdoc_node *bl, *nn;
1340 if (MDOC_BLOCK == n->type)
1342 else if (MDOC_HEAD == n->type)
1347 SCALE_VS_INIT(&su, 0);
1350 for (i = 0; i < (int)bl->args->argc; i++)
1351 switch (bl->args->argv[i].arg) {
1353 a2offs(bl->args->argv[i].value[0], &su);
1355 case (MDOC_Compact):
1358 case (MDOC_Centred):
1364 case (MDOC_Unfilled):
1366 case (MDOC_Literal):
1367 type = bl->args->argv[i].arg;
1373 /* FIXME: -centered, etc. formatting. */
1375 if (MDOC_BLOCK == n->type) {
1376 bufcat_su(h, "margin-left", &su);
1377 for (nn = n; nn && ! comp; nn = nn->parent) {
1378 if (MDOC_BLOCK != nn->type)
1380 if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
1386 print_otag(h, TAG_DIV, 0, tag);
1389 SCALE_VS_INIT(&su, 1);
1390 bufcat_su(h, "margin-top", &su);
1391 PAIR_STYLE_INIT(&tag[0], h);
1392 print_otag(h, TAG_DIV, 1, tag);
1396 if (MDOC_Unfilled != type && MDOC_Literal != type)
1399 PAIR_CLASS_INIT(&tag[0], "lit");
1400 bufcat_style(h, "white-space", "pre");
1401 PAIR_STYLE_INIT(&tag[1], h);
1402 print_otag(h, TAG_DIV, 2, tag);
1404 for (nn = n->child; nn; nn = nn->next) {
1405 h->flags |= HTML_NOSPACE;
1406 print_mdoc_node(m, nn, h);
1407 if (NULL == nn->next)
1409 if (nn->prev && nn->prev->line < nn->line)
1410 print_text(h, "\n");
1411 else if (NULL == nn->prev)
1412 print_text(h, "\n");
1421 mdoc_pa_pre(MDOC_ARGS)
1423 struct htmlpair tag;
1425 PAIR_CLASS_INIT(&tag, "file");
1426 print_otag(h, TAG_SPAN, 1, &tag);
1433 mdoc_ad_pre(MDOC_ARGS)
1435 struct htmlpair tag;
1437 PAIR_CLASS_INIT(&tag, "addr");
1438 print_otag(h, TAG_SPAN, 1, &tag);
1445 mdoc_an_pre(MDOC_ARGS)
1447 struct htmlpair tag;
1449 /* TODO: -split and -nosplit (see termp_an_pre()). */
1451 PAIR_CLASS_INIT(&tag, "author");
1452 print_otag(h, TAG_SPAN, 1, &tag);
1459 mdoc_cd_pre(MDOC_ARGS)
1461 struct htmlpair tag;
1463 print_otag(h, TAG_DIV, 0, NULL);
1464 PAIR_CLASS_INIT(&tag, "config");
1465 print_otag(h, TAG_SPAN, 1, &tag);
1472 mdoc_dv_pre(MDOC_ARGS)
1474 struct htmlpair tag;
1476 PAIR_CLASS_INIT(&tag, "define");
1477 print_otag(h, TAG_SPAN, 1, &tag);
1484 mdoc_ev_pre(MDOC_ARGS)
1486 struct htmlpair tag;
1488 PAIR_CLASS_INIT(&tag, "env");
1489 print_otag(h, TAG_SPAN, 1, &tag);
1496 mdoc_er_pre(MDOC_ARGS)
1498 struct htmlpair tag;
1500 PAIR_CLASS_INIT(&tag, "errno");
1501 print_otag(h, TAG_SPAN, 1, &tag);
1508 mdoc_fa_pre(MDOC_ARGS)
1510 const struct mdoc_node *nn;
1511 struct htmlpair tag;
1514 PAIR_CLASS_INIT(&tag, "farg");
1515 if (n->parent->tok != MDOC_Fo) {
1516 print_otag(h, TAG_SPAN, 1, &tag);
1520 for (nn = n->child; nn; nn = nn->next) {
1521 t = print_otag(h, TAG_SPAN, 1, &tag);
1522 print_text(h, nn->string);
1528 if (n->child && n->next && n->next->tok == MDOC_Fa)
1537 mdoc_fd_pre(MDOC_ARGS)
1539 struct htmlpair tag;
1542 if (SEC_SYNOPSIS == n->sec) {
1543 if (n->next && MDOC_Fd != n->next->tok) {
1544 SCALE_VS_INIT(&su, 1);
1545 bufcat_su(h, "margin-bottom", &su);
1546 PAIR_STYLE_INIT(&tag, h);
1547 print_otag(h, TAG_DIV, 1, &tag);
1549 print_otag(h, TAG_DIV, 0, NULL);
1552 PAIR_CLASS_INIT(&tag, "macro");
1553 print_otag(h, TAG_SPAN, 1, &tag);
1560 mdoc_vt_pre(MDOC_ARGS)
1562 struct htmlpair tag;
1565 if (SEC_SYNOPSIS == n->sec) {
1566 if (n->next && MDOC_Vt != n->next->tok) {
1567 SCALE_VS_INIT(&su, 1);
1568 bufcat_su(h, "margin-bottom", &su);
1569 PAIR_STYLE_INIT(&tag, h);
1570 print_otag(h, TAG_DIV, 1, &tag);
1572 print_otag(h, TAG_DIV, 0, NULL);
1575 PAIR_CLASS_INIT(&tag, "type");
1576 print_otag(h, TAG_SPAN, 1, &tag);
1583 mdoc_ft_pre(MDOC_ARGS)
1585 struct htmlpair tag;
1588 if (SEC_SYNOPSIS == n->sec) {
1589 if (n->prev && MDOC_Fo == n->prev->tok) {
1590 SCALE_VS_INIT(&su, 1);
1591 bufcat_su(h, "margin-top", &su);
1592 PAIR_STYLE_INIT(&tag, h);
1593 print_otag(h, TAG_DIV, 1, &tag);
1595 print_otag(h, TAG_DIV, 0, NULL);
1598 PAIR_CLASS_INIT(&tag, "ftype");
1599 print_otag(h, TAG_SPAN, 1, &tag);
1606 mdoc_fn_pre(MDOC_ARGS)
1609 struct htmlpair tag[2];
1610 const struct mdoc_node *nn;
1612 const char *sp, *ep;
1616 if (SEC_SYNOPSIS == n->sec) {
1617 SCALE_HS_INIT(&su, INDENT);
1618 bufcat_su(h, "margin-left", &su);
1619 su.scale = -su.scale;
1620 bufcat_su(h, "text-indent", &su);
1622 SCALE_VS_INIT(&su, 1);
1623 bufcat_su(h, "margin-bottom", &su);
1625 PAIR_STYLE_INIT(&tag[0], h);
1626 print_otag(h, TAG_DIV, 1, tag);
1629 /* Split apart into type and name. */
1630 assert(n->child->string);
1631 sp = n->child->string;
1633 ep = strchr(sp, ' ');
1635 PAIR_CLASS_INIT(&tag[0], "ftype");
1636 t = print_otag(h, TAG_SPAN, 1, tag);
1639 sz = MIN((int)(ep - sp), BUFSIZ - 1);
1640 (void)memcpy(nbuf, sp, (size_t)sz);
1642 print_text(h, nbuf);
1644 ep = strchr(sp, ' ');
1649 PAIR_CLASS_INIT(&tag[0], "fname");
1650 t = print_otag(h, TAG_SPAN, 1, tag);
1653 (void)strlcpy(nbuf, sp, BUFSIZ);
1654 print_text(h, nbuf);
1659 h->flags |= HTML_NOSPACE;
1663 PAIR_CLASS_INIT(&tag[0], "farg");
1664 bufcat_style(h, "white-space", "nowrap");
1665 PAIR_STYLE_INIT(&tag[1], h);
1667 for (nn = n->child->next; nn; nn = nn->next) {
1669 if (SEC_SYNOPSIS == n->sec)
1671 t = print_otag(h, TAG_SPAN, i, tag);
1672 print_text(h, nn->string);
1679 if (SEC_SYNOPSIS == n->sec)
1688 mdoc_sp_pre(MDOC_ARGS)
1691 struct htmlpair tag;
1696 /* FIXME: can this have a scaling indicator? */
1697 len = n->child ? atoi(n->child->string) : 1;
1707 SCALE_VS_INIT(&su, len);
1708 bufcat_su(h, "height", &su);
1709 PAIR_STYLE_INIT(&tag, h);
1710 print_otag(h, TAG_DIV, 1, &tag);
1718 mdoc_brq_pre(MDOC_ARGS)
1721 if (MDOC_BODY != n->type)
1723 print_text(h, "\\(lC");
1724 h->flags |= HTML_NOSPACE;
1731 mdoc_brq_post(MDOC_ARGS)
1734 if (MDOC_BODY != n->type)
1736 h->flags |= HTML_NOSPACE;
1737 print_text(h, "\\(rC");
1743 mdoc_lk_pre(MDOC_ARGS)
1745 const struct mdoc_node *nn;
1746 struct htmlpair tag[2];
1750 PAIR_CLASS_INIT(&tag[0], "link-ext");
1751 tag[1].key = ATTR_HREF;
1752 tag[1].val = nn->string;
1753 print_otag(h, TAG_A, 2, tag);
1755 if (NULL == nn->next)
1758 for (nn = nn->next; nn; nn = nn->next)
1759 print_text(h, nn->string);
1767 mdoc_mt_pre(MDOC_ARGS)
1769 struct htmlpair tag[2];
1771 const struct mdoc_node *nn;
1773 PAIR_CLASS_INIT(&tag[0], "link-mail");
1775 for (nn = n->child; nn; nn = nn->next) {
1777 bufcat(h, "mailto:");
1778 bufcat(h, nn->string);
1779 PAIR_STYLE_INIT(&tag[1], h);
1780 t = print_otag(h, TAG_A, 2, tag);
1781 print_text(h, nn->string);
1791 mdoc_fo_pre(MDOC_ARGS)
1793 struct htmlpair tag;
1795 if (MDOC_BODY == n->type) {
1796 h->flags |= HTML_NOSPACE;
1798 h->flags |= HTML_NOSPACE;
1800 } else if (MDOC_BLOCK == n->type)
1803 PAIR_CLASS_INIT(&tag, "fname");
1804 print_otag(h, TAG_SPAN, 1, &tag);
1811 mdoc_fo_post(MDOC_ARGS)
1813 if (MDOC_BODY != n->type)
1815 h->flags |= HTML_NOSPACE;
1817 h->flags |= HTML_NOSPACE;
1824 mdoc_in_pre(MDOC_ARGS)
1826 const struct mdoc_node *nn;
1828 struct htmlpair tag[2];
1832 if (SEC_SYNOPSIS == n->sec) {
1833 if (n->next && MDOC_In != n->next->tok) {
1834 SCALE_VS_INIT(&su, 1);
1835 bufcat_su(h, "margin-bottom", &su);
1836 PAIR_STYLE_INIT(&tag[0], h);
1837 print_otag(h, TAG_DIV, 1, tag);
1839 print_otag(h, TAG_DIV, 0, NULL);
1842 /* FIXME: there's a buffer bug in here somewhere. */
1844 PAIR_CLASS_INIT(&tag[0], "includes");
1845 print_otag(h, TAG_SPAN, 1, tag);
1847 if (SEC_SYNOPSIS == n->sec)
1848 print_text(h, "#include");
1851 h->flags |= HTML_NOSPACE;
1853 /* XXX -- see warning in termp_in_post(). */
1855 for (nn = n->child; nn; nn = nn->next) {
1856 PAIR_CLASS_INIT(&tag[0], "link-includes");
1858 if (h->base_includes) {
1859 buffmt_includes(h, nn->string);
1860 tag[i].key = ATTR_HREF;
1861 tag[i++].val = h->buf;
1863 t = print_otag(h, TAG_A, i, tag);
1864 print_mdoc_node(m, nn, h);
1868 h->flags |= HTML_NOSPACE;
1877 mdoc_ic_pre(MDOC_ARGS)
1879 struct htmlpair tag;
1881 PAIR_CLASS_INIT(&tag, "cmd");
1882 print_otag(h, TAG_SPAN, 1, &tag);
1889 mdoc_rv_pre(MDOC_ARGS)
1891 const struct mdoc_node *nn;
1892 struct htmlpair tag;
1895 print_otag(h, TAG_DIV, 0, NULL);
1896 print_text(h, "The");
1898 for (nn = n->child; nn; nn = nn->next) {
1899 PAIR_CLASS_INIT(&tag, "fname");
1900 t = print_otag(h, TAG_SPAN, 1, &tag);
1901 print_text(h, nn->string);
1904 h->flags |= HTML_NOSPACE;
1905 if (nn->next && NULL == nn->next->next)
1906 print_text(h, "(), and");
1908 print_text(h, "(),");
1910 print_text(h, "()");
1914 print_text(h, "functions return");
1916 print_text(h, "function returns");
1918 print_text(h, "the value 0 if successful; otherwise the value "
1919 "-1 is returned and the global variable");
1921 PAIR_CLASS_INIT(&tag, "var");
1922 t = print_otag(h, TAG_SPAN, 1, &tag);
1923 print_text(h, "errno");
1925 print_text(h, "is set to indicate the error.");
1932 mdoc_va_pre(MDOC_ARGS)
1934 struct htmlpair tag;
1936 PAIR_CLASS_INIT(&tag, "var");
1937 print_otag(h, TAG_SPAN, 1, &tag);
1944 mdoc_bq_pre(MDOC_ARGS)
1947 if (MDOC_BODY != n->type)
1949 print_text(h, "\\(lB");
1950 h->flags |= HTML_NOSPACE;
1957 mdoc_bq_post(MDOC_ARGS)
1960 if (MDOC_BODY != n->type)
1962 h->flags |= HTML_NOSPACE;
1963 print_text(h, "\\(rB");
1969 mdoc_ap_pre(MDOC_ARGS)
1972 h->flags |= HTML_NOSPACE;
1973 print_text(h, "\\(aq");
1974 h->flags |= HTML_NOSPACE;
1981 mdoc_bf_pre(MDOC_ARGS)
1984 struct htmlpair tag[2];
1987 if (MDOC_HEAD == n->type)
1989 else if (MDOC_BLOCK != n->type)
1992 PAIR_CLASS_INIT(&tag[0], "lit");
1994 if (n->head->child) {
1995 if ( ! strcmp("Em", n->head->child->string))
1996 PAIR_CLASS_INIT(&tag[0], "emph");
1997 else if ( ! strcmp("Sy", n->head->child->string))
1998 PAIR_CLASS_INIT(&tag[0], "symb");
1999 else if ( ! strcmp("Li", n->head->child->string))
2000 PAIR_CLASS_INIT(&tag[0], "lit");
2003 for (i = 0; i < (int)n->args->argc; i++)
2004 switch (n->args->argv[i].arg) {
2005 case (MDOC_Symbolic):
2006 PAIR_CLASS_INIT(&tag[0], "symb");
2008 case (MDOC_Literal):
2009 PAIR_CLASS_INIT(&tag[0], "lit");
2011 case (MDOC_Emphasis):
2012 PAIR_CLASS_INIT(&tag[0], "emph");
2019 /* FIXME: div's have spaces stripped--we want them. */
2021 bufcat_style(h, "display", "inline");
2022 SCALE_HS_INIT(&su, 1);
2023 bufcat_su(h, "margin-right", &su);
2024 PAIR_STYLE_INIT(&tag[1], h);
2025 print_otag(h, TAG_DIV, 2, tag);
2032 mdoc_ms_pre(MDOC_ARGS)
2034 struct htmlpair tag;
2036 PAIR_CLASS_INIT(&tag, "symb");
2037 print_otag(h, TAG_SPAN, 1, &tag);
2044 mdoc_pf_pre(MDOC_ARGS)
2047 h->flags |= HTML_IGNDELIM;
2054 mdoc_pf_post(MDOC_ARGS)
2057 h->flags &= ~HTML_IGNDELIM;
2058 h->flags |= HTML_NOSPACE;
2064 mdoc_rs_pre(MDOC_ARGS)
2066 struct htmlpair tag;
2069 if (MDOC_BLOCK != n->type)
2072 if (n->prev && SEC_SEE_ALSO == n->sec) {
2073 SCALE_VS_INIT(&su, 1);
2074 bufcat_su(h, "margin-top", &su);
2075 PAIR_STYLE_INIT(&tag, h);
2076 print_otag(h, TAG_DIV, 1, &tag);
2079 PAIR_CLASS_INIT(&tag, "ref");
2080 print_otag(h, TAG_SPAN, 1, &tag);
2088 mdoc_li_pre(MDOC_ARGS)
2090 struct htmlpair tag;
2092 PAIR_CLASS_INIT(&tag, "lit");
2093 print_otag(h, TAG_SPAN, 1, &tag);
2100 mdoc_sy_pre(MDOC_ARGS)
2102 struct htmlpair tag;
2104 PAIR_CLASS_INIT(&tag, "symb");
2105 print_otag(h, TAG_SPAN, 1, &tag);
2112 mdoc_bt_pre(MDOC_ARGS)
2115 print_text(h, "is currently in beta test.");
2122 mdoc_ud_pre(MDOC_ARGS)
2125 print_text(h, "currently under development.");
2132 mdoc_lb_pre(MDOC_ARGS)
2134 struct htmlpair tag;
2136 if (SEC_SYNOPSIS == n->sec)
2137 print_otag(h, TAG_DIV, 0, NULL);
2138 PAIR_CLASS_INIT(&tag, "lib");
2139 print_otag(h, TAG_SPAN, 1, &tag);
2146 mdoc__x_pre(MDOC_ARGS)
2148 struct htmlpair tag[2];
2152 PAIR_CLASS_INIT(&tag[0], "ref-auth");
2155 PAIR_CLASS_INIT(&tag[0], "ref-book");
2158 PAIR_CLASS_INIT(&tag[0], "ref-city");
2161 PAIR_CLASS_INIT(&tag[0], "ref-date");
2164 PAIR_CLASS_INIT(&tag[0], "ref-issue");
2167 PAIR_CLASS_INIT(&tag[0], "ref-jrnl");
2170 PAIR_CLASS_INIT(&tag[0], "ref-num");
2173 PAIR_CLASS_INIT(&tag[0], "ref-opt");
2176 PAIR_CLASS_INIT(&tag[0], "ref-page");
2179 PAIR_CLASS_INIT(&tag[0], "ref-corp");
2182 PAIR_CLASS_INIT(&tag[0], "ref-rep");
2185 PAIR_CLASS_INIT(&tag[0], "ref-title");
2186 print_text(h, "\\(lq");
2187 h->flags |= HTML_NOSPACE;
2190 PAIR_CLASS_INIT(&tag[0], "link-ref");
2193 PAIR_CLASS_INIT(&tag[0], "ref-vol");
2200 if (MDOC__U != n->tok) {
2201 print_otag(h, TAG_SPAN, 1, tag);
2205 PAIR_HREF_INIT(&tag[1], n->child->string);
2206 print_otag(h, TAG_A, 2, tag);
2213 mdoc__x_post(MDOC_ARGS)
2216 h->flags |= HTML_NOSPACE;
2219 print_text(h, "\\(rq");
2220 h->flags |= HTML_NOSPACE;
2225 print_text(h, n->next ? "," : ".");