]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_html.c
1 /* $Id: mdoc_html.c,v 1.12 2009/09/25 13:00:13 kristaps Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <sys/types.h>
18 #include <sys/param.h>
19 #include <sys/queue.h>
35 #define MDOC_ARGS const struct mdoc_meta *m, \
36 const struct mdoc_node *n, \
38 #define MAN_ARGS const struct man_meta *m, \
39 const struct man_node *n, \
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 int a2width(const char *);
53 static int a2offs(const char *);
54 static int a2list(const struct mdoc_node
*);
56 static void mdoc_root_post(MDOC_ARGS
);
57 static int mdoc_root_pre(MDOC_ARGS
);
58 static int mdoc_tbl_pre(MDOC_ARGS
, int);
59 static int mdoc_tbl_block_pre(MDOC_ARGS
, int, int, int, int);
60 static int mdoc_tbl_body_pre(MDOC_ARGS
, int, int);
61 static int mdoc_tbl_head_pre(MDOC_ARGS
, int, int);
63 static void mdoc__x_post(MDOC_ARGS
);
64 static int mdoc__x_pre(MDOC_ARGS
);
65 static int mdoc_ad_pre(MDOC_ARGS
);
66 static int mdoc_an_pre(MDOC_ARGS
);
67 static int mdoc_ap_pre(MDOC_ARGS
);
68 static void mdoc_aq_post(MDOC_ARGS
);
69 static int mdoc_aq_pre(MDOC_ARGS
);
70 static int mdoc_ar_pre(MDOC_ARGS
);
71 static int mdoc_bd_pre(MDOC_ARGS
);
72 static int mdoc_bf_pre(MDOC_ARGS
);
73 static void mdoc_bl_post(MDOC_ARGS
);
74 static int mdoc_bl_pre(MDOC_ARGS
);
75 static void mdoc_bq_post(MDOC_ARGS
);
76 static int mdoc_bq_pre(MDOC_ARGS
);
77 static void mdoc_brq_post(MDOC_ARGS
);
78 static int mdoc_brq_pre(MDOC_ARGS
);
79 static int mdoc_bt_pre(MDOC_ARGS
);
80 static int mdoc_bx_pre(MDOC_ARGS
);
81 static int mdoc_cd_pre(MDOC_ARGS
);
82 static int mdoc_d1_pre(MDOC_ARGS
);
83 static void mdoc_dq_post(MDOC_ARGS
);
84 static int mdoc_dq_pre(MDOC_ARGS
);
85 static int mdoc_dv_pre(MDOC_ARGS
);
86 static int mdoc_fa_pre(MDOC_ARGS
);
87 static int mdoc_fd_pre(MDOC_ARGS
);
88 static int mdoc_fl_pre(MDOC_ARGS
);
89 static int mdoc_fn_pre(MDOC_ARGS
);
90 static int mdoc_ft_pre(MDOC_ARGS
);
91 static int mdoc_em_pre(MDOC_ARGS
);
92 static int mdoc_er_pre(MDOC_ARGS
);
93 static int mdoc_ev_pre(MDOC_ARGS
);
94 static int mdoc_ex_pre(MDOC_ARGS
);
95 static void mdoc_fo_post(MDOC_ARGS
);
96 static int mdoc_fo_pre(MDOC_ARGS
);
97 static int mdoc_ic_pre(MDOC_ARGS
);
98 static int mdoc_in_pre(MDOC_ARGS
);
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
);
131 extern size_t strlcpy(char *, const char *, size_t);
132 extern size_t strlcat(char *, const char *, size_t);
135 static const struct htmlmdoc mdocs
[MDOC_MAX
] = {
136 {mdoc_ap_pre
, NULL
}, /* Ap */
137 {NULL
, NULL
}, /* Dd */
138 {NULL
, NULL
}, /* Dt */
139 {NULL
, NULL
}, /* Os */
140 {mdoc_sh_pre
, NULL
}, /* Sh */
141 {mdoc_ss_pre
, NULL
}, /* Ss */
142 {mdoc_sp_pre
, NULL
}, /* Pp */
143 {mdoc_d1_pre
, NULL
}, /* D1 */
144 {mdoc_d1_pre
, NULL
}, /* Dl */
145 {mdoc_bd_pre
, NULL
}, /* Bd */
146 {NULL
, NULL
}, /* Ed */
147 {mdoc_bl_pre
, mdoc_bl_post
}, /* Bl */
148 {NULL
, NULL
}, /* El */
149 {mdoc_it_pre
, NULL
}, /* It */
150 {mdoc_ad_pre
, NULL
}, /* Ad */
151 {mdoc_an_pre
, NULL
}, /* An */
152 {mdoc_ar_pre
, NULL
}, /* Ar */
153 {mdoc_cd_pre
, NULL
}, /* Cd */
154 {mdoc_fl_pre
, NULL
}, /* Cm */
155 {mdoc_dv_pre
, NULL
}, /* Dv */
156 {mdoc_er_pre
, NULL
}, /* Er */
157 {mdoc_ev_pre
, NULL
}, /* Ev */
158 {mdoc_ex_pre
, NULL
}, /* Ex */
159 {mdoc_fa_pre
, NULL
}, /* Fa */
160 {mdoc_fd_pre
, NULL
}, /* Fd */
161 {mdoc_fl_pre
, NULL
}, /* Fl */
162 {mdoc_fn_pre
, NULL
}, /* Fn */
163 {mdoc_ft_pre
, NULL
}, /* Ft */
164 {mdoc_ic_pre
, NULL
}, /* Ic */
165 {mdoc_in_pre
, NULL
}, /* In */
166 {mdoc_li_pre
, NULL
}, /* Li */
167 {mdoc_nd_pre
, NULL
}, /* Nd */
168 {mdoc_nm_pre
, NULL
}, /* Nm */
169 {mdoc_op_pre
, mdoc_op_post
}, /* Op */
170 {NULL
, NULL
}, /* Ot */
171 {mdoc_pa_pre
, NULL
}, /* Pa */
172 {mdoc_rv_pre
, NULL
}, /* Rv */
173 {NULL
, NULL
}, /* St */
174 {mdoc_va_pre
, NULL
}, /* Va */
175 {mdoc_vt_pre
, NULL
}, /* Vt */
176 {mdoc_xr_pre
, NULL
}, /* Xr */
177 {mdoc__x_pre
, mdoc__x_post
}, /* %A */
178 {mdoc__x_pre
, mdoc__x_post
}, /* %B */
179 {mdoc__x_pre
, mdoc__x_post
}, /* %D */
180 {mdoc__x_pre
, mdoc__x_post
}, /* %I */
181 {mdoc__x_pre
, mdoc__x_post
}, /* %J */
182 {mdoc__x_pre
, mdoc__x_post
}, /* %N */
183 {mdoc__x_pre
, mdoc__x_post
}, /* %O */
184 {mdoc__x_pre
, mdoc__x_post
}, /* %P */
185 {mdoc__x_pre
, mdoc__x_post
}, /* %R */
186 {mdoc__x_pre
, mdoc__x_post
}, /* %T */
187 {mdoc__x_pre
, mdoc__x_post
}, /* %V */
188 {NULL
, NULL
}, /* Ac */
189 {mdoc_aq_pre
, mdoc_aq_post
}, /* Ao */
190 {mdoc_aq_pre
, mdoc_aq_post
}, /* Aq */
191 {NULL
, NULL
}, /* At */
192 {NULL
, NULL
}, /* Bc */
193 {mdoc_bf_pre
, NULL
}, /* Bf */
194 {mdoc_bq_pre
, mdoc_bq_post
}, /* Bo */
195 {mdoc_bq_pre
, mdoc_bq_post
}, /* Bq */
196 {mdoc_xx_pre
, NULL
}, /* Bsx */
197 {mdoc_bx_pre
, NULL
}, /* Bx */
198 {NULL
, NULL
}, /* Db */
199 {NULL
, NULL
}, /* Dc */
200 {mdoc_dq_pre
, mdoc_dq_post
}, /* Do */
201 {mdoc_dq_pre
, mdoc_dq_post
}, /* Dq */
202 {NULL
, NULL
}, /* Ec */
203 {NULL
, NULL
}, /* Ef */
204 {mdoc_em_pre
, NULL
}, /* Em */
205 {NULL
, NULL
}, /* Eo */
206 {mdoc_xx_pre
, NULL
}, /* Fx */
207 {mdoc_ms_pre
, NULL
}, /* Ms */ /* FIXME: convert to symbol? */
208 {NULL
, NULL
}, /* No */
209 {mdoc_ns_pre
, NULL
}, /* Ns */
210 {mdoc_xx_pre
, NULL
}, /* Nx */
211 {mdoc_xx_pre
, NULL
}, /* Ox */
212 {NULL
, NULL
}, /* Pc */
213 {mdoc_pf_pre
, mdoc_pf_post
}, /* Pf */
214 {mdoc_pq_pre
, mdoc_pq_post
}, /* Po */
215 {mdoc_pq_pre
, mdoc_pq_post
}, /* Pq */
216 {NULL
, NULL
}, /* Qc */
217 {mdoc_sq_pre
, mdoc_sq_post
}, /* Ql */
218 {mdoc_dq_pre
, mdoc_dq_post
}, /* Qo */
219 {mdoc_dq_pre
, mdoc_dq_post
}, /* Qq */
220 {NULL
, NULL
}, /* Re */
221 {mdoc_rs_pre
, NULL
}, /* Rs */
222 {NULL
, NULL
}, /* Sc */
223 {mdoc_sq_pre
, mdoc_sq_post
}, /* So */
224 {mdoc_sq_pre
, mdoc_sq_post
}, /* Sq */
225 {NULL
, NULL
}, /* Sm */ /* FIXME - no idea. */
226 {mdoc_sx_pre
, NULL
}, /* Sx */
227 {mdoc_sy_pre
, NULL
}, /* Sy */
228 {NULL
, NULL
}, /* Tn */
229 {mdoc_xx_pre
, NULL
}, /* Ux */
230 {NULL
, NULL
}, /* Xc */
231 {NULL
, NULL
}, /* Xo */
232 {mdoc_fo_pre
, mdoc_fo_post
}, /* Fo */
233 {NULL
, NULL
}, /* Fc */
234 {mdoc_op_pre
, mdoc_op_post
}, /* Oo */
235 {NULL
, NULL
}, /* Oc */
236 {NULL
, NULL
}, /* Bk */
237 {NULL
, NULL
}, /* Ek */
238 {mdoc_bt_pre
, NULL
}, /* Bt */
239 {NULL
, NULL
}, /* Hf */
240 {NULL
, NULL
}, /* Fr */
241 {mdoc_ud_pre
, NULL
}, /* Ud */
242 {mdoc_lb_pre
, NULL
}, /* Lb */
243 {mdoc_sp_pre
, NULL
}, /* Lp */
244 {mdoc_lk_pre
, NULL
}, /* Lk */
245 {mdoc_mt_pre
, NULL
}, /* Mt */
246 {mdoc_brq_pre
, mdoc_brq_post
}, /* Brq */
247 {mdoc_brq_pre
, mdoc_brq_post
}, /* Bro */
248 {NULL
, NULL
}, /* Brc */
249 {mdoc__x_pre
, mdoc__x_post
}, /* %C */
250 {NULL
, NULL
}, /* Es */ /* TODO */
251 {NULL
, NULL
}, /* En */ /* TODO */
252 {mdoc_xx_pre
, NULL
}, /* Dx */
253 {mdoc__x_pre
, mdoc__x_post
}, /* %Q */
254 {mdoc_sp_pre
, NULL
}, /* br */
255 {mdoc_sp_pre
, NULL
}, /* sp */
258 static char buf
[BUFSIZ
]; /* XXX */
260 #define bufcat(x) (void)strlcat(buf, (x), BUFSIZ)
261 #define bufinit() buf[0] = 0
262 #define buffmt(...) (void)snprintf(buf, BUFSIZ - 1, __VA_ARGS__)
265 html_mdoc(void *arg
, const struct mdoc
*m
)
270 h
= (struct html
*)arg
;
272 print_gen_doctype(h
);
273 t
= print_otag(h
, TAG_HTML
, 0, NULL
);
274 print_mdoc(mdoc_meta(m
), mdoc_node(m
), h
);
282 a2list(const struct mdoc_node
*n
)
286 assert(MDOC_BLOCK
== n
->type
&& MDOC_Bl
== n
->tok
);
289 for (i
= 0; i
< (int)n
->args
->argc
; i
++)
290 switch (n
->args
->argv
[i
].arg
) {
312 return(n
->args
->argv
[i
].arg
);
323 a2width(const char *p
)
327 if (0 == (len
= (int)strlen(p
)))
329 for (i
= 0; i
< len
- 1; i
++)
330 if ( ! isdigit((u_char
)p
[i
]))
334 if ('n' == p
[len
- 1] || 'm' == p
[len
- 1])
342 a2offs(const char *p
)
346 if (0 == strcmp(p
, "left"))
348 if (0 == strcmp(p
, "indent"))
350 if (0 == strcmp(p
, "indent-two"))
351 return((INDENT
+ 1) * 2);
353 if (0 == (len
= (int)strlen(p
)))
356 for (i
= 0; i
< len
- 1; i
++)
357 if ( ! isdigit((u_char
)p
[i
]))
361 if ('n' == p
[len
- 1] || 'm' == p
[len
- 1])
369 print_mdoc(MDOC_ARGS
)
374 t
= print_otag(h
, TAG_HEAD
, 0, NULL
);
375 print_mdoc_head(m
, n
, h
);
378 t
= print_otag(h
, TAG_BODY
, 0, NULL
);
380 tag
.key
= ATTR_CLASS
;
382 print_otag(h
, TAG_DIV
, 1, &tag
);
384 print_mdoc_nodelist(m
, n
, h
);
391 print_mdoc_head(MDOC_ARGS
)
397 (void)snprintf(b
, BUFSIZ
- 1,
398 "%s(%d)", m
->title
, m
->msec
);
401 (void)strlcat(b
, " (", BUFSIZ
);
402 (void)strlcat(b
, m
->arch
, BUFSIZ
);
403 (void)strlcat(b
, ")", BUFSIZ
);
406 print_otag(h
, TAG_TITLE
, 0, NULL
);
412 print_mdoc_nodelist(MDOC_ARGS
)
415 print_mdoc_node(m
, n
, h
);
417 print_mdoc_nodelist(m
, n
->next
, h
);
422 print_mdoc_node(MDOC_ARGS
)
428 t
= SLIST_FIRST(&h
->tags
);
434 child
= mdoc_root_pre(m
, n
, h
);
437 print_text(h
, n
->string
);
440 if (mdocs
[n
->tok
].pre
)
441 child
= (*mdocs
[n
->tok
].pre
)(m
, n
, h
);
445 if (child
&& n
->child
)
446 print_mdoc_nodelist(m
, n
->child
, h
);
454 mdoc_root_post(m
, n
, h
);
459 if (mdocs
[n
->tok
].post
)
460 (*mdocs
[n
->tok
].post
)(m
, n
, h
);
468 mdoc_root_post(MDOC_ARGS
)
471 struct htmlpair tag
[2];
475 (void)localtime_r(&m
->date
, &tm
);
477 if (0 == strftime(b
, BUFSIZ
- 1, "%B %e, %Y", &tm
))
478 err(EXIT_FAILURE
, "strftime");
480 tag
[0].key
= ATTR_CLASS
;
481 tag
[0].val
= "footer";
482 tag
[1].key
= ATTR_STYLE
;
483 tag
[1].val
= "width: 100%;";
484 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
485 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
487 tag
[0].key
= ATTR_STYLE
;
488 tag
[0].val
= "width: 50%;";
489 print_otag(h
, TAG_TD
, 1, tag
);
493 tag
[0].key
= ATTR_STYLE
;
494 tag
[0].val
= "width: 50%; text-align: right;";
495 print_otag(h
, TAG_TD
, 1, tag
);
496 print_text(h
, m
->os
);
503 mdoc_root_pre(MDOC_ARGS
)
505 struct htmlpair tag
[2];
507 char b
[BUFSIZ
], title
[BUFSIZ
];
509 (void)strlcpy(b
, m
->vol
, BUFSIZ
);
512 (void)strlcat(b
, " (", BUFSIZ
);
513 (void)strlcat(b
, m
->arch
, BUFSIZ
);
514 (void)strlcat(b
, ")", BUFSIZ
);
517 (void)snprintf(title
, BUFSIZ
- 1,
518 "%s(%d)", m
->title
, m
->msec
);
520 tag
[0].key
= ATTR_CLASS
;
521 tag
[0].val
= "header";
522 tag
[1].key
= ATTR_STYLE
;
523 tag
[1].val
= "width: 100%;";
524 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
525 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
527 tag
[0].key
= ATTR_STYLE
;
528 tag
[0].val
= "width: 10%;";
529 print_otag(h
, TAG_TD
, 1, tag
);
530 print_text(h
, title
);
533 tag
[0].key
= ATTR_STYLE
;
534 tag
[0].val
= "width: 80%; white-space: nowrap; text-align: center;";
535 print_otag(h
, TAG_TD
, 1, tag
);
539 tag
[0].key
= ATTR_STYLE
;
540 tag
[0].val
= "width: 10%; text-align: right;";
541 print_otag(h
, TAG_TD
, 1, tag
);
542 print_text(h
, title
);
551 mdoc_sh_pre(MDOC_ARGS
)
553 struct htmlpair tag
[2];
554 const struct mdoc_node
*nn
;
556 if (MDOC_HEAD
== n
->type
) {
557 tag
[0].key
= ATTR_CLASS
;
558 tag
[0].val
= "sec-head";
559 print_otag(h
, TAG_DIV
, 1, tag
);
560 print_otag(h
, TAG_SPAN
, 1, tag
);
562 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
567 tag
[0].key
= ATTR_NAME
;
569 print_otag(h
, TAG_A
, 1, tag
);
571 } else if (MDOC_BLOCK
== n
->type
) {
572 tag
[0].key
= ATTR_CLASS
;
573 tag
[0].val
= "sec-block";
575 if (n
->prev
&& NULL
== n
->prev
->body
->child
) {
576 print_otag(h
, TAG_DIV
, 1, tag
);
580 bufcat("margin-top: 1em;");
582 bufcat("margin-bottom: 1em;");
584 tag
[1].key
= ATTR_STYLE
;
587 print_otag(h
, TAG_DIV
, 2, tag
);
591 buffmt("margin-left: %dem;", INDENT
);
593 tag
[0].key
= ATTR_CLASS
;
594 tag
[0].val
= "sec-body";
595 tag
[1].key
= ATTR_STYLE
;
598 print_otag(h
, TAG_DIV
, 2, tag
);
605 mdoc_ss_pre(MDOC_ARGS
)
607 struct htmlpair tag
[2];
609 const struct mdoc_node
*nn
;
613 if (MDOC_BODY
== n
->type
) {
614 tag
[i
].key
= ATTR_CLASS
;
615 tag
[i
++].val
= "ssec-body";
616 if (n
->parent
->next
&& n
->child
) {
617 bufcat("margin-bottom: 1em;");
618 tag
[i
].key
= ATTR_STYLE
;
621 print_otag(h
, TAG_DIV
, i
, tag
);
623 } else if (MDOC_BLOCK
== n
->type
) {
624 tag
[i
].key
= ATTR_CLASS
;
625 tag
[i
++].val
= "ssec-block";
627 bufcat("margin-top: 1em;");
628 tag
[i
].key
= ATTR_STYLE
;
631 print_otag(h
, TAG_DIV
, i
, tag
);
635 buffmt("margin-left: -%dem;", INDENT
- HALFINDENT
);
637 tag
[0].key
= ATTR_CLASS
;
638 tag
[0].val
= "ssec-head";
639 tag
[1].key
= ATTR_STYLE
;
642 print_otag(h
, TAG_DIV
, 2, tag
);
643 print_otag(h
, TAG_SPAN
, 1, tag
);
646 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
651 tag
[0].key
= ATTR_NAME
;
653 print_otag(h
, TAG_A
, 1, tag
);
661 mdoc_fl_pre(MDOC_ARGS
)
665 tag
.key
= ATTR_CLASS
;
668 print_otag(h
, TAG_SPAN
, 1, &tag
);
669 if (MDOC_Fl
== n
->tok
) {
670 print_text(h
, "\\-");
671 h
->flags
|= HTML_NOSPACE
;
679 mdoc_nd_pre(MDOC_ARGS
)
683 if (MDOC_BODY
!= n
->type
)
686 /* XXX - this can contain block elements! */
687 print_text(h
, "\\(em");
688 tag
.key
= ATTR_CLASS
;
689 tag
.val
= "desc-body";
690 print_otag(h
, TAG_SPAN
, 1, &tag
);
697 mdoc_op_pre(MDOC_ARGS
)
701 if (MDOC_BODY
!= n
->type
)
704 /* XXX - this can contain block elements! */
705 print_text(h
, "\\(lB");
706 h
->flags
|= HTML_NOSPACE
;
707 tag
.key
= ATTR_CLASS
;
709 print_otag(h
, TAG_SPAN
, 1, &tag
);
716 mdoc_op_post(MDOC_ARGS
)
719 if (MDOC_BODY
!= n
->type
)
721 h
->flags
|= HTML_NOSPACE
;
722 print_text(h
, "\\(rB");
727 mdoc_nm_pre(MDOC_ARGS
)
731 if ( ! (HTML_NEWLINE
& h
->flags
))
732 if (SEC_SYNOPSIS
== n
->sec
) {
733 tag
.key
= ATTR_STYLE
;
734 tag
.val
= "clear: both;";
735 print_otag(h
, TAG_BR
, 1, &tag
);
738 tag
.key
= ATTR_CLASS
;
741 print_otag(h
, TAG_SPAN
, 1, &tag
);
742 if (NULL
== n
->child
)
743 print_text(h
, m
->name
);
751 mdoc_xr_pre(MDOC_ARGS
)
753 struct htmlpair tag
[2];
754 const char *name
, *sec
;
755 const struct mdoc_node
*nn
;
758 name
= nn
&& nn
->string
? nn
->string
: "";
759 nn
= nn
? nn
->next
: NULL
;
760 sec
= nn
&& nn
->string
? nn
->string
: "";
762 buffmt("%s%s%s.html", name
, name
&& sec
? "." : "", sec
);
764 tag
[0].key
= ATTR_CLASS
;
765 tag
[0].val
= "link-man";
766 tag
[1].key
= ATTR_HREF
;
768 print_otag(h
, TAG_A
, 2, tag
);
771 print_text(h
, nn
->string
);
772 if (NULL
== (nn
= nn
->next
))
775 h
->flags
|= HTML_NOSPACE
;
777 h
->flags
|= HTML_NOSPACE
;
778 print_text(h
, nn
->string
);
779 h
->flags
|= HTML_NOSPACE
;
788 mdoc_ns_pre(MDOC_ARGS
)
791 h
->flags
|= HTML_NOSPACE
;
798 mdoc_ar_pre(MDOC_ARGS
)
802 tag
.key
= ATTR_CLASS
;
805 print_otag(h
, TAG_SPAN
, 1, &tag
);
812 mdoc_xx_pre(MDOC_ARGS
)
840 tag
.key
= ATTR_CLASS
;
843 print_otag(h
, TAG_SPAN
, 1, &tag
);
851 mdoc_bx_pre(MDOC_ARGS
)
853 const struct mdoc_node
*nn
;
856 tag
.key
= ATTR_CLASS
;
859 print_otag(h
, TAG_SPAN
, 1, &tag
);
861 for (nn
= n
->child
; nn
; nn
= nn
->next
)
862 print_mdoc_node(m
, nn
, h
);
865 h
->flags
|= HTML_NOSPACE
;
867 print_text(h
, "BSD");
874 mdoc_tbl_block_pre(MDOC_ARGS
, int t
, int w
, int o
, int c
)
884 buffmt("margin-left: %dem; clear: both;", o
);
887 buffmt("margin-left: %dem; clear: both;", w
+ o
);
891 if ( ! c
&& MDOC_Column
!= t
) {
892 if (n
->prev
&& n
->prev
->body
->child
)
893 bufcat("padding-top: 1em;");
894 else if (NULL
== n
->prev
)
895 bufcat("padding-top: 1em;");
898 tag
.key
= ATTR_STYLE
;
900 print_otag(h
, TAG_DIV
, 1, &tag
);
907 mdoc_tbl_body_pre(MDOC_ARGS
, int t
, int w
)
910 print_otag(h
, TAG_DIV
, 0, NULL
);
917 mdoc_tbl_head_pre(MDOC_ARGS
, int t
, int w
)
927 print_otag(h
, TAG_DIV
, 0, NULL
);
930 buffmt("min-width: %dem;", w
);
931 bufcat("clear: none;");
932 if (n
->next
&& MDOC_HEAD
== n
->next
->type
)
933 bufcat("float: left;");
934 tag
.key
= ATTR_STYLE
;
936 print_otag(h
, TAG_DIV
, 1, &tag
);
939 buffmt("margin-left: -%dem; min-width: %dem;",
941 bufcat("clear: left;");
942 if (n
->next
&& n
->next
->child
)
943 bufcat("float: left;");
944 bufcat("padding-right: 1em;");
945 tag
.key
= ATTR_STYLE
;
947 print_otag(h
, TAG_DIV
, 1, &tag
);
953 tag
.key
= ATTR_CLASS
;
955 print_otag(h
, TAG_SPAN
, 1, &tag
);
958 ord
= SLIST_FIRST(&h
->ords
);
960 nbuf
[BUFSIZ
- 1] = 0;
961 (void)snprintf(nbuf
, BUFSIZ
- 1, "%d.", ord
->pos
++);
965 print_text(h
, "\\(en");
968 print_text(h
, "\\(hy");
971 print_text(h
, "\\(bu");
982 mdoc_tbl_pre(MDOC_ARGS
, int type
)
985 const struct mdoc_node
*bl
, *nn
;
987 bl
= n
->parent
->parent
;
988 if (MDOC_BLOCK
!= n
->type
)
991 /* FIXME: fmt_vspace() equivalent. */
998 for (i
= 0; i
< (int)bl
->args
->argc
; i
++)
999 if (MDOC_Width
== bl
->args
->argv
[i
].arg
) {
1000 assert(bl
->args
->argv
[i
].sz
);
1002 w
= a2width(bl
->args
->argv
[i
].value
[0]);
1003 } else if (MDOC_Offset
== bl
->args
->argv
[i
].arg
) {
1004 assert(bl
->args
->argv
[i
].sz
);
1005 o
= a2offs(bl
->args
->argv
[i
].value
[0]);
1006 } else if (MDOC_Compact
== bl
->args
->argv
[i
].arg
)
1009 if (MDOC_HEAD
== n
->type
&& MDOC_Column
== type
) {
1010 nn
= n
->parent
->child
;
1011 assert(nn
&& MDOC_HEAD
== nn
->type
);
1012 for (i
= 0; nn
&& nn
!= n
; nn
= nn
->next
, i
++)
1015 if (wp
>= 0 && i
< (int)bl
->args
[wp
].argv
->sz
)
1016 w
= a2width(bl
->args
->argv
[wp
].value
[i
]);
1045 return(mdoc_tbl_head_pre(m
, n
, h
, type
, w
));
1047 return(mdoc_tbl_body_pre(m
, n
, h
, type
, w
));
1053 return(mdoc_tbl_block_pre(m
, n
, h
, type
, w
, o
, c
));
1059 mdoc_bl_pre(MDOC_ARGS
)
1063 if (MDOC_BLOCK
!= n
->type
)
1065 if (MDOC_Enum
!= a2list(n
))
1068 ord
= malloc(sizeof(struct ord
));
1070 err(EXIT_FAILURE
, "malloc");
1073 SLIST_INSERT_HEAD(&h
->ords
, ord
, entry
);
1081 mdoc_bl_post(MDOC_ARGS
)
1085 if (MDOC_BLOCK
!= n
->type
)
1087 if (MDOC_Enum
!= a2list(n
))
1090 ord
= SLIST_FIRST(&h
->ords
);
1092 SLIST_REMOVE_HEAD(&h
->ords
, entry
);
1098 mdoc_it_pre(MDOC_ARGS
)
1102 if (MDOC_BLOCK
== n
->type
)
1103 type
= a2list(n
->parent
->parent
);
1105 type
= a2list(n
->parent
->parent
->parent
);
1107 return(mdoc_tbl_pre(m
, n
, h
, type
));
1113 mdoc_ex_pre(MDOC_ARGS
)
1115 const struct mdoc_node
*nn
;
1117 struct htmlpair tag
;
1119 print_text(h
, "The");
1121 tag
.key
= ATTR_CLASS
;
1122 tag
.val
= "utility";
1124 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1125 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1126 print_text(h
, nn
->string
);
1129 h
->flags
|= HTML_NOSPACE
;
1131 if (nn
->next
&& NULL
== nn
->next
->next
)
1132 print_text(h
, ", and");
1136 h
->flags
&= ~HTML_NOSPACE
;
1140 print_text(h
, "utilities exit");
1142 print_text(h
, "utility exits");
1144 print_text(h
, "0 on success, and >0 if an error occurs.");
1151 mdoc_dq_pre(MDOC_ARGS
)
1154 if (MDOC_BODY
!= n
->type
)
1156 print_text(h
, "\\(lq");
1157 h
->flags
|= HTML_NOSPACE
;
1164 mdoc_dq_post(MDOC_ARGS
)
1167 if (MDOC_BODY
!= n
->type
)
1169 h
->flags
|= HTML_NOSPACE
;
1170 print_text(h
, "\\(rq");
1176 mdoc_pq_pre(MDOC_ARGS
)
1179 if (MDOC_BODY
!= n
->type
)
1181 print_text(h
, "\\&(");
1182 h
->flags
|= HTML_NOSPACE
;
1189 mdoc_pq_post(MDOC_ARGS
)
1192 if (MDOC_BODY
!= n
->type
)
1200 mdoc_sq_pre(MDOC_ARGS
)
1203 if (MDOC_BODY
!= n
->type
)
1205 print_text(h
, "\\(oq");
1206 h
->flags
|= HTML_NOSPACE
;
1213 mdoc_sq_post(MDOC_ARGS
)
1216 if (MDOC_BODY
!= n
->type
)
1218 h
->flags
|= HTML_NOSPACE
;
1219 print_text(h
, "\\(aq");
1225 mdoc_em_pre(MDOC_ARGS
)
1227 struct htmlpair tag
;
1229 tag
.key
= ATTR_CLASS
;
1232 print_otag(h
, TAG_SPAN
, 1, &tag
);
1239 mdoc_d1_pre(MDOC_ARGS
)
1241 struct htmlpair tag
[2];
1243 if (MDOC_BLOCK
!= n
->type
)
1246 buffmt("margin-left: %dem;", INDENT
);
1248 tag
[0].key
= ATTR_CLASS
;
1250 tag
[1].key
= ATTR_STYLE
;
1253 print_otag(h
, TAG_DIV
, 2, tag
);
1260 mdoc_sx_pre(MDOC_ARGS
)
1262 struct htmlpair tag
[2];
1263 const struct mdoc_node
*nn
;
1266 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1272 tag
[0].key
= ATTR_HREF
;
1274 tag
[1].key
= ATTR_CLASS
;
1275 tag
[1].val
= "link-sec";
1277 print_otag(h
, TAG_A
, 2, tag
);
1284 mdoc_aq_pre(MDOC_ARGS
)
1287 if (MDOC_BODY
!= n
->type
)
1289 print_text(h
, "\\(la");
1290 h
->flags
|= HTML_NOSPACE
;
1297 mdoc_aq_post(MDOC_ARGS
)
1300 if (MDOC_BODY
!= n
->type
)
1302 h
->flags
|= HTML_NOSPACE
;
1303 print_text(h
, "\\(ra");
1309 mdoc_bd_pre(MDOC_ARGS
)
1311 struct htmlpair tag
[2];
1313 const struct mdoc_node
*bl
;
1315 /* FIXME: fmt_vspace() shit. */
1317 if (MDOC_BLOCK
== n
->type
)
1319 else if (MDOC_HEAD
== n
->type
)
1326 for (i
= 0; i
< (int)bl
->args
->argc
; i
++)
1327 switch (bl
->args
->argv
[i
].arg
) {
1329 assert(bl
->args
->argv
[i
].sz
);
1330 o
= a2offs (bl
->args
->argv
[i
].value
[0]);
1332 case (MDOC_Compact
):
1339 case (MDOC_Unfilled
):
1341 case (MDOC_Literal
):
1342 t
= bl
->args
->argv
[i
].arg
;
1346 if (MDOC_BLOCK
== n
->type
) {
1348 buffmt("margin-left: %dem;", o
);
1349 bufcat("margin-top: 1em;");
1350 tag
[0].key
= ATTR_STYLE
;
1352 print_otag(h
, TAG_DIV
, 1, tag
);
1357 case (MDOC_Unfilled
):
1358 case (MDOC_Literal
):
1364 bufcat("white-space: pre;");
1365 tag
[0].key
= ATTR_STYLE
;
1367 tag
[1].key
= ATTR_CLASS
;
1370 print_otag(h
, TAG_DIV
, 2, tag
);
1372 for (n
= n
->child
; n
; n
= n
->next
) {
1373 h
->flags
|= HTML_NOSPACE
;
1374 print_mdoc_node(m
, n
, h
);
1376 print_text(h
, "\n");
1385 mdoc_pa_pre(MDOC_ARGS
)
1387 struct htmlpair tag
;
1389 tag
.key
= ATTR_CLASS
;
1392 print_otag(h
, TAG_SPAN
, 1, &tag
);
1399 mdoc_ad_pre(MDOC_ARGS
)
1401 struct htmlpair tag
;
1403 tag
.key
= ATTR_CLASS
;
1405 print_otag(h
, TAG_SPAN
, 1, &tag
);
1412 mdoc_an_pre(MDOC_ARGS
)
1414 struct htmlpair tag
;
1416 tag
.key
= ATTR_CLASS
;
1418 print_otag(h
, TAG_SPAN
, 1, &tag
);
1425 mdoc_cd_pre(MDOC_ARGS
)
1427 struct htmlpair tag
;
1429 tag
.key
= ATTR_CLASS
;
1431 print_otag(h
, TAG_SPAN
, 1, &tag
);
1438 mdoc_dv_pre(MDOC_ARGS
)
1440 struct htmlpair tag
;
1442 tag
.key
= ATTR_CLASS
;
1444 print_otag(h
, TAG_SPAN
, 1, &tag
);
1451 mdoc_ev_pre(MDOC_ARGS
)
1453 struct htmlpair tag
;
1455 tag
.key
= ATTR_CLASS
;
1457 print_otag(h
, TAG_SPAN
, 1, &tag
);
1464 mdoc_er_pre(MDOC_ARGS
)
1466 struct htmlpair tag
;
1468 tag
.key
= ATTR_CLASS
;
1470 print_otag(h
, TAG_SPAN
, 1, &tag
);
1477 mdoc_fa_pre(MDOC_ARGS
)
1479 const struct mdoc_node
*nn
;
1480 struct htmlpair tag
;
1483 tag
.key
= ATTR_CLASS
;
1486 if (n
->parent
->tok
!= MDOC_Fo
) {
1487 print_otag(h
, TAG_SPAN
, 1, &tag
);
1491 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1492 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1493 print_text(h
, nn
->string
);
1499 if (n
->child
&& n
->next
&& n
->next
->tok
== MDOC_Fa
)
1508 mdoc_fd_pre(MDOC_ARGS
)
1510 struct htmlpair tag
;
1512 if (SEC_SYNOPSIS
== n
->sec
) {
1513 if (n
->next
&& MDOC_Fd
!= n
->next
->tok
) {
1514 tag
.key
= ATTR_STYLE
;
1515 tag
.val
= "margin-bottom: 1em;";
1516 print_otag(h
, TAG_DIV
, 1, &tag
);
1518 print_otag(h
, TAG_DIV
, 0, NULL
);
1521 tag
.key
= ATTR_CLASS
;
1523 print_otag(h
, TAG_SPAN
, 1, &tag
);
1530 mdoc_vt_pre(MDOC_ARGS
)
1532 struct htmlpair tag
;
1534 if (SEC_SYNOPSIS
== n
->sec
) {
1535 if (n
->next
&& MDOC_Vt
!= n
->next
->tok
) {
1536 tag
.key
= ATTR_STYLE
;
1537 tag
.val
= "margin-bottom: 1em;";
1538 print_otag(h
, TAG_DIV
, 1, &tag
);
1540 print_otag(h
, TAG_DIV
, 0, NULL
);
1543 tag
.key
= ATTR_CLASS
;
1545 print_otag(h
, TAG_SPAN
, 1, &tag
);
1552 mdoc_ft_pre(MDOC_ARGS
)
1554 struct htmlpair tag
;
1556 if (SEC_SYNOPSIS
== n
->sec
) {
1557 if (n
->prev
&& MDOC_Fo
== n
->prev
->tok
) {
1558 tag
.key
= ATTR_STYLE
;
1559 tag
.val
= "margin-top: 1em;";
1560 print_otag(h
, TAG_DIV
, 1, &tag
);
1562 print_otag(h
, TAG_DIV
, 0, NULL
);
1565 tag
.key
= ATTR_CLASS
;
1567 print_otag(h
, TAG_SPAN
, 1, &tag
);
1574 mdoc_fn_pre(MDOC_ARGS
)
1577 struct htmlpair tag
;
1578 const struct mdoc_node
*nn
;
1580 const char *sp
, *ep
;
1583 if (SEC_SYNOPSIS
== n
->sec
) {
1585 tag
.key
= ATTR_STYLE
;
1586 tag
.val
= "margin-bottom: 1em";
1587 print_otag(h
, TAG_DIV
, 1, &tag
);
1589 print_otag(h
, TAG_DIV
, 0, NULL
);
1592 /* Split apart into type and name. */
1594 tag
.key
= ATTR_CLASS
;
1596 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1598 assert(n
->child
->string
);
1599 sp
= n
->child
->string
;
1600 while (NULL
!= (ep
= strchr(sp
, ' '))) {
1601 sz
= MIN((int)(ep
- sp
), BUFSIZ
- 1);
1602 (void)memcpy(nbuf
, sp
, (size_t)sz
);
1604 print_text(h
, nbuf
);
1610 tag
.key
= ATTR_CLASS
;
1612 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1615 (void)strlcpy(nbuf
, sp
, BUFSIZ
);
1616 print_text(h
, nbuf
);
1621 h
->flags
|= HTML_NOSPACE
;
1624 for (nn
= n
->child
->next
; nn
; nn
= nn
->next
) {
1625 tag
.key
= ATTR_CLASS
;
1627 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1628 print_text(h
, nn
->string
);
1636 if (SEC_SYNOPSIS
== n
->sec
)
1645 mdoc_sp_pre(MDOC_ARGS
)
1648 struct htmlpair tag
;
1652 len
= n
->child
? atoi(n
->child
->string
) : 1;
1662 buffmt("height: %dem", len
);
1663 tag
.key
= ATTR_STYLE
;
1665 print_otag(h
, TAG_DIV
, 1, &tag
);
1673 mdoc_brq_pre(MDOC_ARGS
)
1676 if (MDOC_BODY
!= n
->type
)
1678 print_text(h
, "\\(lC");
1679 h
->flags
|= HTML_NOSPACE
;
1686 mdoc_brq_post(MDOC_ARGS
)
1689 if (MDOC_BODY
!= n
->type
)
1691 h
->flags
|= HTML_NOSPACE
;
1692 print_text(h
, "\\(rC");
1698 mdoc_lk_pre(MDOC_ARGS
)
1700 const struct mdoc_node
*nn
;
1701 struct htmlpair tag
[2];
1705 tag
[0].key
= ATTR_CLASS
;
1706 tag
[0].val
= "link-ext";
1707 tag
[1].key
= ATTR_HREF
;
1708 tag
[1].val
= nn
->string
;
1710 print_otag(h
, TAG_A
, 2, tag
);
1712 if (NULL
== nn
->next
)
1715 for (nn
= nn
->next
; nn
; nn
= nn
->next
)
1716 print_text(h
, nn
->string
);
1724 mdoc_mt_pre(MDOC_ARGS
)
1726 struct htmlpair tag
[2];
1728 const struct mdoc_node
*nn
;
1730 tag
[0].key
= ATTR_CLASS
;
1731 tag
[0].val
= "link-mail";
1733 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1738 tag
[1].key
= ATTR_HREF
;
1741 t
= print_otag(h
, TAG_A
, 2, tag
);
1742 print_text(h
, nn
->string
);
1752 mdoc_fo_pre(MDOC_ARGS
)
1754 struct htmlpair tag
;
1756 if (MDOC_BODY
== n
->type
) {
1757 h
->flags
|= HTML_NOSPACE
;
1759 h
->flags
|= HTML_NOSPACE
;
1761 } else if (MDOC_BLOCK
== n
->type
)
1764 tag
.key
= ATTR_CLASS
;
1766 print_otag(h
, TAG_SPAN
, 1, &tag
);
1773 mdoc_fo_post(MDOC_ARGS
)
1775 if (MDOC_BODY
!= n
->type
)
1777 h
->flags
|= HTML_NOSPACE
;
1779 h
->flags
|= HTML_NOSPACE
;
1786 mdoc_in_pre(MDOC_ARGS
)
1788 const struct mdoc_node
*nn
;
1789 struct htmlpair tag
;
1791 if (SEC_SYNOPSIS
== n
->sec
) {
1792 if (n
->next
&& MDOC_In
!= n
->next
->tok
) {
1793 tag
.key
= ATTR_STYLE
;
1794 tag
.val
= "margin-bottom: 1em;";
1795 print_otag(h
, TAG_DIV
, 1, &tag
);
1797 print_otag(h
, TAG_DIV
, 0, NULL
);
1800 tag
.key
= ATTR_CLASS
;
1801 tag
.val
= "includes";
1803 print_otag(h
, TAG_SPAN
, 1, &tag
);
1805 if (SEC_SYNOPSIS
== n
->sec
)
1806 print_text(h
, "#include");
1809 h
->flags
|= HTML_NOSPACE
;
1811 /* XXX -- see warning in termp_in_post(). */
1813 for (nn
= n
->child
; nn
; nn
= nn
->next
)
1814 print_mdoc_node(m
, nn
, h
);
1816 h
->flags
|= HTML_NOSPACE
;
1825 mdoc_ic_pre(MDOC_ARGS
)
1827 struct htmlpair tag
;
1829 tag
.key
= ATTR_CLASS
;
1832 print_otag(h
, TAG_SPAN
, 1, &tag
);
1839 mdoc_rv_pre(MDOC_ARGS
)
1841 const struct mdoc_node
*nn
;
1842 struct htmlpair tag
;
1845 print_otag(h
, TAG_DIV
, 0, NULL
);
1847 print_text(h
, "The");
1849 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1850 tag
.key
= ATTR_CLASS
;
1852 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1853 print_text(h
, nn
->string
);
1856 h
->flags
|= HTML_NOSPACE
;
1857 if (nn
->next
&& NULL
== nn
->next
->next
)
1858 print_text(h
, "(), and");
1860 print_text(h
, "(),");
1862 print_text(h
, "()");
1866 print_text(h
, "functions return");
1868 print_text(h
, "function returns");
1870 print_text(h
, "the value 0 if successful; otherwise the value "
1871 "-1 is returned and the global variable");
1873 tag
.key
= ATTR_CLASS
;
1875 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1876 print_text(h
, "errno");
1878 print_text(h
, "is set to indicate the error.");
1885 mdoc_va_pre(MDOC_ARGS
)
1887 struct htmlpair tag
;
1889 tag
.key
= ATTR_CLASS
;
1891 print_otag(h
, TAG_SPAN
, 1, &tag
);
1898 mdoc_bq_pre(MDOC_ARGS
)
1901 if (MDOC_BODY
!= n
->type
)
1903 print_text(h
, "\\(lB");
1904 h
->flags
|= HTML_NOSPACE
;
1911 mdoc_bq_post(MDOC_ARGS
)
1914 if (MDOC_BODY
!= n
->type
)
1916 h
->flags
|= HTML_NOSPACE
;
1917 print_text(h
, "\\(rB");
1923 mdoc_ap_pre(MDOC_ARGS
)
1926 h
->flags
|= HTML_NOSPACE
;
1927 print_text(h
, "\\(aq");
1928 h
->flags
|= HTML_NOSPACE
;
1935 mdoc_bf_pre(MDOC_ARGS
)
1938 struct htmlpair tag
[2];
1940 if (MDOC_HEAD
== n
->type
)
1942 else if (MDOC_BLOCK
!= n
->type
)
1945 tag
[0].key
= ATTR_CLASS
;
1948 if (n
->head
->child
) {
1949 if ( ! strcmp("Em", n
->head
->child
->string
))
1950 tag
[0].val
= "emph";
1951 else if ( ! strcmp("Sy", n
->head
->child
->string
))
1952 tag
[0].val
= "symb";
1953 else if ( ! strcmp("Li", n
->head
->child
->string
))
1957 for (i
= 0; i
< (int)n
->args
->argc
; i
++)
1958 switch (n
->args
->argv
[i
].arg
) {
1959 case (MDOC_Symbolic
):
1960 tag
[0].val
= "symb";
1962 case (MDOC_Literal
):
1965 case (MDOC_Emphasis
):
1966 tag
[0].val
= "emph";
1973 /* FIXME: div's have spaces stripped--we want them. */
1976 tag
[1].key
= ATTR_STYLE
;
1977 tag
[1].val
= "display: inline; margin-right: 1em;";
1978 print_otag(h
, TAG_DIV
, 2, tag
);
1985 mdoc_ms_pre(MDOC_ARGS
)
1987 struct htmlpair tag
;
1989 tag
.key
= ATTR_CLASS
;
1991 print_otag(h
, TAG_SPAN
, 1, &tag
);
1998 mdoc_pf_pre(MDOC_ARGS
)
2001 h
->flags
|= HTML_IGNDELIM
;
2008 mdoc_pf_post(MDOC_ARGS
)
2011 h
->flags
&= ~HTML_IGNDELIM
;
2012 h
->flags
|= HTML_NOSPACE
;
2018 mdoc_rs_pre(MDOC_ARGS
)
2020 struct htmlpair tag
;
2022 if (MDOC_BLOCK
!= n
->type
)
2025 if (n
->prev
&& SEC_SEE_ALSO
== n
->sec
) {
2026 tag
.key
= ATTR_STYLE
;
2027 tag
.val
= "margin-top: 1em;";
2028 print_otag(h
, TAG_DIV
, 1, &tag
);
2031 tag
.key
= ATTR_CLASS
;
2033 print_otag(h
, TAG_SPAN
, 1, &tag
);
2041 mdoc_li_pre(MDOC_ARGS
)
2043 struct htmlpair tag
;
2045 tag
.key
= ATTR_CLASS
;
2048 print_otag(h
, TAG_SPAN
, 1, &tag
);
2055 mdoc_sy_pre(MDOC_ARGS
)
2057 struct htmlpair tag
;
2059 tag
.key
= ATTR_CLASS
;
2062 print_otag(h
, TAG_SPAN
, 1, &tag
);
2069 mdoc_bt_pre(MDOC_ARGS
)
2072 print_text(h
, "is currently in beta test.");
2079 mdoc_ud_pre(MDOC_ARGS
)
2082 print_text(h
, "currently under development.");
2089 mdoc_lb_pre(MDOC_ARGS
)
2091 struct htmlpair tag
;
2093 tag
.key
= ATTR_CLASS
;
2096 if (SEC_SYNOPSIS
== n
->sec
)
2097 print_otag(h
, TAG_DIV
, 0, NULL
);
2099 print_otag(h
, TAG_SPAN
, 1, &tag
);
2106 mdoc__x_pre(MDOC_ARGS
)
2108 struct htmlpair tag
;
2110 tag
.key
= ATTR_CLASS
;
2114 tag
.val
= "ref-auth";
2117 tag
.val
= "ref-book";
2120 tag
.val
= "ref-city";
2123 tag
.val
= "ref-date";
2126 tag
.val
= "ref-issue";
2129 tag
.val
= "ref-jrnl";
2132 tag
.val
= "ref-num";
2135 tag
.val
= "ref-opt";
2138 tag
.val
= "ref-page";
2141 tag
.val
= "ref-corp";
2144 tag
.val
= "ref-rep";
2147 print_text(h
, "\\(lq");
2148 h
->flags
|= HTML_NOSPACE
;
2149 tag
.val
= "ref-title";
2152 tag
.val
= "ref-vol";
2159 print_otag(h
, TAG_SPAN
, 1, &tag
);
2166 mdoc__x_post(MDOC_ARGS
)
2169 h
->flags
|= HTML_NOSPACE
;
2172 print_text(h
, "\\(rq");
2173 h
->flags
|= HTML_NOSPACE
;
2178 print_text(h
, n
->next
? "," : ".");