1 /* $Id: mdoc_html.c,v 1.54 2010/01/30 08:42:20 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>
34 #define MDOC_ARGS const struct mdoc_meta *m, \
35 const struct mdoc_node *n, \
39 #define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b))
43 int (*pre)(MDOC_ARGS);
44 void (*post)(MDOC_ARGS);
47 static void print_mdoc(MDOC_ARGS);
48 static void print_mdoc_head(MDOC_ARGS);
49 static void print_mdoc_node(MDOC_ARGS);
50 static void print_mdoc_nodelist(MDOC_ARGS);
52 static void a2width(const char *, struct roffsu *);
53 static void a2offs(const char *, struct roffsu *);
55 static int a2list(const struct mdoc_node *);
57 static void mdoc_root_post(MDOC_ARGS);
58 static int mdoc_root_pre(MDOC_ARGS);
60 static void mdoc__x_post(MDOC_ARGS);
61 static int mdoc__x_pre(MDOC_ARGS);
62 static int mdoc_ad_pre(MDOC_ARGS);
63 static int mdoc_an_pre(MDOC_ARGS);
64 static int mdoc_ap_pre(MDOC_ARGS);
65 static void mdoc_aq_post(MDOC_ARGS);
66 static int mdoc_aq_pre(MDOC_ARGS);
67 static int mdoc_ar_pre(MDOC_ARGS);
68 static int mdoc_bd_pre(MDOC_ARGS);
69 static int mdoc_bf_pre(MDOC_ARGS);
70 static void mdoc_bl_post(MDOC_ARGS);
71 static int mdoc_bl_pre(MDOC_ARGS);
72 static void mdoc_bq_post(MDOC_ARGS);
73 static int mdoc_bq_pre(MDOC_ARGS);
74 static void mdoc_brq_post(MDOC_ARGS);
75 static int mdoc_brq_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 void mdoc_dq_post(MDOC_ARGS);
81 static int mdoc_dq_pre(MDOC_ARGS);
82 static int mdoc_dv_pre(MDOC_ARGS);
83 static int mdoc_fa_pre(MDOC_ARGS);
84 static int mdoc_fd_pre(MDOC_ARGS);
85 static int mdoc_fl_pre(MDOC_ARGS);
86 static int mdoc_fn_pre(MDOC_ARGS);
87 static int mdoc_ft_pre(MDOC_ARGS);
88 static int mdoc_em_pre(MDOC_ARGS);
89 static int mdoc_er_pre(MDOC_ARGS);
90 static int mdoc_ev_pre(MDOC_ARGS);
91 static int mdoc_ex_pre(MDOC_ARGS);
92 static void mdoc_fo_post(MDOC_ARGS);
93 static int mdoc_fo_pre(MDOC_ARGS);
94 static int mdoc_ic_pre(MDOC_ARGS);
95 static int mdoc_in_pre(MDOC_ARGS);
96 static int mdoc_it_block_pre(MDOC_ARGS, int, int,
97 struct roffsu *, struct roffsu *);
98 static int mdoc_it_head_pre(MDOC_ARGS, int,
100 static int mdoc_it_body_pre(MDOC_ARGS, int);
101 static int mdoc_it_pre(MDOC_ARGS);
102 static int mdoc_lb_pre(MDOC_ARGS);
103 static int mdoc_li_pre(MDOC_ARGS);
104 static int mdoc_lk_pre(MDOC_ARGS);
105 static int mdoc_mt_pre(MDOC_ARGS);
106 static int mdoc_ms_pre(MDOC_ARGS);
107 static int mdoc_nd_pre(MDOC_ARGS);
108 static int mdoc_nm_pre(MDOC_ARGS);
109 static int mdoc_ns_pre(MDOC_ARGS);
110 static void mdoc_op_post(MDOC_ARGS);
111 static int mdoc_op_pre(MDOC_ARGS);
112 static int mdoc_pa_pre(MDOC_ARGS);
113 static void mdoc_pf_post(MDOC_ARGS);
114 static int mdoc_pf_pre(MDOC_ARGS);
115 static void mdoc_pq_post(MDOC_ARGS);
116 static int mdoc_pq_pre(MDOC_ARGS);
117 static int mdoc_rs_pre(MDOC_ARGS);
118 static int mdoc_rv_pre(MDOC_ARGS);
119 static int mdoc_sh_pre(MDOC_ARGS);
120 static int mdoc_sp_pre(MDOC_ARGS);
121 static void mdoc_sq_post(MDOC_ARGS);
122 static int mdoc_sq_pre(MDOC_ARGS);
123 static int mdoc_ss_pre(MDOC_ARGS);
124 static int mdoc_sx_pre(MDOC_ARGS);
125 static int mdoc_sy_pre(MDOC_ARGS);
126 static int mdoc_ud_pre(MDOC_ARGS);
127 static int mdoc_va_pre(MDOC_ARGS);
128 static int mdoc_vt_pre(MDOC_ARGS);
129 static int mdoc_xr_pre(MDOC_ARGS);
130 static int mdoc_xx_pre(MDOC_ARGS);
132 static const struct htmlmdoc mdocs[MDOC_MAX] = {
133 {mdoc_ap_pre, NULL}, /* Ap */
134 {NULL, NULL}, /* Dd */
135 {NULL, NULL}, /* Dt */
136 {NULL, NULL}, /* Os */
137 {mdoc_sh_pre, NULL }, /* Sh */
138 {mdoc_ss_pre, NULL }, /* Ss */
139 {mdoc_sp_pre, NULL}, /* Pp */
140 {mdoc_d1_pre, NULL}, /* D1 */
141 {mdoc_d1_pre, NULL}, /* Dl */
142 {mdoc_bd_pre, NULL}, /* Bd */
143 {NULL, NULL}, /* Ed */
144 {mdoc_bl_pre, mdoc_bl_post}, /* Bl */
145 {NULL, NULL}, /* El */
146 {mdoc_it_pre, NULL}, /* It */
147 {mdoc_ad_pre, NULL}, /* Ad */
148 {mdoc_an_pre, NULL}, /* An */
149 {mdoc_ar_pre, NULL}, /* Ar */
150 {mdoc_cd_pre, NULL}, /* Cd */
151 {mdoc_fl_pre, NULL}, /* Cm */
152 {mdoc_dv_pre, NULL}, /* Dv */
153 {mdoc_er_pre, NULL}, /* Er */
154 {mdoc_ev_pre, NULL}, /* Ev */
155 {mdoc_ex_pre, NULL}, /* Ex */
156 {mdoc_fa_pre, NULL}, /* Fa */
157 {mdoc_fd_pre, NULL}, /* Fd */
158 {mdoc_fl_pre, NULL}, /* Fl */
159 {mdoc_fn_pre, NULL}, /* Fn */
160 {mdoc_ft_pre, NULL}, /* Ft */
161 {mdoc_ic_pre, NULL}, /* Ic */
162 {mdoc_in_pre, NULL}, /* In */
163 {mdoc_li_pre, NULL}, /* Li */
164 {mdoc_nd_pre, NULL}, /* Nd */
165 {mdoc_nm_pre, NULL}, /* Nm */
166 {mdoc_op_pre, mdoc_op_post}, /* Op */
167 {NULL, NULL}, /* Ot */
168 {mdoc_pa_pre, NULL}, /* Pa */
169 {mdoc_rv_pre, NULL}, /* Rv */
170 {NULL, NULL}, /* St */
171 {mdoc_va_pre, NULL}, /* Va */
172 {mdoc_vt_pre, NULL}, /* Vt */
173 {mdoc_xr_pre, NULL}, /* Xr */
174 {mdoc__x_pre, mdoc__x_post}, /* %A */
175 {mdoc__x_pre, mdoc__x_post}, /* %B */
176 {mdoc__x_pre, mdoc__x_post}, /* %D */
177 {mdoc__x_pre, mdoc__x_post}, /* %I */
178 {mdoc__x_pre, mdoc__x_post}, /* %J */
179 {mdoc__x_pre, mdoc__x_post}, /* %N */
180 {mdoc__x_pre, mdoc__x_post}, /* %O */
181 {mdoc__x_pre, mdoc__x_post}, /* %P */
182 {mdoc__x_pre, mdoc__x_post}, /* %R */
183 {mdoc__x_pre, mdoc__x_post}, /* %T */
184 {mdoc__x_pre, mdoc__x_post}, /* %V */
185 {NULL, NULL}, /* Ac */
186 {mdoc_aq_pre, mdoc_aq_post}, /* Ao */
187 {mdoc_aq_pre, mdoc_aq_post}, /* Aq */
188 {NULL, NULL}, /* At */
189 {NULL, NULL}, /* Bc */
190 {mdoc_bf_pre, NULL}, /* Bf */
191 {mdoc_bq_pre, mdoc_bq_post}, /* Bo */
192 {mdoc_bq_pre, mdoc_bq_post}, /* Bq */
193 {mdoc_xx_pre, NULL}, /* Bsx */
194 {mdoc_bx_pre, NULL}, /* Bx */
195 {NULL, NULL}, /* Db */
196 {NULL, NULL}, /* Dc */
197 {mdoc_dq_pre, mdoc_dq_post}, /* Do */
198 {mdoc_dq_pre, mdoc_dq_post}, /* Dq */
199 {NULL, NULL}, /* Ec */
200 {NULL, NULL}, /* Ef */
201 {mdoc_em_pre, NULL}, /* Em */
202 {NULL, NULL}, /* Eo */
203 {mdoc_xx_pre, NULL}, /* Fx */
204 {mdoc_ms_pre, NULL}, /* Ms */ /* FIXME: convert to symbol? */
205 {NULL, NULL}, /* No */
206 {mdoc_ns_pre, NULL}, /* Ns */
207 {mdoc_xx_pre, NULL}, /* Nx */
208 {mdoc_xx_pre, NULL}, /* Ox */
209 {NULL, NULL}, /* Pc */
210 {mdoc_pf_pre, mdoc_pf_post}, /* Pf */
211 {mdoc_pq_pre, mdoc_pq_post}, /* Po */
212 {mdoc_pq_pre, mdoc_pq_post}, /* Pq */
213 {NULL, NULL}, /* Qc */
214 {mdoc_sq_pre, mdoc_sq_post}, /* Ql */
215 {mdoc_dq_pre, mdoc_dq_post}, /* Qo */
216 {mdoc_dq_pre, mdoc_dq_post}, /* Qq */
217 {NULL, NULL}, /* Re */
218 {mdoc_rs_pre, NULL}, /* Rs */
219 {NULL, NULL}, /* Sc */
220 {mdoc_sq_pre, mdoc_sq_post}, /* So */
221 {mdoc_sq_pre, mdoc_sq_post}, /* Sq */
222 {NULL, NULL}, /* Sm */ /* FIXME - no idea. */
223 {mdoc_sx_pre, NULL}, /* Sx */
224 {mdoc_sy_pre, NULL}, /* Sy */
225 {NULL, NULL}, /* Tn */
226 {mdoc_xx_pre, NULL}, /* Ux */
227 {NULL, NULL}, /* Xc */
228 {NULL, NULL}, /* Xo */
229 {mdoc_fo_pre, mdoc_fo_post}, /* Fo */
230 {NULL, NULL}, /* Fc */
231 {mdoc_op_pre, mdoc_op_post}, /* Oo */
232 {NULL, NULL}, /* Oc */
233 {NULL, NULL}, /* Bk */
234 {NULL, NULL}, /* Ek */
235 {mdoc_bt_pre, NULL}, /* Bt */
236 {NULL, NULL}, /* Hf */
237 {NULL, NULL}, /* Fr */
238 {mdoc_ud_pre, NULL}, /* Ud */
239 {mdoc_lb_pre, NULL}, /* Lb */
240 {mdoc_sp_pre, NULL}, /* Lp */
241 {mdoc_lk_pre, NULL}, /* Lk */
242 {mdoc_mt_pre, NULL}, /* Mt */
243 {mdoc_brq_pre, mdoc_brq_post}, /* Brq */
244 {mdoc_brq_pre, mdoc_brq_post}, /* Bro */
245 {NULL, NULL}, /* Brc */
246 {mdoc__x_pre, mdoc__x_post}, /* %C */
247 {NULL, NULL}, /* Es */ /* TODO */
248 {NULL, NULL}, /* En */ /* TODO */
249 {mdoc_xx_pre, NULL}, /* Dx */
250 {mdoc__x_pre, mdoc__x_post}, /* %Q */
251 {mdoc_sp_pre, NULL}, /* br */
252 {mdoc_sp_pre, NULL}, /* sp */
253 {mdoc__x_pre, mdoc__x_post}, /* %U */
258 html_mdoc(void *arg, const struct mdoc *m)
263 h = (struct html *)arg;
266 t = print_otag(h, TAG_HTML, 0, NULL);
267 print_mdoc(mdoc_meta(m), mdoc_node(m), h);
275 * Return the list type for `Bl', e.g., `Bl -column' returns
276 * MDOC_Column. This can ONLY be run for lists; it will abort() if no
277 * list type is found.
280 a2list(const struct mdoc_node *n)
285 for (i = 0; i < (int)n->args->argc; i++)
286 switch (n->args->argv[i].arg) {
308 return(n->args->argv[i].arg);
319 * Calculate the scaling unit passed in a `-width' argument. This uses
320 * either a native scaling unit (e.g., 1i, 2m) or the string length of
324 a2width(const char *p, struct roffsu *su)
327 if ( ! a2roffsu(p, su, SCALE_MAX)) {
329 su->scale = (int)strlen(p);
335 * Calculate the scaling unit passed in an `-offset' argument. This
336 * uses either a native scaling unit (e.g., 1i, 2m), one of a set of
337 * predefined strings (indent, etc.), or the string length of the value.
340 a2offs(const char *p, struct roffsu *su)
343 /* FIXME: "right"? */
345 if (0 == strcmp(p, "left"))
346 SCALE_HS_INIT(su, 0);
347 else if (0 == strcmp(p, "indent"))
348 SCALE_HS_INIT(su, INDENT);
349 else if (0 == strcmp(p, "indent-two"))
350 SCALE_HS_INIT(su, INDENT * 2);
351 else if ( ! a2roffsu(p, su, SCALE_MAX)) {
353 su->scale = (int)strlen(p);
359 print_mdoc(MDOC_ARGS)
364 t = print_otag(h, TAG_HEAD, 0, NULL);
365 print_mdoc_head(m, n, h);
368 t = print_otag(h, TAG_BODY, 0, NULL);
370 tag.key = ATTR_CLASS;
372 print_otag(h, TAG_DIV, 1, &tag);
374 print_mdoc_nodelist(m, n, h);
381 print_mdoc_head(MDOC_ARGS)
386 buffmt(h, "%s(%d)", m->title, m->msec);
394 print_otag(h, TAG_TITLE, 0, NULL);
395 print_text(h, h->buf);
400 print_mdoc_nodelist(MDOC_ARGS)
403 print_mdoc_node(m, n, h);
405 print_mdoc_nodelist(m, n->next, h);
410 print_mdoc_node(MDOC_ARGS)
421 child = mdoc_root_pre(m, n, h);
424 print_text(h, n->string);
427 if (mdocs[n->tok].pre)
428 child = (*mdocs[n->tok].pre)(m, n, h);
432 if (child && n->child)
433 print_mdoc_nodelist(m, n->child, h);
440 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[3];
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 PAIR_SUMMARY_INIT(&tag[2], "footer");
471 t = print_otag(h, TAG_TABLE, 3, tag);
472 tt = print_otag(h, TAG_TR, 0, NULL);
475 bufcat_style(h, "width", "50%");
476 PAIR_STYLE_INIT(&tag[0], h);
477 print_otag(h, TAG_TD, 1, tag);
482 bufcat_style(h, "width", "50%");
483 bufcat_style(h, "text-align", "right");
484 PAIR_STYLE_INIT(&tag[0], h);
485 print_otag(h, TAG_TD, 1, tag);
486 print_text(h, m->os);
493 mdoc_root_pre(MDOC_ARGS)
495 struct htmlpair tag[3];
497 char b[BUFSIZ], title[BUFSIZ];
499 (void)strlcpy(b, m->vol, BUFSIZ);
502 (void)strlcat(b, " (", BUFSIZ);
503 (void)strlcat(b, m->arch, BUFSIZ);
504 (void)strlcat(b, ")", BUFSIZ);
507 (void)snprintf(title, BUFSIZ - 1,
508 "%s(%d)", m->title, m->msec);
510 /* XXX: see note in mdoc_root_post() about divs. */
512 PAIR_CLASS_INIT(&tag[0], "header");
513 bufcat_style(h, "width", "100%");
514 PAIR_STYLE_INIT(&tag[1], h);
515 PAIR_SUMMARY_INIT(&tag[2], "header");
517 t = print_otag(h, TAG_TABLE, 3, tag);
519 tt = print_otag(h, TAG_TR, 0, NULL);
522 bufcat_style(h, "width", "10%");
523 PAIR_STYLE_INIT(&tag[0], h);
524 print_otag(h, TAG_TD, 1, tag);
525 print_text(h, title);
529 bufcat_style(h, "text-align", "center");
530 bufcat_style(h, "white-space", "nowrap");
531 bufcat_style(h, "width", "80%");
532 PAIR_STYLE_INIT(&tag[0], h);
533 print_otag(h, TAG_TD, 1, tag);
538 bufcat_style(h, "text-align", "right");
539 bufcat_style(h, "width", "10%");
540 PAIR_STYLE_INIT(&tag[0], h);
541 print_otag(h, TAG_TD, 1, tag);
542 print_text(h, title);
550 mdoc_sh_pre(MDOC_ARGS)
552 struct htmlpair tag[2];
553 const struct mdoc_node *nn;
557 if (MDOC_BODY == n->type) {
558 SCALE_HS_INIT(&su, INDENT);
559 bufcat_su(h, "margin-left", &su);
560 PAIR_CLASS_INIT(&tag[0], "sec-body");
561 PAIR_STYLE_INIT(&tag[1], h);
562 print_otag(h, TAG_DIV, 2, tag);
564 } else if (MDOC_BLOCK == n->type) {
565 PAIR_CLASS_INIT(&tag[0], "sec-block");
566 if (n->prev && NULL == n->prev->body->child) {
567 print_otag(h, TAG_DIV, 1, tag);
571 SCALE_VS_INIT(&su, 1);
572 bufcat_su(h, "margin-top", &su);
574 bufcat_su(h, "margin-bottom", &su);
576 PAIR_STYLE_INIT(&tag[1], h);
577 print_otag(h, TAG_DIV, 2, tag);
582 for (nn = n->child; nn; nn = nn->next) {
583 html_idcat(buf, nn->string, BUFSIZ);
585 html_idcat(buf, " ", BUFSIZ);
589 * TODO: make sure there are no duplicates, as HTML does not
590 * allow for multiple `id' tags of the same name.
593 PAIR_CLASS_INIT(&tag[0], "sec-head");
594 tag[1].key = ATTR_ID;
596 print_otag(h, TAG_DIV, 2, tag);
603 mdoc_ss_pre(MDOC_ARGS)
605 struct htmlpair tag[3];
606 const struct mdoc_node *nn;
610 SCALE_VS_INIT(&su, 1);
612 if (MDOC_BODY == n->type) {
613 PAIR_CLASS_INIT(&tag[0], "ssec-body");
614 if (n->parent->next && n->child) {
615 bufcat_su(h, "margin-bottom", &su);
616 PAIR_STYLE_INIT(&tag[1], h);
617 print_otag(h, TAG_DIV, 2, tag);
619 print_otag(h, TAG_DIV, 1, tag);
621 } else if (MDOC_BLOCK == n->type) {
622 PAIR_CLASS_INIT(&tag[0], "ssec-block");
624 bufcat_su(h, "margin-top", &su);
625 PAIR_STYLE_INIT(&tag[1], h);
626 print_otag(h, TAG_DIV, 2, tag);
628 print_otag(h, TAG_DIV, 1, tag);
632 /* TODO: see note in mdoc_sh_pre() about duplicates. */
635 for (nn = n->child; nn; nn = nn->next) {
636 html_idcat(buf, nn->string, BUFSIZ);
638 html_idcat(buf, " ", BUFSIZ);
641 SCALE_HS_INIT(&su, INDENT - HALFINDENT);
642 su.scale = -su.scale;
643 bufcat_su(h, "margin-left", &su);
645 PAIR_CLASS_INIT(&tag[0], "ssec-head");
646 PAIR_STYLE_INIT(&tag[1], h);
647 tag[2].key = ATTR_ID;
649 print_otag(h, TAG_DIV, 3, tag);
656 mdoc_fl_pre(MDOC_ARGS)
660 PAIR_CLASS_INIT(&tag, "flag");
661 print_otag(h, TAG_SPAN, 1, &tag);
663 /* `Cm' has no leading hyphen. */
665 if (MDOC_Cm == n->tok)
668 print_text(h, "\\-");
670 /* A blank `Fl' should incur a subsequent space. */
673 h->flags |= HTML_NOSPACE;
681 mdoc_nd_pre(MDOC_ARGS)
685 if (MDOC_BODY != n->type)
688 /* XXX: this tag in theory can contain block elements. */
690 print_text(h, "\\(em");
691 PAIR_CLASS_INIT(&tag, "desc-body");
692 print_otag(h, TAG_SPAN, 1, &tag);
699 mdoc_op_pre(MDOC_ARGS)
703 if (MDOC_BODY != n->type)
706 /* XXX: this tag in theory can contain block elements. */
708 print_text(h, "\\(lB");
709 h->flags |= HTML_NOSPACE;
710 PAIR_CLASS_INIT(&tag, "opt");
711 print_otag(h, TAG_SPAN, 1, &tag);
718 mdoc_op_post(MDOC_ARGS)
721 if (MDOC_BODY != n->type)
723 h->flags |= HTML_NOSPACE;
724 print_text(h, "\\(rB");
729 mdoc_nm_pre(MDOC_ARGS)
733 if (SEC_SYNOPSIS == n->sec && n->prev) {
734 bufcat_style(h, "clear", "both");
735 PAIR_STYLE_INIT(&tag, h);
736 print_otag(h, TAG_BR, 1, &tag);
739 PAIR_CLASS_INIT(&tag, "name");
740 print_otag(h, TAG_SPAN, 1, &tag);
741 if (NULL == n->child)
742 print_text(h, m->name);
750 mdoc_xr_pre(MDOC_ARGS)
752 struct htmlpair tag[2];
753 const struct mdoc_node *nn;
755 PAIR_CLASS_INIT(&tag[0], "link-man");
758 buffmt_man(h, n->child->string,
760 n->child->next->string : NULL);
761 tag[1].key = ATTR_HREF;
763 print_otag(h, TAG_A, 2, tag);
765 print_otag(h, TAG_A, 1, tag);
768 print_text(h, nn->string);
770 if (NULL == (nn = nn->next))
773 h->flags |= HTML_NOSPACE;
775 h->flags |= HTML_NOSPACE;
776 print_text(h, nn->string);
777 h->flags |= HTML_NOSPACE;
785 mdoc_ns_pre(MDOC_ARGS)
788 h->flags |= HTML_NOSPACE;
795 mdoc_ar_pre(MDOC_ARGS)
799 PAIR_CLASS_INIT(&tag, "arg");
800 print_otag(h, TAG_SPAN, 1, &tag);
807 mdoc_xx_pre(MDOC_ARGS)
835 PAIR_CLASS_INIT(&tag, "unix");
836 print_otag(h, TAG_SPAN, 1, &tag);
844 mdoc_bx_pre(MDOC_ARGS)
846 const struct mdoc_node *nn;
849 PAIR_CLASS_INIT(&tag, "unix");
850 print_otag(h, TAG_SPAN, 1, &tag);
852 for (nn = n->child; nn; nn = nn->next)
853 print_mdoc_node(m, nn, h);
856 h->flags |= HTML_NOSPACE;
858 print_text(h, "BSD");
865 mdoc_it_block_pre(MDOC_ARGS, int type, int comp,
866 struct roffsu *offs, struct roffsu *width)
869 const struct mdoc_node *nn;
872 nn = n->parent->parent;
875 /* XXX: see notes in mdoc_it_pre(). */
877 if (MDOC_Column == type) {
878 /* Don't width-pad on the left. */
879 SCALE_HS_INIT(width, 0);
880 /* Also disallow non-compact. */
883 if (MDOC_Diag == type)
884 /* Mandate non-compact with empty prior. */
885 if (n->prev && NULL == n->prev->body->child)
888 bufcat_style(h, "clear", "both");
890 bufcat_su(h, "margin-left", offs);
891 if (width->scale > 0)
892 bufcat_su(h, "padding-left", width);
894 PAIR_STYLE_INIT(&tag, h);
896 /* Mandate compact following `Ss' and `Sh' starts. */
898 for (nn = n; nn && ! comp; nn = nn->parent) {
899 if (MDOC_BLOCK != nn->type)
901 if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
908 SCALE_VS_INIT(&su, 1);
909 bufcat_su(h, "padding-top", &su);
912 PAIR_STYLE_INIT(&tag, h);
913 print_otag(h, TAG_DIV, 1, &tag);
920 mdoc_it_body_pre(MDOC_ARGS, int type)
934 * XXX: this tricks CSS into aligning the bodies with
935 * the right-padding in the head.
937 SCALE_HS_INIT(&su, 2);
938 bufcat_su(h, "margin-left", &su);
939 PAIR_STYLE_INIT(&tag, h);
940 print_otag(h, TAG_DIV, 1, &tag);
950 mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *width)
960 print_otag(h, TAG_DIV, 0, &tag);
963 bufcat_su(h, "min-width", width);
964 bufcat_style(h, "clear", "none");
965 if (n->next && MDOC_HEAD == n->next->type)
966 bufcat_style(h, "float", "left");
967 PAIR_STYLE_INIT(&tag, h);
968 print_otag(h, TAG_DIV, 1, &tag);
971 bufcat_su(h, "min-width", width);
973 bufcat_su(h, "margin-left", width);
974 if (n->next && n->next->child)
975 bufcat_style(h, "float", "left");
977 /* XXX: buffer if we run into body. */
978 SCALE_HS_INIT(width, 1);
979 bufcat_su(h, "margin-right", width);
980 PAIR_STYLE_INIT(&tag, h);
981 print_otag(h, TAG_DIV, 1, &tag);
987 PAIR_CLASS_INIT(&tag, "diag");
988 print_otag(h, TAG_SPAN, 1, &tag);
993 nbuf[BUFSIZ - 1] = 0;
994 (void)snprintf(nbuf, BUFSIZ - 1, "%d.", ord->pos++);
998 print_text(h, "\\(en");
1001 print_text(h, "\\(hy");
1004 print_text(h, "\\(bu");
1015 mdoc_it_pre(MDOC_ARGS)
1017 int i, type, wp, comp;
1018 const struct mdoc_node *bl, *nn;
1019 struct roffsu width, offs;
1022 * XXX: be very careful in changing anything, here. Lists in
1023 * mandoc have many peculiarities; furthermore, they don't
1024 * translate well into HTML and require a bit of mangling.
1027 bl = n->parent->parent;
1028 if (MDOC_BLOCK != n->type)
1033 /* Set default width and offset. */
1035 SCALE_HS_INIT(&offs, 0);
1045 SCALE_HS_INIT(&width, 2);
1048 SCALE_HS_INIT(&width, INDENT);
1052 /* Get width, offset, and compact arguments. */
1054 for (wp = -1, comp = i = 0; i < (int)bl->args->argc; i++)
1055 switch (bl->args->argv[i].arg) {
1057 wp = i; /* Save for later. */
1060 a2width(bl->args->argv[i].value[0], &width);
1063 a2offs(bl->args->argv[i].value[0], &offs);
1065 case (MDOC_Compact):
1072 /* Override width in some cases. */
1082 SCALE_HS_INIT(&width, 0);
1085 if (0 == width.scale)
1086 SCALE_HS_INIT(&width, INDENT);
1090 /* Flip to body/block processing. */
1092 if (MDOC_BODY == n->type)
1093 return(mdoc_it_body_pre(m, n, h, type));
1094 if (MDOC_BLOCK == n->type)
1095 return(mdoc_it_block_pre(m, n, h, type, comp,
1098 /* Override column widths. */
1100 if (MDOC_Column == type) {
1101 nn = n->parent->child;
1102 for (i = 0; nn && nn != n; nn = nn->next, i++)
1104 if (i < (int)bl->args->argv[wp].sz)
1105 a2width(bl->args->argv[wp].value[i], &width);
1108 return(mdoc_it_head_pre(m, n, h, type, &width));
1114 mdoc_bl_pre(MDOC_ARGS)
1118 if (MDOC_BLOCK != n->type)
1120 if (MDOC_Enum != a2list(n))
1123 ord = malloc(sizeof(struct ord));
1130 ord->next = h->ords.head;
1138 mdoc_bl_post(MDOC_ARGS)
1142 if (MDOC_BLOCK != n->type)
1144 if (MDOC_Enum != a2list(n))
1149 h->ords.head = ord->next;
1156 mdoc_ex_pre(MDOC_ARGS)
1158 const struct mdoc_node *nn;
1160 struct htmlpair tag;
1162 PAIR_CLASS_INIT(&tag, "utility");
1164 print_text(h, "The");
1165 for (nn = n->child; nn; nn = nn->next) {
1166 t = print_otag(h, TAG_SPAN, 1, &tag);
1167 print_text(h, nn->string);
1170 h->flags |= HTML_NOSPACE;
1172 if (nn->next && NULL == nn->next->next)
1173 print_text(h, ", and");
1177 h->flags &= ~HTML_NOSPACE;
1181 print_text(h, "utilities exit");
1183 print_text(h, "utility exits");
1185 print_text(h, "0 on success, and >0 if an error occurs.");
1192 mdoc_dq_pre(MDOC_ARGS)
1195 if (MDOC_BODY != n->type)
1197 print_text(h, "\\(lq");
1198 h->flags |= HTML_NOSPACE;
1205 mdoc_dq_post(MDOC_ARGS)
1208 if (MDOC_BODY != n->type)
1210 h->flags |= HTML_NOSPACE;
1211 print_text(h, "\\(rq");
1217 mdoc_pq_pre(MDOC_ARGS)
1220 if (MDOC_BODY != n->type)
1222 print_text(h, "\\&(");
1223 h->flags |= HTML_NOSPACE;
1230 mdoc_pq_post(MDOC_ARGS)
1233 if (MDOC_BODY != n->type)
1241 mdoc_sq_pre(MDOC_ARGS)
1244 if (MDOC_BODY != n->type)
1246 print_text(h, "\\(oq");
1247 h->flags |= HTML_NOSPACE;
1254 mdoc_sq_post(MDOC_ARGS)
1257 if (MDOC_BODY != n->type)
1259 h->flags |= HTML_NOSPACE;
1260 print_text(h, "\\(aq");
1266 mdoc_em_pre(MDOC_ARGS)
1268 struct htmlpair tag;
1270 PAIR_CLASS_INIT(&tag, "emph");
1271 print_otag(h, TAG_SPAN, 1, &tag);
1278 mdoc_d1_pre(MDOC_ARGS)
1280 struct htmlpair tag[2];
1283 if (MDOC_BLOCK != n->type)
1286 /* FIXME: D1 shouldn't be literal. */
1288 SCALE_VS_INIT(&su, INDENT - 2);
1289 bufcat_su(h, "margin-left", &su);
1290 PAIR_CLASS_INIT(&tag[0], "lit");
1291 PAIR_STYLE_INIT(&tag[1], h);
1292 print_otag(h, TAG_DIV, 2, tag);
1299 mdoc_sx_pre(MDOC_ARGS)
1301 struct htmlpair tag[2];
1302 const struct mdoc_node *nn;
1305 /* FIXME: duplicates? */
1307 strlcpy(buf, "#", BUFSIZ);
1308 for (nn = n->child; nn; nn = nn->next) {
1309 html_idcat(buf, nn->string, BUFSIZ);
1311 html_idcat(buf, " ", BUFSIZ);
1314 PAIR_CLASS_INIT(&tag[0], "link-sec");
1315 tag[1].key = ATTR_HREF;
1318 print_otag(h, TAG_A, 2, tag);
1325 mdoc_aq_pre(MDOC_ARGS)
1328 if (MDOC_BODY != n->type)
1330 print_text(h, "\\(la");
1331 h->flags |= HTML_NOSPACE;
1338 mdoc_aq_post(MDOC_ARGS)
1341 if (MDOC_BODY != n->type)
1343 h->flags |= HTML_NOSPACE;
1344 print_text(h, "\\(ra");
1350 mdoc_bd_pre(MDOC_ARGS)
1352 struct htmlpair tag[2];
1354 const struct mdoc_node *bl, *nn;
1357 if (MDOC_BLOCK == n->type)
1359 else if (MDOC_HEAD == n->type)
1364 SCALE_VS_INIT(&su, 0);
1367 for (i = 0; i < (int)bl->args->argc; i++)
1368 switch (bl->args->argv[i].arg) {
1370 a2offs(bl->args->argv[i].value[0], &su);
1372 case (MDOC_Compact):
1375 case (MDOC_Centred):
1381 case (MDOC_Unfilled):
1383 case (MDOC_Literal):
1384 type = bl->args->argv[i].arg;
1390 /* FIXME: -centered, etc. formatting. */
1392 if (MDOC_BLOCK == n->type) {
1393 bufcat_su(h, "margin-left", &su);
1394 for (nn = n; nn && ! comp; nn = nn->parent) {
1395 if (MDOC_BLOCK != nn->type)
1397 if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
1403 print_otag(h, TAG_DIV, 0, tag);
1406 SCALE_VS_INIT(&su, 1);
1407 bufcat_su(h, "margin-top", &su);
1408 PAIR_STYLE_INIT(&tag[0], h);
1409 print_otag(h, TAG_DIV, 1, tag);
1413 if (MDOC_Unfilled != type && MDOC_Literal != type)
1416 PAIR_CLASS_INIT(&tag[0], "lit");
1417 bufcat_style(h, "white-space", "pre");
1418 PAIR_STYLE_INIT(&tag[1], h);
1419 print_otag(h, TAG_DIV, 2, tag);
1421 for (nn = n->child; nn; nn = nn->next) {
1422 h->flags |= HTML_NOSPACE;
1423 print_mdoc_node(m, nn, h);
1424 if (NULL == nn->next)
1426 if (nn->prev && nn->prev->line < nn->line)
1427 print_text(h, "\n");
1428 else if (NULL == nn->prev)
1429 print_text(h, "\n");
1438 mdoc_pa_pre(MDOC_ARGS)
1440 struct htmlpair tag;
1442 PAIR_CLASS_INIT(&tag, "file");
1443 print_otag(h, TAG_SPAN, 1, &tag);
1450 mdoc_ad_pre(MDOC_ARGS)
1452 struct htmlpair tag;
1454 PAIR_CLASS_INIT(&tag, "addr");
1455 print_otag(h, TAG_SPAN, 1, &tag);
1462 mdoc_an_pre(MDOC_ARGS)
1464 struct htmlpair tag;
1466 /* TODO: -split and -nosplit (see termp_an_pre()). */
1468 PAIR_CLASS_INIT(&tag, "author");
1469 print_otag(h, TAG_SPAN, 1, &tag);
1476 mdoc_cd_pre(MDOC_ARGS)
1478 struct htmlpair tag;
1480 print_otag(h, TAG_DIV, 0, NULL);
1481 PAIR_CLASS_INIT(&tag, "config");
1482 print_otag(h, TAG_SPAN, 1, &tag);
1489 mdoc_dv_pre(MDOC_ARGS)
1491 struct htmlpair tag;
1493 PAIR_CLASS_INIT(&tag, "define");
1494 print_otag(h, TAG_SPAN, 1, &tag);
1501 mdoc_ev_pre(MDOC_ARGS)
1503 struct htmlpair tag;
1505 PAIR_CLASS_INIT(&tag, "env");
1506 print_otag(h, TAG_SPAN, 1, &tag);
1513 mdoc_er_pre(MDOC_ARGS)
1515 struct htmlpair tag;
1517 PAIR_CLASS_INIT(&tag, "errno");
1518 print_otag(h, TAG_SPAN, 1, &tag);
1525 mdoc_fa_pre(MDOC_ARGS)
1527 const struct mdoc_node *nn;
1528 struct htmlpair tag;
1531 PAIR_CLASS_INIT(&tag, "farg");
1532 if (n->parent->tok != MDOC_Fo) {
1533 print_otag(h, TAG_SPAN, 1, &tag);
1537 for (nn = n->child; nn; nn = nn->next) {
1538 t = print_otag(h, TAG_SPAN, 1, &tag);
1539 print_text(h, nn->string);
1545 if (n->child && n->next && n->next->tok == MDOC_Fa)
1554 mdoc_fd_pre(MDOC_ARGS)
1556 struct htmlpair tag;
1559 if (SEC_SYNOPSIS == n->sec) {
1560 if (n->next && MDOC_Fd != n->next->tok) {
1561 SCALE_VS_INIT(&su, 1);
1562 bufcat_su(h, "margin-bottom", &su);
1563 PAIR_STYLE_INIT(&tag, h);
1564 print_otag(h, TAG_DIV, 1, &tag);
1566 print_otag(h, TAG_DIV, 0, NULL);
1569 PAIR_CLASS_INIT(&tag, "macro");
1570 print_otag(h, TAG_SPAN, 1, &tag);
1577 mdoc_vt_pre(MDOC_ARGS)
1579 struct htmlpair tag;
1582 if (MDOC_BLOCK == n->type) {
1583 if (n->prev && MDOC_Vt != n->prev->tok) {
1584 SCALE_VS_INIT(&su, 1);
1585 bufcat_su(h, "margin-top", &su);
1586 PAIR_STYLE_INIT(&tag, h);
1587 print_otag(h, TAG_DIV, 1, &tag);
1589 print_otag(h, TAG_DIV, 0, NULL);
1592 } else if (MDOC_HEAD == n->type)
1595 PAIR_CLASS_INIT(&tag, "type");
1596 print_otag(h, TAG_SPAN, 1, &tag);
1603 mdoc_ft_pre(MDOC_ARGS)
1605 struct htmlpair tag;
1608 if (SEC_SYNOPSIS == n->sec) {
1609 if (n->prev && MDOC_Fo == n->prev->tok) {
1610 SCALE_VS_INIT(&su, 1);
1611 bufcat_su(h, "margin-top", &su);
1612 PAIR_STYLE_INIT(&tag, h);
1613 print_otag(h, TAG_DIV, 1, &tag);
1615 print_otag(h, TAG_DIV, 0, NULL);
1618 PAIR_CLASS_INIT(&tag, "ftype");
1619 print_otag(h, TAG_SPAN, 1, &tag);
1626 mdoc_fn_pre(MDOC_ARGS)
1629 struct htmlpair tag[2];
1630 const struct mdoc_node *nn;
1632 const char *sp, *ep;
1636 if (SEC_SYNOPSIS == n->sec) {
1637 SCALE_HS_INIT(&su, INDENT);
1638 bufcat_su(h, "margin-left", &su);
1639 su.scale = -su.scale;
1640 bufcat_su(h, "text-indent", &su);
1642 SCALE_VS_INIT(&su, 1);
1643 bufcat_su(h, "margin-bottom", &su);
1645 PAIR_STYLE_INIT(&tag[0], h);
1646 print_otag(h, TAG_DIV, 1, tag);
1649 /* Split apart into type and name. */
1650 assert(n->child->string);
1651 sp = n->child->string;
1653 ep = strchr(sp, ' ');
1655 PAIR_CLASS_INIT(&tag[0], "ftype");
1656 t = print_otag(h, TAG_SPAN, 1, tag);
1659 sz = MIN((int)(ep - sp), BUFSIZ - 1);
1660 (void)memcpy(nbuf, sp, (size_t)sz);
1662 print_text(h, nbuf);
1664 ep = strchr(sp, ' ');
1669 PAIR_CLASS_INIT(&tag[0], "fname");
1670 t = print_otag(h, TAG_SPAN, 1, tag);
1673 (void)strlcpy(nbuf, sp, BUFSIZ);
1674 print_text(h, nbuf);
1679 h->flags |= HTML_NOSPACE;
1683 PAIR_CLASS_INIT(&tag[0], "farg");
1684 bufcat_style(h, "white-space", "nowrap");
1685 PAIR_STYLE_INIT(&tag[1], h);
1687 for (nn = n->child->next; nn; nn = nn->next) {
1689 if (SEC_SYNOPSIS == n->sec)
1691 t = print_otag(h, TAG_SPAN, i, tag);
1692 print_text(h, nn->string);
1699 if (SEC_SYNOPSIS == n->sec)
1708 mdoc_sp_pre(MDOC_ARGS)
1711 struct htmlpair tag;
1716 /* FIXME: can this have a scaling indicator? */
1717 len = n->child ? atoi(n->child->string) : 1;
1727 SCALE_VS_INIT(&su, len);
1728 bufcat_su(h, "height", &su);
1729 PAIR_STYLE_INIT(&tag, h);
1730 print_otag(h, TAG_DIV, 1, &tag);
1731 /* So the div isn't empty: */
1732 print_text(h, "\\~");
1741 mdoc_brq_pre(MDOC_ARGS)
1744 if (MDOC_BODY != n->type)
1746 print_text(h, "\\(lC");
1747 h->flags |= HTML_NOSPACE;
1754 mdoc_brq_post(MDOC_ARGS)
1757 if (MDOC_BODY != n->type)
1759 h->flags |= HTML_NOSPACE;
1760 print_text(h, "\\(rC");
1766 mdoc_lk_pre(MDOC_ARGS)
1768 const struct mdoc_node *nn;
1769 struct htmlpair tag[2];
1773 PAIR_CLASS_INIT(&tag[0], "link-ext");
1774 tag[1].key = ATTR_HREF;
1775 tag[1].val = nn->string;
1776 print_otag(h, TAG_A, 2, tag);
1778 if (NULL == nn->next)
1781 for (nn = nn->next; nn; nn = nn->next)
1782 print_text(h, nn->string);
1790 mdoc_mt_pre(MDOC_ARGS)
1792 struct htmlpair tag[2];
1794 const struct mdoc_node *nn;
1796 PAIR_CLASS_INIT(&tag[0], "link-mail");
1798 for (nn = n->child; nn; nn = nn->next) {
1800 bufcat(h, "mailto:");
1801 bufcat(h, nn->string);
1802 PAIR_STYLE_INIT(&tag[1], h);
1803 t = print_otag(h, TAG_A, 2, tag);
1804 print_text(h, nn->string);
1814 mdoc_fo_pre(MDOC_ARGS)
1816 struct htmlpair tag;
1818 if (MDOC_BODY == n->type) {
1819 h->flags |= HTML_NOSPACE;
1821 h->flags |= HTML_NOSPACE;
1823 } else if (MDOC_BLOCK == n->type)
1826 PAIR_CLASS_INIT(&tag, "fname");
1827 print_otag(h, TAG_SPAN, 1, &tag);
1834 mdoc_fo_post(MDOC_ARGS)
1836 if (MDOC_BODY != n->type)
1838 h->flags |= HTML_NOSPACE;
1840 h->flags |= HTML_NOSPACE;
1847 mdoc_in_pre(MDOC_ARGS)
1849 const struct mdoc_node *nn;
1851 struct htmlpair tag[2];
1855 if (SEC_SYNOPSIS == n->sec) {
1856 if (n->next && MDOC_In != n->next->tok) {
1857 SCALE_VS_INIT(&su, 1);
1858 bufcat_su(h, "margin-bottom", &su);
1859 PAIR_STYLE_INIT(&tag[0], h);
1860 print_otag(h, TAG_DIV, 1, tag);
1862 print_otag(h, TAG_DIV, 0, NULL);
1865 /* FIXME: there's a buffer bug in here somewhere. */
1867 PAIR_CLASS_INIT(&tag[0], "includes");
1868 print_otag(h, TAG_SPAN, 1, tag);
1870 if (SEC_SYNOPSIS == n->sec)
1871 print_text(h, "#include");
1874 h->flags |= HTML_NOSPACE;
1876 /* XXX -- see warning in termp_in_post(). */
1878 for (nn = n->child; nn; nn = nn->next) {
1879 PAIR_CLASS_INIT(&tag[0], "link-includes");
1882 if (h->base_includes) {
1883 buffmt_includes(h, nn->string);
1884 tag[i].key = ATTR_HREF;
1885 tag[i++].val = h->buf;
1887 t = print_otag(h, TAG_A, i, tag);
1888 print_mdoc_node(m, nn, h);
1892 h->flags |= HTML_NOSPACE;
1901 mdoc_ic_pre(MDOC_ARGS)
1903 struct htmlpair tag;
1905 PAIR_CLASS_INIT(&tag, "cmd");
1906 print_otag(h, TAG_SPAN, 1, &tag);
1913 mdoc_rv_pre(MDOC_ARGS)
1915 const struct mdoc_node *nn;
1916 struct htmlpair tag;
1919 print_otag(h, TAG_DIV, 0, NULL);
1920 print_text(h, "The");
1922 for (nn = n->child; nn; nn = nn->next) {
1923 PAIR_CLASS_INIT(&tag, "fname");
1924 t = print_otag(h, TAG_SPAN, 1, &tag);
1925 print_text(h, nn->string);
1928 h->flags |= HTML_NOSPACE;
1929 if (nn->next && NULL == nn->next->next)
1930 print_text(h, "(), and");
1932 print_text(h, "(),");
1934 print_text(h, "()");
1938 print_text(h, "functions return");
1940 print_text(h, "function returns");
1942 print_text(h, "the value 0 if successful; otherwise the value "
1943 "-1 is returned and the global variable");
1945 PAIR_CLASS_INIT(&tag, "var");
1946 t = print_otag(h, TAG_SPAN, 1, &tag);
1947 print_text(h, "errno");
1949 print_text(h, "is set to indicate the error.");
1956 mdoc_va_pre(MDOC_ARGS)
1958 struct htmlpair tag;
1960 PAIR_CLASS_INIT(&tag, "var");
1961 print_otag(h, TAG_SPAN, 1, &tag);
1968 mdoc_bq_pre(MDOC_ARGS)
1971 if (MDOC_BODY != n->type)
1973 print_text(h, "\\(lB");
1974 h->flags |= HTML_NOSPACE;
1981 mdoc_bq_post(MDOC_ARGS)
1984 if (MDOC_BODY != n->type)
1986 h->flags |= HTML_NOSPACE;
1987 print_text(h, "\\(rB");
1993 mdoc_ap_pre(MDOC_ARGS)
1996 h->flags |= HTML_NOSPACE;
1997 print_text(h, "\\(aq");
1998 h->flags |= HTML_NOSPACE;
2005 mdoc_bf_pre(MDOC_ARGS)
2008 struct htmlpair tag[2];
2011 if (MDOC_HEAD == n->type)
2013 else if (MDOC_BLOCK != n->type)
2016 PAIR_CLASS_INIT(&tag[0], "lit");
2018 if (n->head->child) {
2019 if ( ! strcmp("Em", n->head->child->string))
2020 PAIR_CLASS_INIT(&tag[0], "emph");
2021 else if ( ! strcmp("Sy", n->head->child->string))
2022 PAIR_CLASS_INIT(&tag[0], "symb");
2023 else if ( ! strcmp("Li", n->head->child->string))
2024 PAIR_CLASS_INIT(&tag[0], "lit");
2027 for (i = 0; i < (int)n->args->argc; i++)
2028 switch (n->args->argv[i].arg) {
2029 case (MDOC_Symbolic):
2030 PAIR_CLASS_INIT(&tag[0], "symb");
2032 case (MDOC_Literal):
2033 PAIR_CLASS_INIT(&tag[0], "lit");
2035 case (MDOC_Emphasis):
2036 PAIR_CLASS_INIT(&tag[0], "emph");
2043 /* FIXME: div's have spaces stripped--we want them. */
2045 bufcat_style(h, "display", "inline");
2046 SCALE_HS_INIT(&su, 1);
2047 bufcat_su(h, "margin-right", &su);
2048 PAIR_STYLE_INIT(&tag[1], h);
2049 print_otag(h, TAG_DIV, 2, tag);
2056 mdoc_ms_pre(MDOC_ARGS)
2058 struct htmlpair tag;
2060 PAIR_CLASS_INIT(&tag, "symb");
2061 print_otag(h, TAG_SPAN, 1, &tag);
2068 mdoc_pf_pre(MDOC_ARGS)
2071 h->flags |= HTML_IGNDELIM;
2078 mdoc_pf_post(MDOC_ARGS)
2081 h->flags &= ~HTML_IGNDELIM;
2082 h->flags |= HTML_NOSPACE;
2088 mdoc_rs_pre(MDOC_ARGS)
2090 struct htmlpair tag;
2093 if (MDOC_BLOCK != n->type)
2096 if (n->prev && SEC_SEE_ALSO == n->sec) {
2097 SCALE_VS_INIT(&su, 1);
2098 bufcat_su(h, "margin-top", &su);
2099 PAIR_STYLE_INIT(&tag, h);
2100 print_otag(h, TAG_DIV, 1, &tag);
2103 PAIR_CLASS_INIT(&tag, "ref");
2104 print_otag(h, TAG_SPAN, 1, &tag);
2112 mdoc_li_pre(MDOC_ARGS)
2114 struct htmlpair tag;
2116 PAIR_CLASS_INIT(&tag, "lit");
2117 print_otag(h, TAG_SPAN, 1, &tag);
2124 mdoc_sy_pre(MDOC_ARGS)
2126 struct htmlpair tag;
2128 PAIR_CLASS_INIT(&tag, "symb");
2129 print_otag(h, TAG_SPAN, 1, &tag);
2136 mdoc_bt_pre(MDOC_ARGS)
2139 print_text(h, "is currently in beta test.");
2146 mdoc_ud_pre(MDOC_ARGS)
2149 print_text(h, "currently under development.");
2156 mdoc_lb_pre(MDOC_ARGS)
2158 struct htmlpair tag;
2160 if (SEC_SYNOPSIS == n->sec)
2161 print_otag(h, TAG_DIV, 0, NULL);
2162 PAIR_CLASS_INIT(&tag, "lib");
2163 print_otag(h, TAG_SPAN, 1, &tag);
2170 mdoc__x_pre(MDOC_ARGS)
2172 struct htmlpair tag[2];
2176 PAIR_CLASS_INIT(&tag[0], "ref-auth");
2179 PAIR_CLASS_INIT(&tag[0], "ref-book");
2182 PAIR_CLASS_INIT(&tag[0], "ref-city");
2185 PAIR_CLASS_INIT(&tag[0], "ref-date");
2188 PAIR_CLASS_INIT(&tag[0], "ref-issue");
2191 PAIR_CLASS_INIT(&tag[0], "ref-jrnl");
2194 PAIR_CLASS_INIT(&tag[0], "ref-num");
2197 PAIR_CLASS_INIT(&tag[0], "ref-opt");
2200 PAIR_CLASS_INIT(&tag[0], "ref-page");
2203 PAIR_CLASS_INIT(&tag[0], "ref-corp");
2206 PAIR_CLASS_INIT(&tag[0], "ref-rep");
2209 PAIR_CLASS_INIT(&tag[0], "ref-title");
2210 print_text(h, "\\(lq");
2211 h->flags |= HTML_NOSPACE;
2214 PAIR_CLASS_INIT(&tag[0], "link-ref");
2217 PAIR_CLASS_INIT(&tag[0], "ref-vol");
2224 if (MDOC__U != n->tok) {
2225 print_otag(h, TAG_SPAN, 1, tag);
2229 PAIR_HREF_INIT(&tag[1], n->child->string);
2230 print_otag(h, TAG_A, 2, tag);
2237 mdoc__x_post(MDOC_ARGS)
2240 h->flags |= HTML_NOSPACE;
2243 print_text(h, "\\(rq");
2244 h->flags |= HTML_NOSPACE;
2249 print_text(h, n->next ? "," : ".");