1 /* $Id: mdoc_html.c,v 1.195 2014/08/06 15:09:05 schwarze Exp $ */
3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #include <sys/types.h>
32 #include "mandoc_aux.h"
40 #define MDOC_ARGS const struct mdoc_meta *meta, \
41 const struct mdoc_node *n, \
45 #define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b))
49 int (*pre)(MDOC_ARGS);
50 void (*post)(MDOC_ARGS);
53 static void print_mdoc(MDOC_ARGS);
54 static void print_mdoc_head(MDOC_ARGS);
55 static void print_mdoc_node(MDOC_ARGS);
56 static void print_mdoc_nodelist(MDOC_ARGS);
57 static void synopsis_pre(struct html *,
58 const struct mdoc_node *);
60 static void a2width(const char *, struct roffsu *);
61 static void a2offs(const char *, struct roffsu *);
63 static void mdoc_root_post(MDOC_ARGS);
64 static int mdoc_root_pre(MDOC_ARGS);
66 static void mdoc__x_post(MDOC_ARGS);
67 static int mdoc__x_pre(MDOC_ARGS);
68 static int mdoc_ad_pre(MDOC_ARGS);
69 static int mdoc_an_pre(MDOC_ARGS);
70 static int mdoc_ap_pre(MDOC_ARGS);
71 static int mdoc_ar_pre(MDOC_ARGS);
72 static int mdoc_bd_pre(MDOC_ARGS);
73 static int mdoc_bf_pre(MDOC_ARGS);
74 static void mdoc_bk_post(MDOC_ARGS);
75 static int mdoc_bk_pre(MDOC_ARGS);
76 static int mdoc_bl_pre(MDOC_ARGS);
77 static int mdoc_bt_pre(MDOC_ARGS);
78 static int mdoc_bx_pre(MDOC_ARGS);
79 static int mdoc_cd_pre(MDOC_ARGS);
80 static int mdoc_d1_pre(MDOC_ARGS);
81 static int mdoc_dv_pre(MDOC_ARGS);
82 static int mdoc_fa_pre(MDOC_ARGS);
83 static int mdoc_fd_pre(MDOC_ARGS);
84 static int mdoc_fl_pre(MDOC_ARGS);
85 static int mdoc_fn_pre(MDOC_ARGS);
86 static int mdoc_ft_pre(MDOC_ARGS);
87 static int mdoc_em_pre(MDOC_ARGS);
88 static int mdoc_er_pre(MDOC_ARGS);
89 static int mdoc_ev_pre(MDOC_ARGS);
90 static int mdoc_ex_pre(MDOC_ARGS);
91 static void mdoc_fo_post(MDOC_ARGS);
92 static int mdoc_fo_pre(MDOC_ARGS);
93 static int mdoc_ic_pre(MDOC_ARGS);
94 static int mdoc_igndelim_pre(MDOC_ARGS);
95 static int mdoc_in_pre(MDOC_ARGS);
96 static int mdoc_it_pre(MDOC_ARGS);
97 static int mdoc_lb_pre(MDOC_ARGS);
98 static int mdoc_li_pre(MDOC_ARGS);
99 static int mdoc_lk_pre(MDOC_ARGS);
100 static int mdoc_mt_pre(MDOC_ARGS);
101 static int mdoc_ms_pre(MDOC_ARGS);
102 static int mdoc_nd_pre(MDOC_ARGS);
103 static int mdoc_nm_pre(MDOC_ARGS);
104 static int mdoc_ns_pre(MDOC_ARGS);
105 static int mdoc_pa_pre(MDOC_ARGS);
106 static void mdoc_pf_post(MDOC_ARGS);
107 static int mdoc_pp_pre(MDOC_ARGS);
108 static void mdoc_quote_post(MDOC_ARGS);
109 static int mdoc_quote_pre(MDOC_ARGS);
110 static int mdoc_rs_pre(MDOC_ARGS);
111 static int mdoc_rv_pre(MDOC_ARGS);
112 static int mdoc_sh_pre(MDOC_ARGS);
113 static int mdoc_skip_pre(MDOC_ARGS);
114 static int mdoc_sm_pre(MDOC_ARGS);
115 static int mdoc_sp_pre(MDOC_ARGS);
116 static int mdoc_ss_pre(MDOC_ARGS);
117 static int mdoc_sx_pre(MDOC_ARGS);
118 static int mdoc_sy_pre(MDOC_ARGS);
119 static int mdoc_ud_pre(MDOC_ARGS);
120 static int mdoc_va_pre(MDOC_ARGS);
121 static int mdoc_vt_pre(MDOC_ARGS);
122 static int mdoc_xr_pre(MDOC_ARGS);
123 static int mdoc_xx_pre(MDOC_ARGS);
125 static const struct htmlmdoc mdocs[MDOC_MAX] = {
126 {mdoc_ap_pre, NULL}, /* Ap */
127 {NULL, NULL}, /* Dd */
128 {NULL, NULL}, /* Dt */
129 {NULL, NULL}, /* Os */
130 {mdoc_sh_pre, NULL }, /* Sh */
131 {mdoc_ss_pre, NULL }, /* Ss */
132 {mdoc_pp_pre, NULL}, /* Pp */
133 {mdoc_d1_pre, NULL}, /* D1 */
134 {mdoc_d1_pre, NULL}, /* Dl */
135 {mdoc_bd_pre, NULL}, /* Bd */
136 {NULL, NULL}, /* Ed */
137 {mdoc_bl_pre, NULL}, /* Bl */
138 {NULL, NULL}, /* El */
139 {mdoc_it_pre, NULL}, /* It */
140 {mdoc_ad_pre, NULL}, /* Ad */
141 {mdoc_an_pre, NULL}, /* An */
142 {mdoc_ar_pre, NULL}, /* Ar */
143 {mdoc_cd_pre, NULL}, /* Cd */
144 {mdoc_fl_pre, NULL}, /* Cm */
145 {mdoc_dv_pre, NULL}, /* Dv */
146 {mdoc_er_pre, NULL}, /* Er */
147 {mdoc_ev_pre, NULL}, /* Ev */
148 {mdoc_ex_pre, NULL}, /* Ex */
149 {mdoc_fa_pre, NULL}, /* Fa */
150 {mdoc_fd_pre, NULL}, /* Fd */
151 {mdoc_fl_pre, NULL}, /* Fl */
152 {mdoc_fn_pre, NULL}, /* Fn */
153 {mdoc_ft_pre, NULL}, /* Ft */
154 {mdoc_ic_pre, NULL}, /* Ic */
155 {mdoc_in_pre, NULL}, /* In */
156 {mdoc_li_pre, NULL}, /* Li */
157 {mdoc_nd_pre, NULL}, /* Nd */
158 {mdoc_nm_pre, NULL}, /* Nm */
159 {mdoc_quote_pre, mdoc_quote_post}, /* Op */
160 {mdoc_ft_pre, NULL}, /* Ot */
161 {mdoc_pa_pre, NULL}, /* Pa */
162 {mdoc_rv_pre, NULL}, /* Rv */
163 {NULL, NULL}, /* St */
164 {mdoc_va_pre, NULL}, /* Va */
165 {mdoc_vt_pre, NULL}, /* Vt */
166 {mdoc_xr_pre, NULL}, /* Xr */
167 {mdoc__x_pre, mdoc__x_post}, /* %A */
168 {mdoc__x_pre, mdoc__x_post}, /* %B */
169 {mdoc__x_pre, mdoc__x_post}, /* %D */
170 {mdoc__x_pre, mdoc__x_post}, /* %I */
171 {mdoc__x_pre, mdoc__x_post}, /* %J */
172 {mdoc__x_pre, mdoc__x_post}, /* %N */
173 {mdoc__x_pre, mdoc__x_post}, /* %O */
174 {mdoc__x_pre, mdoc__x_post}, /* %P */
175 {mdoc__x_pre, mdoc__x_post}, /* %R */
176 {mdoc__x_pre, mdoc__x_post}, /* %T */
177 {mdoc__x_pre, mdoc__x_post}, /* %V */
178 {NULL, NULL}, /* Ac */
179 {mdoc_quote_pre, mdoc_quote_post}, /* Ao */
180 {mdoc_quote_pre, mdoc_quote_post}, /* Aq */
181 {NULL, NULL}, /* At */
182 {NULL, NULL}, /* Bc */
183 {mdoc_bf_pre, NULL}, /* Bf */
184 {mdoc_quote_pre, mdoc_quote_post}, /* Bo */
185 {mdoc_quote_pre, mdoc_quote_post}, /* Bq */
186 {mdoc_xx_pre, NULL}, /* Bsx */
187 {mdoc_bx_pre, NULL}, /* Bx */
188 {NULL, NULL}, /* Db */
189 {NULL, NULL}, /* Dc */
190 {mdoc_quote_pre, mdoc_quote_post}, /* Do */
191 {mdoc_quote_pre, mdoc_quote_post}, /* Dq */
192 {NULL, NULL}, /* Ec */ /* FIXME: no space */
193 {NULL, NULL}, /* Ef */
194 {mdoc_em_pre, NULL}, /* Em */
195 {mdoc_quote_pre, mdoc_quote_post}, /* Eo */
196 {mdoc_xx_pre, NULL}, /* Fx */
197 {mdoc_ms_pre, NULL}, /* Ms */
198 {mdoc_igndelim_pre, NULL}, /* No */
199 {mdoc_ns_pre, NULL}, /* Ns */
200 {mdoc_xx_pre, NULL}, /* Nx */
201 {mdoc_xx_pre, NULL}, /* Ox */
202 {NULL, NULL}, /* Pc */
203 {mdoc_igndelim_pre, mdoc_pf_post}, /* Pf */
204 {mdoc_quote_pre, mdoc_quote_post}, /* Po */
205 {mdoc_quote_pre, mdoc_quote_post}, /* Pq */
206 {NULL, NULL}, /* Qc */
207 {mdoc_quote_pre, mdoc_quote_post}, /* Ql */
208 {mdoc_quote_pre, mdoc_quote_post}, /* Qo */
209 {mdoc_quote_pre, mdoc_quote_post}, /* Qq */
210 {NULL, NULL}, /* Re */
211 {mdoc_rs_pre, NULL}, /* Rs */
212 {NULL, NULL}, /* Sc */
213 {mdoc_quote_pre, mdoc_quote_post}, /* So */
214 {mdoc_quote_pre, mdoc_quote_post}, /* Sq */
215 {mdoc_sm_pre, NULL}, /* Sm */
216 {mdoc_sx_pre, NULL}, /* Sx */
217 {mdoc_sy_pre, NULL}, /* Sy */
218 {NULL, NULL}, /* Tn */
219 {mdoc_xx_pre, NULL}, /* Ux */
220 {NULL, NULL}, /* Xc */
221 {NULL, NULL}, /* Xo */
222 {mdoc_fo_pre, mdoc_fo_post}, /* Fo */
223 {NULL, NULL}, /* Fc */
224 {mdoc_quote_pre, mdoc_quote_post}, /* Oo */
225 {NULL, NULL}, /* Oc */
226 {mdoc_bk_pre, mdoc_bk_post}, /* Bk */
227 {NULL, NULL}, /* Ek */
228 {mdoc_bt_pre, NULL}, /* Bt */
229 {NULL, NULL}, /* Hf */
230 {mdoc_em_pre, NULL}, /* Fr */
231 {mdoc_ud_pre, NULL}, /* Ud */
232 {mdoc_lb_pre, NULL}, /* Lb */
233 {mdoc_pp_pre, NULL}, /* Lp */
234 {mdoc_lk_pre, NULL}, /* Lk */
235 {mdoc_mt_pre, NULL}, /* Mt */
236 {mdoc_quote_pre, mdoc_quote_post}, /* Brq */
237 {mdoc_quote_pre, mdoc_quote_post}, /* Bro */
238 {NULL, NULL}, /* Brc */
239 {mdoc__x_pre, mdoc__x_post}, /* %C */
240 {mdoc_skip_pre, NULL}, /* Es */
241 {mdoc_quote_pre, mdoc_quote_post}, /* En */
242 {mdoc_xx_pre, NULL}, /* Dx */
243 {mdoc__x_pre, mdoc__x_post}, /* %Q */
244 {mdoc_sp_pre, NULL}, /* br */
245 {mdoc_sp_pre, NULL}, /* sp */
246 {mdoc__x_pre, mdoc__x_post}, /* %U */
247 {NULL, NULL}, /* Ta */
248 {mdoc_skip_pre, NULL}, /* ll */
251 static const char * const lists[LIST_MAX] = {
268 html_mdoc(void *arg, const struct mdoc *mdoc)
271 print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc),
277 * Calculate the scaling unit passed in a `-width' argument. This uses
278 * either a native scaling unit (e.g., 1i, 2m) or the string length of
282 a2width(const char *p, struct roffsu *su)
285 if ( ! a2roffsu(p, su, SCALE_MAX)) {
287 su->scale = html_strlen(p);
292 * See the same function in mdoc_term.c for documentation.
295 synopsis_pre(struct html *h, const struct mdoc_node *n)
298 if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
301 if (n->prev->tok == n->tok &&
305 print_otag(h, TAG_BR, 0, NULL);
309 switch (n->prev->tok) {
319 print_otag(h, TAG_P, 0, NULL);
322 if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
323 print_otag(h, TAG_P, 0, NULL);
328 print_otag(h, TAG_BR, 0, NULL);
334 * Calculate the scaling unit passed in an `-offset' argument. This
335 * uses either a native scaling unit (e.g., 1i, 2m), one of a set of
336 * predefined strings (indent, etc.), or the string length of the value.
339 a2offs(const char *p, struct roffsu *su)
342 /* FIXME: "right"? */
344 if (0 == strcmp(p, "left"))
345 SCALE_HS_INIT(su, 0);
346 else if (0 == strcmp(p, "indent"))
347 SCALE_HS_INIT(su, INDENT);
348 else if (0 == strcmp(p, "indent-two"))
349 SCALE_HS_INIT(su, INDENT * 2);
350 else if ( ! a2roffsu(p, su, SCALE_MAX))
351 SCALE_HS_INIT(su, html_strlen(p));
355 print_mdoc(MDOC_ARGS)
360 PAIR_CLASS_INIT(&tag, "mandoc");
362 if ( ! (HTML_FRAGMENT & h->oflags)) {
364 t = print_otag(h, TAG_HTML, 0, NULL);
365 tt = print_otag(h, TAG_HEAD, 0, NULL);
366 print_mdoc_head(meta, n, h);
368 print_otag(h, TAG_BODY, 0, NULL);
369 print_otag(h, TAG_DIV, 1, &tag);
371 t = print_otag(h, TAG_DIV, 1, &tag);
373 print_mdoc_nodelist(meta, n, h);
378 print_mdoc_head(MDOC_ARGS)
383 bufcat(h, meta->title);
385 bufcat_fmt(h, "(%s)", meta->msec);
387 bufcat_fmt(h, " (%s)", meta->arch);
389 print_otag(h, TAG_TITLE, 0, NULL);
390 print_text(h, h->buf);
394 print_mdoc_nodelist(MDOC_ARGS)
397 print_mdoc_node(meta, n, h);
399 print_mdoc_nodelist(meta, n->next, h);
403 print_mdoc_node(MDOC_ARGS)
413 child = mdoc_root_pre(meta, n, h);
416 /* No tables in this mode... */
417 assert(NULL == h->tblt);
420 * Make sure that if we're in a literal mode already
421 * (i.e., within a <PRE>) don't print the newline.
423 if (' ' == *n->string && MDOC_LINE & n->flags)
424 if ( ! (HTML_LITERAL & h->flags))
425 print_otag(h, TAG_BR, 0, NULL);
426 if (MDOC_DELIMC & n->flags)
427 h->flags |= HTML_NOSPACE;
428 print_text(h, n->string);
429 if (MDOC_DELIMO & n->flags)
430 h->flags |= HTML_NOSPACE;
433 print_eqn(h, n->eqn);
437 * This will take care of initialising all of the table
438 * state data for the first table, then tearing it down
441 print_tbl(h, n->span);
445 * Close out the current table, if it's open, and unset
446 * the "meta" table state. This will be reopened on the
447 * next table element.
454 assert(NULL == h->tblt);
455 if (mdocs[n->tok].pre && ENDBODY_NOT == n->end)
456 child = (*mdocs[n->tok].pre)(meta, n, h);
460 if (HTML_KEEP & h->flags) {
461 if (n->prev ? (n->prev->lastline != n->line) :
462 (n->parent && n->parent->line != n->line)) {
463 h->flags &= ~HTML_KEEP;
464 h->flags |= HTML_PREKEEP;
468 if (child && n->child)
469 print_mdoc_nodelist(meta, n->child, h);
475 mdoc_root_post(meta, n, h);
480 if (mdocs[n->tok].post && ENDBODY_NOT == n->end)
481 (*mdocs[n->tok].post)(meta, n, h);
487 mdoc_root_post(MDOC_ARGS)
489 struct htmlpair tag[3];
492 PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
493 PAIR_CLASS_INIT(&tag[1], "foot");
494 PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
495 t = print_otag(h, TAG_TABLE, 3, tag);
496 PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
497 print_otag(h, TAG_COL, 1, tag);
498 print_otag(h, TAG_COL, 1, tag);
500 print_otag(h, TAG_TBODY, 0, NULL);
502 tt = print_otag(h, TAG_TR, 0, NULL);
504 PAIR_CLASS_INIT(&tag[0], "foot-date");
505 print_otag(h, TAG_TD, 1, tag);
506 print_text(h, meta->date);
509 PAIR_CLASS_INIT(&tag[0], "foot-os");
510 PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
511 print_otag(h, TAG_TD, 2, tag);
512 print_text(h, meta->os);
517 mdoc_root_pre(MDOC_ARGS)
519 struct htmlpair tag[3];
521 char *volume, *title;
523 if (NULL == meta->arch)
524 volume = mandoc_strdup(meta->vol);
526 mandoc_asprintf(&volume, "%s (%s)",
527 meta->vol, meta->arch);
529 if (NULL == meta->msec)
530 title = mandoc_strdup(meta->title);
532 mandoc_asprintf(&title, "%s(%s)",
533 meta->title, meta->msec);
535 PAIR_SUMMARY_INIT(&tag[0], "Document Header");
536 PAIR_CLASS_INIT(&tag[1], "head");
537 PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
538 t = print_otag(h, TAG_TABLE, 3, tag);
539 PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
540 print_otag(h, TAG_COL, 1, tag);
541 print_otag(h, TAG_COL, 1, tag);
542 print_otag(h, TAG_COL, 1, tag);
544 print_otag(h, TAG_TBODY, 0, NULL);
546 tt = print_otag(h, TAG_TR, 0, NULL);
548 PAIR_CLASS_INIT(&tag[0], "head-ltitle");
549 print_otag(h, TAG_TD, 1, tag);
550 print_text(h, title);
553 PAIR_CLASS_INIT(&tag[0], "head-vol");
554 PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
555 print_otag(h, TAG_TD, 2, tag);
556 print_text(h, volume);
559 PAIR_CLASS_INIT(&tag[0], "head-rtitle");
560 PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
561 print_otag(h, TAG_TD, 2, tag);
562 print_text(h, title);
571 mdoc_sh_pre(MDOC_ARGS)
575 if (MDOC_BLOCK == n->type) {
576 PAIR_CLASS_INIT(&tag, "section");
577 print_otag(h, TAG_DIV, 1, &tag);
579 } else if (MDOC_BODY == n->type)
585 for (n = n->child; n && MDOC_TEXT == n->type; ) {
586 bufcat_id(h, n->string);
587 if (NULL != (n = n->next))
592 PAIR_ID_INIT(&tag, h->buf);
593 print_otag(h, TAG_H1, 1, &tag);
595 print_otag(h, TAG_H1, 0, NULL);
601 mdoc_ss_pre(MDOC_ARGS)
605 if (MDOC_BLOCK == n->type) {
606 PAIR_CLASS_INIT(&tag, "subsection");
607 print_otag(h, TAG_DIV, 1, &tag);
609 } else if (MDOC_BODY == n->type)
615 for (n = n->child; n && MDOC_TEXT == n->type; ) {
616 bufcat_id(h, n->string);
617 if (NULL != (n = n->next))
622 PAIR_ID_INIT(&tag, h->buf);
623 print_otag(h, TAG_H2, 1, &tag);
625 print_otag(h, TAG_H2, 0, NULL);
631 mdoc_fl_pre(MDOC_ARGS)
635 PAIR_CLASS_INIT(&tag, "flag");
636 print_otag(h, TAG_B, 1, &tag);
638 /* `Cm' has no leading hyphen. */
640 if (MDOC_Cm == n->tok)
643 print_text(h, "\\-");
646 h->flags |= HTML_NOSPACE;
647 else if (n->next && n->next->line == n->line)
648 h->flags |= HTML_NOSPACE;
654 mdoc_nd_pre(MDOC_ARGS)
658 if (MDOC_BODY != n->type)
661 /* XXX: this tag in theory can contain block elements. */
663 print_text(h, "\\(em");
664 PAIR_CLASS_INIT(&tag, "desc");
665 print_otag(h, TAG_SPAN, 1, &tag);
670 mdoc_nm_pre(MDOC_ARGS)
679 PAIR_CLASS_INIT(&tag, "name");
680 print_otag(h, TAG_B, 1, &tag);
681 if (NULL == n->child && meta->name)
682 print_text(h, meta->name);
685 print_otag(h, TAG_TD, 0, NULL);
686 if (NULL == n->child && meta->name)
687 print_text(h, meta->name);
690 print_otag(h, TAG_TD, 0, NULL);
697 PAIR_CLASS_INIT(&tag, "synopsis");
698 print_otag(h, TAG_TABLE, 1, &tag);
700 for (len = 0, n = n->child; n; n = n->next)
701 if (MDOC_TEXT == n->type)
702 len += html_strlen(n->string);
704 if (0 == len && meta->name)
705 len = html_strlen(meta->name);
707 SCALE_HS_INIT(&su, len);
709 bufcat_su(h, "width", &su);
710 PAIR_STYLE_INIT(&tag, h);
711 print_otag(h, TAG_COL, 1, &tag);
712 print_otag(h, TAG_COL, 0, NULL);
713 print_otag(h, TAG_TBODY, 0, NULL);
714 print_otag(h, TAG_TR, 0, NULL);
719 mdoc_xr_pre(MDOC_ARGS)
721 struct htmlpair tag[2];
723 if (NULL == n->child)
726 PAIR_CLASS_INIT(&tag[0], "link-man");
729 buffmt_man(h, n->child->string,
731 n->child->next->string : NULL);
732 PAIR_HREF_INIT(&tag[1], h->buf);
733 print_otag(h, TAG_A, 2, tag);
735 print_otag(h, TAG_A, 1, tag);
738 print_text(h, n->string);
740 if (NULL == (n = n->next))
743 h->flags |= HTML_NOSPACE;
745 h->flags |= HTML_NOSPACE;
746 print_text(h, n->string);
747 h->flags |= HTML_NOSPACE;
753 mdoc_ns_pre(MDOC_ARGS)
756 if ( ! (MDOC_LINE & n->flags))
757 h->flags |= HTML_NOSPACE;
762 mdoc_ar_pre(MDOC_ARGS)
766 PAIR_CLASS_INIT(&tag, "arg");
767 print_otag(h, TAG_I, 1, &tag);
772 mdoc_xx_pre(MDOC_ARGS)
801 PAIR_CLASS_INIT(&tag, "unix");
802 print_otag(h, TAG_SPAN, 1, &tag);
807 h->flags |= HTML_KEEP;
808 print_text(h, n->child->string);
815 mdoc_bx_pre(MDOC_ARGS)
819 PAIR_CLASS_INIT(&tag, "unix");
820 print_otag(h, TAG_SPAN, 1, &tag);
822 if (NULL != (n = n->child)) {
823 print_text(h, n->string);
824 h->flags |= HTML_NOSPACE;
825 print_text(h, "BSD");
827 print_text(h, "BSD");
831 if (NULL != (n = n->next)) {
832 h->flags |= HTML_NOSPACE;
834 h->flags |= HTML_NOSPACE;
835 print_text(h, n->string);
842 mdoc_it_pre(MDOC_ARGS)
846 struct htmlpair tag[2];
847 const struct mdoc_node *bl;
850 while (bl && MDOC_Bl != bl->tok)
855 type = bl->norm->Bl.type;
858 PAIR_CLASS_INIT(&tag[0], lists[type]);
862 if (MDOC_HEAD == n->type) {
883 SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
884 bufcat_su(h, "margin-top", &su);
885 PAIR_STYLE_INIT(&tag[1], h);
886 print_otag(h, TAG_DT, 2, tag);
887 if (LIST_diag != type)
889 PAIR_CLASS_INIT(&tag[0], "diag");
890 print_otag(h, TAG_B, 1, tag);
897 } else if (MDOC_BODY == n->type) {
908 SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
909 bufcat_su(h, "margin-top", &su);
910 PAIR_STYLE_INIT(&tag[1], h);
911 print_otag(h, TAG_LI, 2, tag);
922 if (NULL == bl->norm->Bl.width) {
923 print_otag(h, TAG_DD, 1, tag);
926 a2width(bl->norm->Bl.width, &su);
927 bufcat_su(h, "margin-left", &su);
928 PAIR_STYLE_INIT(&tag[1], h);
929 print_otag(h, TAG_DD, 2, tag);
932 SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
933 bufcat_su(h, "margin-top", &su);
934 PAIR_STYLE_INIT(&tag[1], h);
935 print_otag(h, TAG_TD, 2, tag);
943 print_otag(h, TAG_TR, 1, tag);
954 mdoc_bl_pre(MDOC_ARGS)
957 struct htmlpair tag[3];
961 if (MDOC_BODY == n->type) {
962 if (LIST_column == n->norm->Bl.type)
963 print_otag(h, TAG_TBODY, 0, NULL);
967 if (MDOC_HEAD == n->type) {
968 if (LIST_column != n->norm->Bl.type)
972 * For each column, print out the <COL> tag with our
973 * suggested width. The last column gets min-width, as
974 * in terminal mode it auto-sizes to the width of the
975 * screen and we want to preserve that behaviour.
978 for (i = 0; i < (int)n->norm->Bl.ncols; i++) {
980 a2width(n->norm->Bl.cols[i], &su);
981 if (i < (int)n->norm->Bl.ncols - 1)
982 bufcat_su(h, "width", &su);
984 bufcat_su(h, "min-width", &su);
985 PAIR_STYLE_INIT(&tag[0], h);
986 print_otag(h, TAG_COL, 1, tag);
992 SCALE_VS_INIT(&su, 0);
994 bufcat_su(h, "margin-top", &su);
995 bufcat_su(h, "margin-bottom", &su);
996 PAIR_STYLE_INIT(&tag[0], h);
998 assert(lists[n->norm->Bl.type]);
999 (void)strlcpy(buf, "list ", BUFSIZ);
1000 (void)strlcat(buf, lists[n->norm->Bl.type], BUFSIZ);
1001 PAIR_INIT(&tag[1], ATTR_CLASS, buf);
1003 /* Set the block's left-hand margin. */
1005 if (n->norm->Bl.offs) {
1006 a2offs(n->norm->Bl.offs, &su);
1007 bufcat_su(h, "margin-left", &su);
1010 switch (n->norm->Bl.type) {
1018 print_otag(h, TAG_UL, 2, tag);
1021 print_otag(h, TAG_OL, 2, tag);
1032 print_otag(h, TAG_DL, 2, tag);
1035 print_otag(h, TAG_TABLE, 2, tag);
1046 mdoc_ex_pre(MDOC_ARGS)
1049 struct htmlpair tag;
1053 print_otag(h, TAG_BR, 0, NULL);
1055 PAIR_CLASS_INIT(&tag, "utility");
1057 print_text(h, "The");
1060 for (n = n->child; n; n = n->next) {
1061 assert(MDOC_TEXT == n->type);
1063 t = print_otag(h, TAG_B, 1, &tag);
1064 print_text(h, n->string);
1067 if (nchild > 2 && n->next) {
1068 h->flags |= HTML_NOSPACE;
1072 if (n->next && NULL == n->next->next)
1073 print_text(h, "and");
1077 print_text(h, "utilities exit\\~0");
1079 print_text(h, "utility exits\\~0");
1081 print_text(h, "on success, and\\~>0 if an error occurs.");
1086 mdoc_em_pre(MDOC_ARGS)
1088 struct htmlpair tag;
1090 PAIR_CLASS_INIT(&tag, "emph");
1091 print_otag(h, TAG_SPAN, 1, &tag);
1096 mdoc_d1_pre(MDOC_ARGS)
1098 struct htmlpair tag[2];
1101 if (MDOC_BLOCK != n->type)
1104 SCALE_VS_INIT(&su, 0);
1106 bufcat_su(h, "margin-top", &su);
1107 bufcat_su(h, "margin-bottom", &su);
1108 PAIR_STYLE_INIT(&tag[0], h);
1109 print_otag(h, TAG_BLOCKQUOTE, 1, tag);
1111 /* BLOCKQUOTE needs a block body. */
1113 PAIR_CLASS_INIT(&tag[0], "display");
1114 print_otag(h, TAG_DIV, 1, tag);
1116 if (MDOC_Dl == n->tok) {
1117 PAIR_CLASS_INIT(&tag[0], "lit");
1118 print_otag(h, TAG_CODE, 1, tag);
1125 mdoc_sx_pre(MDOC_ARGS)
1127 struct htmlpair tag[2];
1132 for (n = n->child; n; ) {
1133 bufcat_id(h, n->string);
1134 if (NULL != (n = n->next))
1138 PAIR_CLASS_INIT(&tag[0], "link-sec");
1139 PAIR_HREF_INIT(&tag[1], h->buf);
1141 print_otag(h, TAG_I, 1, tag);
1142 print_otag(h, TAG_A, 2, tag);
1147 mdoc_bd_pre(MDOC_ARGS)
1149 struct htmlpair tag[2];
1151 const struct mdoc_node *nn;
1154 if (MDOC_HEAD == n->type)
1157 if (MDOC_BLOCK == n->type) {
1158 comp = n->norm->Bd.comp;
1159 for (nn = n; nn && ! comp; nn = nn->parent) {
1160 if (MDOC_BLOCK != nn->type)
1162 if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
1168 print_otag(h, TAG_P, 0, NULL);
1172 SCALE_HS_INIT(&su, 0);
1173 if (n->norm->Bd.offs)
1174 a2offs(n->norm->Bd.offs, &su);
1177 bufcat_su(h, "margin-left", &su);
1178 PAIR_STYLE_INIT(&tag[0], h);
1180 if (DISP_unfilled != n->norm->Bd.type &&
1181 DISP_literal != n->norm->Bd.type) {
1182 PAIR_CLASS_INIT(&tag[1], "display");
1183 print_otag(h, TAG_DIV, 2, tag);
1187 PAIR_CLASS_INIT(&tag[1], "lit display");
1188 print_otag(h, TAG_PRE, 2, tag);
1190 /* This can be recursive: save & set our literal state. */
1192 sv = h->flags & HTML_LITERAL;
1193 h->flags |= HTML_LITERAL;
1195 for (nn = n->child; nn; nn = nn->next) {
1196 print_mdoc_node(meta, nn, h);
1198 * If the printed node flushes its own line, then we
1199 * needn't do it here as well. This is hacky, but the
1200 * notion of selective eoln whitespace is pretty dumb
1201 * anyway, so don't sweat it.
1223 if (nn->next && nn->next->line == nn->line)
1226 print_text(h, "\n");
1228 h->flags |= HTML_NOSPACE;
1232 h->flags &= ~HTML_LITERAL;
1238 mdoc_pa_pre(MDOC_ARGS)
1240 struct htmlpair tag;
1242 PAIR_CLASS_INIT(&tag, "file");
1243 print_otag(h, TAG_I, 1, &tag);
1248 mdoc_ad_pre(MDOC_ARGS)
1250 struct htmlpair tag;
1252 PAIR_CLASS_INIT(&tag, "addr");
1253 print_otag(h, TAG_I, 1, &tag);
1258 mdoc_an_pre(MDOC_ARGS)
1260 struct htmlpair tag;
1262 /* TODO: -split and -nosplit (see termp_an_pre()). */
1264 PAIR_CLASS_INIT(&tag, "author");
1265 print_otag(h, TAG_SPAN, 1, &tag);
1270 mdoc_cd_pre(MDOC_ARGS)
1272 struct htmlpair tag;
1275 PAIR_CLASS_INIT(&tag, "config");
1276 print_otag(h, TAG_B, 1, &tag);
1281 mdoc_dv_pre(MDOC_ARGS)
1283 struct htmlpair tag;
1285 PAIR_CLASS_INIT(&tag, "define");
1286 print_otag(h, TAG_SPAN, 1, &tag);
1291 mdoc_ev_pre(MDOC_ARGS)
1293 struct htmlpair tag;
1295 PAIR_CLASS_INIT(&tag, "env");
1296 print_otag(h, TAG_SPAN, 1, &tag);
1301 mdoc_er_pre(MDOC_ARGS)
1303 struct htmlpair tag;
1305 PAIR_CLASS_INIT(&tag, "errno");
1306 print_otag(h, TAG_SPAN, 1, &tag);
1311 mdoc_fa_pre(MDOC_ARGS)
1313 const struct mdoc_node *nn;
1314 struct htmlpair tag;
1317 PAIR_CLASS_INIT(&tag, "farg");
1318 if (n->parent->tok != MDOC_Fo) {
1319 print_otag(h, TAG_I, 1, &tag);
1323 for (nn = n->child; nn; nn = nn->next) {
1324 t = print_otag(h, TAG_I, 1, &tag);
1325 print_text(h, nn->string);
1328 h->flags |= HTML_NOSPACE;
1333 if (n->child && n->next && n->next->tok == MDOC_Fa) {
1334 h->flags |= HTML_NOSPACE;
1342 mdoc_fd_pre(MDOC_ARGS)
1344 struct htmlpair tag[2];
1352 if (NULL == (n = n->child))
1355 assert(MDOC_TEXT == n->type);
1357 if (strcmp(n->string, "#include")) {
1358 PAIR_CLASS_INIT(&tag[0], "macro");
1359 print_otag(h, TAG_B, 1, tag);
1363 PAIR_CLASS_INIT(&tag[0], "includes");
1364 print_otag(h, TAG_B, 1, tag);
1365 print_text(h, n->string);
1367 if (NULL != (n = n->next)) {
1368 assert(MDOC_TEXT == n->type);
1371 * XXX This is broken and not easy to fix.
1372 * When using -Oincludes, truncation may occur.
1373 * Dynamic allocation wouldn't help because
1374 * passing long strings to buffmt_includes()
1375 * does not work either.
1378 strlcpy(buf, '<' == *n->string || '"' == *n->string ?
1379 n->string + 1 : n->string, BUFSIZ);
1382 if (sz && ('>' == buf[sz - 1] || '"' == buf[sz - 1]))
1385 PAIR_CLASS_INIT(&tag[0], "link-includes");
1388 if (h->base_includes) {
1389 buffmt_includes(h, buf);
1390 PAIR_HREF_INIT(&tag[i], h->buf);
1394 t = print_otag(h, TAG_A, i, tag);
1395 print_text(h, n->string);
1401 for ( ; n; n = n->next) {
1402 assert(MDOC_TEXT == n->type);
1403 print_text(h, n->string);
1410 mdoc_vt_pre(MDOC_ARGS)
1412 struct htmlpair tag;
1414 if (MDOC_BLOCK == n->type) {
1417 } else if (MDOC_ELEM == n->type) {
1419 } else if (MDOC_HEAD == n->type)
1422 PAIR_CLASS_INIT(&tag, "type");
1423 print_otag(h, TAG_SPAN, 1, &tag);
1428 mdoc_ft_pre(MDOC_ARGS)
1430 struct htmlpair tag;
1433 PAIR_CLASS_INIT(&tag, "ftype");
1434 print_otag(h, TAG_I, 1, &tag);
1439 mdoc_fn_pre(MDOC_ARGS)
1442 struct htmlpair tag[2];
1444 const char *sp, *ep;
1447 pretty = MDOC_SYNPRETTY & n->flags;
1450 /* Split apart into type and name. */
1451 assert(n->child->string);
1452 sp = n->child->string;
1454 ep = strchr(sp, ' ');
1456 PAIR_CLASS_INIT(&tag[0], "ftype");
1457 t = print_otag(h, TAG_I, 1, tag);
1460 sz = MIN((int)(ep - sp), BUFSIZ - 1);
1461 (void)memcpy(nbuf, sp, (size_t)sz);
1463 print_text(h, nbuf);
1465 ep = strchr(sp, ' ');
1470 PAIR_CLASS_INIT(&tag[0], "fname");
1473 * FIXME: only refer to IDs that we know exist.
1477 if (MDOC_SYNPRETTY & n->flags) {
1479 html_idcat(nbuf, sp, BUFSIZ);
1480 PAIR_ID_INIT(&tag[1], nbuf);
1482 strlcpy(nbuf, "#", BUFSIZ);
1483 html_idcat(nbuf, sp, BUFSIZ);
1484 PAIR_HREF_INIT(&tag[1], nbuf);
1488 t = print_otag(h, TAG_B, 1, tag);
1495 h->flags |= HTML_NOSPACE;
1497 h->flags |= HTML_NOSPACE;
1499 PAIR_CLASS_INIT(&tag[0], "farg");
1501 bufcat_style(h, "white-space", "nowrap");
1502 PAIR_STYLE_INIT(&tag[1], h);
1504 for (n = n->child->next; n; n = n->next) {
1506 if (MDOC_SYNPRETTY & n->flags)
1508 t = print_otag(h, TAG_I, i, tag);
1509 print_text(h, n->string);
1512 h->flags |= HTML_NOSPACE;
1517 h->flags |= HTML_NOSPACE;
1521 h->flags |= HTML_NOSPACE;
1529 mdoc_sm_pre(MDOC_ARGS)
1532 if (NULL == n->child)
1533 h->flags ^= HTML_NONOSPACE;
1534 else if (0 == strcmp("on", n->child->string))
1535 h->flags &= ~HTML_NONOSPACE;
1537 h->flags |= HTML_NONOSPACE;
1539 if ( ! (HTML_NONOSPACE & h->flags))
1540 h->flags &= ~HTML_NOSPACE;
1546 mdoc_skip_pre(MDOC_ARGS)
1553 mdoc_pp_pre(MDOC_ARGS)
1556 print_otag(h, TAG_P, 0, NULL);
1561 mdoc_sp_pre(MDOC_ARGS)
1564 struct htmlpair tag;
1566 SCALE_VS_INIT(&su, 1);
1568 if (MDOC_sp == n->tok) {
1569 if (NULL != (n = n->child))
1570 if ( ! a2roffsu(n->string, &su, SCALE_VS))
1571 SCALE_VS_INIT(&su, atoi(n->string));
1576 bufcat_su(h, "height", &su);
1577 PAIR_STYLE_INIT(&tag, h);
1578 print_otag(h, TAG_DIV, 1, &tag);
1580 /* So the div isn't empty: */
1581 print_text(h, "\\~");
1588 mdoc_lk_pre(MDOC_ARGS)
1590 struct htmlpair tag[2];
1592 if (NULL == (n = n->child))
1595 assert(MDOC_TEXT == n->type);
1597 PAIR_CLASS_INIT(&tag[0], "link-ext");
1598 PAIR_HREF_INIT(&tag[1], n->string);
1600 print_otag(h, TAG_A, 2, tag);
1602 if (NULL == n->next)
1603 print_text(h, n->string);
1605 for (n = n->next; n; n = n->next)
1606 print_text(h, n->string);
1612 mdoc_mt_pre(MDOC_ARGS)
1614 struct htmlpair tag[2];
1617 PAIR_CLASS_INIT(&tag[0], "link-mail");
1619 for (n = n->child; n; n = n->next) {
1620 assert(MDOC_TEXT == n->type);
1623 bufcat(h, "mailto:");
1624 bufcat(h, n->string);
1626 PAIR_HREF_INIT(&tag[1], h->buf);
1627 t = print_otag(h, TAG_A, 2, tag);
1628 print_text(h, n->string);
1636 mdoc_fo_pre(MDOC_ARGS)
1638 struct htmlpair tag;
1641 if (MDOC_BODY == n->type) {
1642 h->flags |= HTML_NOSPACE;
1644 h->flags |= HTML_NOSPACE;
1646 } else if (MDOC_BLOCK == n->type) {
1651 /* XXX: we drop non-initial arguments as per groff. */
1654 assert(n->child->string);
1656 PAIR_CLASS_INIT(&tag, "fname");
1657 t = print_otag(h, TAG_B, 1, &tag);
1658 print_text(h, n->child->string);
1664 mdoc_fo_post(MDOC_ARGS)
1667 if (MDOC_BODY != n->type)
1669 h->flags |= HTML_NOSPACE;
1671 h->flags |= HTML_NOSPACE;
1676 mdoc_in_pre(MDOC_ARGS)
1679 struct htmlpair tag[2];
1684 PAIR_CLASS_INIT(&tag[0], "includes");
1685 print_otag(h, TAG_B, 1, tag);
1688 * The first argument of the `In' gets special treatment as
1689 * being a linked value. Subsequent values are printed
1690 * afterward. groff does similarly. This also handles the case
1694 if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags)
1695 print_text(h, "#include");
1698 h->flags |= HTML_NOSPACE;
1700 if (NULL != (n = n->child)) {
1701 assert(MDOC_TEXT == n->type);
1703 PAIR_CLASS_INIT(&tag[0], "link-includes");
1706 if (h->base_includes) {
1707 buffmt_includes(h, n->string);
1708 PAIR_HREF_INIT(&tag[i], h->buf);
1712 t = print_otag(h, TAG_A, i, tag);
1713 print_text(h, n->string);
1719 h->flags |= HTML_NOSPACE;
1722 for ( ; n; n = n->next) {
1723 assert(MDOC_TEXT == n->type);
1724 print_text(h, n->string);
1731 mdoc_ic_pre(MDOC_ARGS)
1733 struct htmlpair tag;
1735 PAIR_CLASS_INIT(&tag, "cmd");
1736 print_otag(h, TAG_B, 1, &tag);
1741 mdoc_rv_pre(MDOC_ARGS)
1743 struct htmlpair tag;
1748 print_otag(h, TAG_BR, 0, NULL);
1750 PAIR_CLASS_INIT(&tag, "fname");
1754 print_text(h, "The");
1756 for (n = n->child; n; n = n->next) {
1757 t = print_otag(h, TAG_B, 1, &tag);
1758 print_text(h, n->string);
1761 h->flags |= HTML_NOSPACE;
1762 print_text(h, "()");
1764 if (n->next == NULL)
1768 h->flags |= HTML_NOSPACE;
1771 if (n->next->next == NULL)
1772 print_text(h, "and");
1776 print_text(h, "functions return");
1778 print_text(h, "function returns");
1780 print_text(h, "the value\\~0 if successful;");
1782 print_text(h, "Upon successful completion,"
1783 " the value\\~0 is returned;");
1785 print_text(h, "otherwise the value\\~\\-1 is returned"
1786 " and the global variable");
1788 PAIR_CLASS_INIT(&tag, "var");
1789 t = print_otag(h, TAG_B, 1, &tag);
1790 print_text(h, "errno");
1792 print_text(h, "is set to indicate the error.");
1797 mdoc_va_pre(MDOC_ARGS)
1799 struct htmlpair tag;
1801 PAIR_CLASS_INIT(&tag, "var");
1802 print_otag(h, TAG_B, 1, &tag);
1807 mdoc_ap_pre(MDOC_ARGS)
1810 h->flags |= HTML_NOSPACE;
1811 print_text(h, "\\(aq");
1812 h->flags |= HTML_NOSPACE;
1817 mdoc_bf_pre(MDOC_ARGS)
1819 struct htmlpair tag[2];
1822 if (MDOC_HEAD == n->type)
1824 else if (MDOC_BODY != n->type)
1827 if (FONT_Em == n->norm->Bf.font)
1828 PAIR_CLASS_INIT(&tag[0], "emph");
1829 else if (FONT_Sy == n->norm->Bf.font)
1830 PAIR_CLASS_INIT(&tag[0], "symb");
1831 else if (FONT_Li == n->norm->Bf.font)
1832 PAIR_CLASS_INIT(&tag[0], "lit");
1834 PAIR_CLASS_INIT(&tag[0], "none");
1837 * We want this to be inline-formatted, but needs to be div to
1838 * accept block children.
1841 bufcat_style(h, "display", "inline");
1842 SCALE_HS_INIT(&su, 1);
1843 /* Needs a left-margin for spacing. */
1844 bufcat_su(h, "margin-left", &su);
1845 PAIR_STYLE_INIT(&tag[1], h);
1846 print_otag(h, TAG_DIV, 2, tag);
1851 mdoc_ms_pre(MDOC_ARGS)
1853 struct htmlpair tag;
1855 PAIR_CLASS_INIT(&tag, "symb");
1856 print_otag(h, TAG_SPAN, 1, &tag);
1861 mdoc_igndelim_pre(MDOC_ARGS)
1864 h->flags |= HTML_IGNDELIM;
1869 mdoc_pf_post(MDOC_ARGS)
1872 h->flags |= HTML_NOSPACE;
1876 mdoc_rs_pre(MDOC_ARGS)
1878 struct htmlpair tag;
1880 if (MDOC_BLOCK != n->type)
1883 if (n->prev && SEC_SEE_ALSO == n->sec)
1884 print_otag(h, TAG_P, 0, NULL);
1886 PAIR_CLASS_INIT(&tag, "ref");
1887 print_otag(h, TAG_SPAN, 1, &tag);
1892 mdoc_li_pre(MDOC_ARGS)
1894 struct htmlpair tag;
1896 PAIR_CLASS_INIT(&tag, "lit");
1897 print_otag(h, TAG_CODE, 1, &tag);
1902 mdoc_sy_pre(MDOC_ARGS)
1904 struct htmlpair tag;
1906 PAIR_CLASS_INIT(&tag, "symb");
1907 print_otag(h, TAG_SPAN, 1, &tag);
1912 mdoc_bt_pre(MDOC_ARGS)
1915 print_text(h, "is currently in beta test.");
1920 mdoc_ud_pre(MDOC_ARGS)
1923 print_text(h, "currently under development.");
1928 mdoc_lb_pre(MDOC_ARGS)
1930 struct htmlpair tag;
1932 if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags && n->prev)
1933 print_otag(h, TAG_BR, 0, NULL);
1935 PAIR_CLASS_INIT(&tag, "lib");
1936 print_otag(h, TAG_SPAN, 1, &tag);
1941 mdoc__x_pre(MDOC_ARGS)
1943 struct htmlpair tag[2];
1950 PAIR_CLASS_INIT(&tag[0], "ref-auth");
1951 if (n->prev && MDOC__A == n->prev->tok)
1952 if (NULL == n->next || MDOC__A != n->next->tok)
1953 print_text(h, "and");
1956 PAIR_CLASS_INIT(&tag[0], "ref-book");
1960 PAIR_CLASS_INIT(&tag[0], "ref-city");
1963 PAIR_CLASS_INIT(&tag[0], "ref-date");
1966 PAIR_CLASS_INIT(&tag[0], "ref-issue");
1970 PAIR_CLASS_INIT(&tag[0], "ref-jrnl");
1974 PAIR_CLASS_INIT(&tag[0], "ref-num");
1977 PAIR_CLASS_INIT(&tag[0], "ref-opt");
1980 PAIR_CLASS_INIT(&tag[0], "ref-page");
1983 PAIR_CLASS_INIT(&tag[0], "ref-corp");
1986 PAIR_CLASS_INIT(&tag[0], "ref-rep");
1989 PAIR_CLASS_INIT(&tag[0], "ref-title");
1992 PAIR_CLASS_INIT(&tag[0], "link-ref");
1995 PAIR_CLASS_INIT(&tag[0], "ref-vol");
2002 if (MDOC__U != n->tok) {
2003 print_otag(h, t, 1, tag);
2007 PAIR_HREF_INIT(&tag[1], n->child->string);
2008 print_otag(h, TAG_A, 2, tag);
2014 mdoc__x_post(MDOC_ARGS)
2017 if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
2018 if (NULL == n->next->next || MDOC__A != n->next->next->tok)
2019 if (NULL == n->prev || MDOC__A != n->prev->tok)
2024 if (NULL == n->parent || MDOC_Rs != n->parent->tok)
2027 h->flags |= HTML_NOSPACE;
2028 print_text(h, n->next ? "," : ".");
2032 mdoc_bk_pre(MDOC_ARGS)
2041 if (n->parent->args || 0 == n->prev->nchild)
2042 h->flags |= HTML_PREKEEP;
2053 mdoc_bk_post(MDOC_ARGS)
2056 if (MDOC_BODY == n->type)
2057 h->flags &= ~(HTML_KEEP | HTML_PREKEEP);
2061 mdoc_quote_pre(MDOC_ARGS)
2063 struct htmlpair tag;
2065 if (MDOC_BODY != n->type)
2072 print_text(h, "\\(la");
2077 print_text(h, "\\(lC");
2082 print_text(h, "\\(lB");
2087 print_text(h, "\\(lB");
2088 h->flags |= HTML_NOSPACE;
2089 PAIR_CLASS_INIT(&tag, "opt");
2090 print_otag(h, TAG_SPAN, 1, &tag);
2093 if (NULL == n->norm->Es ||
2094 NULL == n->norm->Es->child)
2096 print_text(h, n->norm->Es->child->string);
2107 print_text(h, "\\(lq");
2115 print_text(h, "\\(oq");
2116 h->flags |= HTML_NOSPACE;
2117 PAIR_CLASS_INIT(&tag, "lit");
2118 print_otag(h, TAG_CODE, 1, &tag);
2123 print_text(h, "\\(oq");
2130 h->flags |= HTML_NOSPACE;
2135 mdoc_quote_post(MDOC_ARGS)
2138 if (MDOC_BODY != n->type)
2141 if (MDOC_En != n->tok)
2142 h->flags |= HTML_NOSPACE;
2148 print_text(h, "\\(ra");
2153 print_text(h, "\\(rC");
2162 print_text(h, "\\(rB");
2165 if (NULL != n->norm->Es &&
2166 NULL != n->norm->Es->child &&
2167 NULL != n->norm->Es->child->next) {
2168 h->flags |= HTML_NOSPACE;
2169 print_text(h, n->norm->Es->child->next->string);
2181 print_text(h, "\\(rq");
2193 print_text(h, "\\(cq");