]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_html.c
1 /* $Id: mdoc_html.c,v 1.19 2009/10/03 19:02:45 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 */
260 html_mdoc(void *arg
, const struct mdoc
*m
)
265 h
= (struct html
*)arg
;
267 print_gen_doctype(h
);
268 t
= print_otag(h
, TAG_HTML
, 0, NULL
);
269 print_mdoc(mdoc_meta(m
), mdoc_node(m
), h
);
277 a2list(const struct mdoc_node
*n
)
281 assert(MDOC_BLOCK
== n
->type
&& MDOC_Bl
== n
->tok
);
284 for (i
= 0; i
< (int)n
->args
->argc
; i
++)
285 switch (n
->args
->argv
[i
].arg
) {
307 return(n
->args
->argv
[i
].arg
);
318 a2width(const char *p
)
322 if (0 == (len
= (int)strlen(p
)))
324 for (i
= 0; i
< len
- 1; i
++)
325 if ( ! isdigit((u_char
)p
[i
]))
329 if ('n' == p
[len
- 1] || 'm' == p
[len
- 1])
337 a2offs(const char *p
)
341 if (0 == strcmp(p
, "left"))
343 if (0 == strcmp(p
, "indent"))
345 if (0 == strcmp(p
, "indent-two"))
346 return((INDENT
+ 1) * 2);
348 if (0 == (len
= (int)strlen(p
)))
351 for (i
= 0; i
< len
- 1; i
++)
352 if ( ! isdigit((u_char
)p
[i
]))
356 if ('n' == p
[len
- 1] || 'm' == p
[len
- 1])
364 print_mdoc(MDOC_ARGS
)
369 t
= print_otag(h
, TAG_HEAD
, 0, NULL
);
370 print_mdoc_head(m
, n
, h
);
373 t
= print_otag(h
, TAG_BODY
, 0, NULL
);
375 tag
.key
= ATTR_CLASS
;
377 print_otag(h
, TAG_DIV
, 1, &tag
);
379 print_mdoc_nodelist(m
, n
, h
);
386 print_mdoc_head(MDOC_ARGS
)
392 (void)snprintf(b
, BUFSIZ
- 1,
393 "%s(%d)", m
->title
, m
->msec
);
396 (void)strlcat(b
, " (", BUFSIZ
);
397 (void)strlcat(b
, m
->arch
, BUFSIZ
);
398 (void)strlcat(b
, ")", BUFSIZ
);
401 print_otag(h
, TAG_TITLE
, 0, NULL
);
407 print_mdoc_nodelist(MDOC_ARGS
)
410 print_mdoc_node(m
, n
, h
);
412 print_mdoc_nodelist(m
, n
->next
, h
);
417 print_mdoc_node(MDOC_ARGS
)
423 t
= SLIST_FIRST(&h
->tags
);
429 child
= mdoc_root_pre(m
, n
, h
);
432 print_text(h
, n
->string
);
435 if (mdocs
[n
->tok
].pre
)
436 child
= (*mdocs
[n
->tok
].pre
)(m
, n
, h
);
440 if (child
&& n
->child
)
441 print_mdoc_nodelist(m
, n
->child
, h
);
449 mdoc_root_post(m
, n
, h
);
454 if (mdocs
[n
->tok
].post
)
455 (*mdocs
[n
->tok
].post
)(m
, n
, h
);
463 mdoc_root_post(MDOC_ARGS
)
466 struct htmlpair tag
[2];
470 (void)localtime_r(&m
->date
, &tm
);
472 if (0 == strftime(b
, BUFSIZ
- 1, "%B %e, %Y", &tm
))
473 err(EXIT_FAILURE
, "strftime");
475 tag
[0].key
= ATTR_CLASS
;
476 tag
[0].val
= "footer";
477 tag
[1].key
= ATTR_STYLE
;
478 tag
[1].val
= "width: 100%;";
479 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
480 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
482 tag
[0].key
= ATTR_STYLE
;
483 tag
[0].val
= "width: 50%;";
484 print_otag(h
, TAG_TD
, 1, tag
);
488 tag
[0].key
= ATTR_STYLE
;
489 tag
[0].val
= "width: 50%; text-align: right;";
490 print_otag(h
, TAG_TD
, 1, tag
);
491 print_text(h
, m
->os
);
498 mdoc_root_pre(MDOC_ARGS
)
500 struct htmlpair tag
[2];
502 char b
[BUFSIZ
], title
[BUFSIZ
];
504 (void)strlcpy(b
, m
->vol
, BUFSIZ
);
507 (void)strlcat(b
, " (", BUFSIZ
);
508 (void)strlcat(b
, m
->arch
, BUFSIZ
);
509 (void)strlcat(b
, ")", BUFSIZ
);
512 (void)snprintf(title
, BUFSIZ
- 1,
513 "%s(%d)", m
->title
, m
->msec
);
515 tag
[0].key
= ATTR_CLASS
;
516 tag
[0].val
= "header";
517 tag
[1].key
= ATTR_STYLE
;
518 tag
[1].val
= "width: 100%;";
519 t
= print_otag(h
, TAG_TABLE
, 2, tag
);
520 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
522 tag
[0].key
= ATTR_STYLE
;
523 tag
[0].val
= "width: 10%;";
524 print_otag(h
, TAG_TD
, 1, tag
);
525 print_text(h
, title
);
528 tag
[0].key
= ATTR_STYLE
;
529 tag
[0].val
= "width: 80%; white-space: nowrap; text-align: center;";
530 print_otag(h
, TAG_TD
, 1, tag
);
534 tag
[0].key
= ATTR_STYLE
;
535 tag
[0].val
= "width: 10%; text-align: right;";
536 print_otag(h
, TAG_TD
, 1, tag
);
537 print_text(h
, title
);
546 mdoc_sh_pre(MDOC_ARGS
)
548 struct htmlpair tag
[2];
549 const struct mdoc_node
*nn
;
551 if (MDOC_HEAD
== n
->type
) {
552 tag
[0].key
= ATTR_CLASS
;
553 tag
[0].val
= "sec-head";
554 print_otag(h
, TAG_DIV
, 1, tag
);
555 print_otag(h
, TAG_SPAN
, 1, tag
);
557 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
558 bufcat(h
, nn
->string
);
562 tag
[0].key
= ATTR_NAME
;
564 print_otag(h
, TAG_A
, 1, tag
);
566 } else if (MDOC_BLOCK
== n
->type
) {
567 tag
[0].key
= ATTR_CLASS
;
568 tag
[0].val
= "sec-block";
570 if (n
->prev
&& NULL
== n
->prev
->body
->child
) {
571 print_otag(h
, TAG_DIV
, 1, tag
);
575 bufcat(h
, "margin-top: 1em;");
577 bufcat(h
, "margin-bottom: 1em;");
579 tag
[1].key
= ATTR_STYLE
;
582 print_otag(h
, TAG_DIV
, 2, tag
);
586 buffmt(h
, "margin-left: %dem;", INDENT
);
588 tag
[0].key
= ATTR_CLASS
;
589 tag
[0].val
= "sec-body";
590 tag
[1].key
= ATTR_STYLE
;
593 print_otag(h
, TAG_DIV
, 2, tag
);
600 mdoc_ss_pre(MDOC_ARGS
)
602 struct htmlpair tag
[2];
604 const struct mdoc_node
*nn
;
608 if (MDOC_BODY
== n
->type
) {
609 tag
[i
].key
= ATTR_CLASS
;
610 tag
[i
++].val
= "ssec-body";
611 if (n
->parent
->next
&& n
->child
) {
612 bufcat(h
, "margin-bottom: 1em;");
613 tag
[i
].key
= ATTR_STYLE
;
614 tag
[i
++].val
= h
->buf
;
616 print_otag(h
, TAG_DIV
, i
, tag
);
618 } else if (MDOC_BLOCK
== n
->type
) {
619 tag
[i
].key
= ATTR_CLASS
;
620 tag
[i
++].val
= "ssec-block";
622 bufcat(h
, "margin-top: 1em;");
623 tag
[i
].key
= ATTR_STYLE
;
624 tag
[i
++].val
= h
->buf
;
626 print_otag(h
, TAG_DIV
, i
, tag
);
630 buffmt(h
, "margin-left: -%dem;", INDENT
- HALFINDENT
);
632 tag
[0].key
= ATTR_CLASS
;
633 tag
[0].val
= "ssec-head";
634 tag
[1].key
= ATTR_STYLE
;
637 print_otag(h
, TAG_DIV
, 2, tag
);
638 print_otag(h
, TAG_SPAN
, 1, tag
);
641 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
642 bufcat(h
, nn
->string
);
646 tag
[0].key
= ATTR_NAME
;
648 print_otag(h
, TAG_A
, 1, tag
);
656 mdoc_fl_pre(MDOC_ARGS
)
660 tag
.key
= ATTR_CLASS
;
663 print_otag(h
, TAG_SPAN
, 1, &tag
);
664 if (MDOC_Fl
== n
->tok
) {
665 print_text(h
, "\\-");
666 h
->flags
|= HTML_NOSPACE
;
674 mdoc_nd_pre(MDOC_ARGS
)
678 if (MDOC_BODY
!= n
->type
)
681 /* XXX - this can contain block elements! */
682 print_text(h
, "\\(em");
683 tag
.key
= ATTR_CLASS
;
684 tag
.val
= "desc-body";
685 print_otag(h
, TAG_SPAN
, 1, &tag
);
692 mdoc_op_pre(MDOC_ARGS
)
696 if (MDOC_BODY
!= n
->type
)
699 /* XXX - this can contain block elements! */
700 print_text(h
, "\\(lB");
701 h
->flags
|= HTML_NOSPACE
;
702 tag
.key
= ATTR_CLASS
;
704 print_otag(h
, TAG_SPAN
, 1, &tag
);
711 mdoc_op_post(MDOC_ARGS
)
714 if (MDOC_BODY
!= n
->type
)
716 h
->flags
|= HTML_NOSPACE
;
717 print_text(h
, "\\(rB");
722 mdoc_nm_pre(MDOC_ARGS
)
726 if ( ! (HTML_NEWLINE
& h
->flags
))
727 if (SEC_SYNOPSIS
== n
->sec
) {
728 tag
.key
= ATTR_STYLE
;
729 tag
.val
= "clear: both;";
730 print_otag(h
, TAG_BR
, 1, &tag
);
733 tag
.key
= ATTR_CLASS
;
736 print_otag(h
, TAG_SPAN
, 1, &tag
);
737 if (NULL
== n
->child
)
738 print_text(h
, m
->name
);
746 mdoc_xr_pre(MDOC_ARGS
)
748 struct htmlpair tag
[2];
749 const struct mdoc_node
*nn
;
753 tag
[i
].key
= ATTR_CLASS
;
754 tag
[i
++].val
= "link-man";
757 buffmt_man(h
, n
->child
->string
, n
->child
->next
?
758 n
->child
->next
->string
: NULL
);
759 tag
[i
].key
= ATTR_HREF
;
760 tag
[i
++].val
= h
->buf
;
763 print_otag(h
, TAG_A
, i
, tag
);
766 print_text(h
, nn
->string
);
768 if (NULL
== (nn
= nn
->next
))
771 h
->flags
|= HTML_NOSPACE
;
773 h
->flags
|= HTML_NOSPACE
;
774 print_text(h
, nn
->string
);
775 h
->flags
|= HTML_NOSPACE
;
784 mdoc_ns_pre(MDOC_ARGS
)
787 h
->flags
|= HTML_NOSPACE
;
794 mdoc_ar_pre(MDOC_ARGS
)
798 tag
.key
= ATTR_CLASS
;
801 print_otag(h
, TAG_SPAN
, 1, &tag
);
808 mdoc_xx_pre(MDOC_ARGS
)
836 tag
.key
= ATTR_CLASS
;
839 print_otag(h
, TAG_SPAN
, 1, &tag
);
847 mdoc_bx_pre(MDOC_ARGS
)
849 const struct mdoc_node
*nn
;
852 tag
.key
= ATTR_CLASS
;
855 print_otag(h
, TAG_SPAN
, 1, &tag
);
857 for (nn
= n
->child
; nn
; nn
= nn
->next
)
858 print_mdoc_node(m
, nn
, h
);
861 h
->flags
|= HTML_NOSPACE
;
863 print_text(h
, "BSD");
870 mdoc_tbl_block_pre(MDOC_ARGS
, int t
, int w
, int o
, int c
)
873 const struct mdoc_node
*nn
;
881 buffmt(h
, "margin-left: %dem; clear: both;", o
);
884 buffmt(h
, "margin-left: %dem; clear: both;", w
+ o
);
888 if ( ! c
&& MDOC_Column
!= t
) {
889 for (nn
= n
; nn
; nn
= nn
->parent
) {
890 if (MDOC_BLOCK
!= nn
->type
)
904 if (MDOC_Diag
== t
&& n
->prev
)
905 if (NULL
== n
->prev
->body
->child
)
908 bufcat(h
, "padding-top: 1em;");
911 tag
.key
= ATTR_STYLE
;
913 print_otag(h
, TAG_DIV
, 1, &tag
);
920 mdoc_tbl_body_pre(MDOC_ARGS
, int t
, int w
)
923 print_otag(h
, TAG_DIV
, 0, NULL
);
930 mdoc_tbl_head_pre(MDOC_ARGS
, int t
, int w
)
940 print_otag(h
, TAG_DIV
, 0, NULL
);
943 buffmt(h
, "min-width: %dem;", w
);
944 bufcat(h
, "clear: none;");
945 if (n
->next
&& MDOC_HEAD
== n
->next
->type
)
946 bufcat(h
, "float: left;");
947 tag
.key
= ATTR_STYLE
;
949 print_otag(h
, TAG_DIV
, 1, &tag
);
952 buffmt(h
, "margin-left: -%dem; min-width: %dem;",
954 bufcat(h
, "clear: left;");
955 if (n
->next
&& n
->next
->child
)
956 bufcat(h
, "float: left;");
957 bufcat(h
, "padding-right: 1em;");
958 tag
.key
= ATTR_STYLE
;
960 print_otag(h
, TAG_DIV
, 1, &tag
);
966 tag
.key
= ATTR_CLASS
;
968 print_otag(h
, TAG_SPAN
, 1, &tag
);
971 ord
= SLIST_FIRST(&h
->ords
);
973 nbuf
[BUFSIZ
- 1] = 0;
974 (void)snprintf(nbuf
, BUFSIZ
- 1, "%d.", ord
->pos
++);
978 print_text(h
, "\\(en");
981 print_text(h
, "\\(hy");
984 print_text(h
, "\\(bu");
995 mdoc_tbl_pre(MDOC_ARGS
, int type
)
998 const struct mdoc_node
*bl
, *nn
;
1000 bl
= n
->parent
->parent
;
1001 if (MDOC_BLOCK
!= n
->type
)
1009 for (i
= 0; i
< (int)bl
->args
->argc
; i
++)
1010 if (MDOC_Width
== bl
->args
->argv
[i
].arg
) {
1011 assert(bl
->args
->argv
[i
].sz
);
1013 w
= a2width(bl
->args
->argv
[i
].value
[0]);
1014 } else if (MDOC_Offset
== bl
->args
->argv
[i
].arg
) {
1015 assert(bl
->args
->argv
[i
].sz
);
1016 o
= a2offs(bl
->args
->argv
[i
].value
[0]);
1017 } else if (MDOC_Compact
== bl
->args
->argv
[i
].arg
)
1020 if (MDOC_HEAD
== n
->type
&& MDOC_Column
== type
) {
1021 nn
= n
->parent
->child
;
1022 assert(nn
&& MDOC_HEAD
== nn
->type
);
1023 for (i
= 0; nn
&& nn
!= n
; nn
= nn
->next
, i
++)
1026 if (wp
>= 0 && i
< (int)bl
->args
[wp
].argv
->sz
)
1027 w
= a2width(bl
->args
->argv
[wp
].value
[i
]);
1056 return(mdoc_tbl_head_pre(m
, n
, h
, type
, w
));
1058 return(mdoc_tbl_body_pre(m
, n
, h
, type
, w
));
1064 return(mdoc_tbl_block_pre(m
, n
, h
, type
, w
, o
, c
));
1070 mdoc_bl_pre(MDOC_ARGS
)
1074 if (MDOC_BLOCK
!= n
->type
)
1076 if (MDOC_Enum
!= a2list(n
))
1079 /* Allocate an -enum on the stack of indices. */
1081 ord
= malloc(sizeof(struct ord
));
1083 err(EXIT_FAILURE
, "malloc");
1086 SLIST_INSERT_HEAD(&h
->ords
, ord
, entry
);
1094 mdoc_bl_post(MDOC_ARGS
)
1098 if (MDOC_BLOCK
!= n
->type
)
1100 if (MDOC_Enum
!= a2list(n
))
1103 ord
= SLIST_FIRST(&h
->ords
);
1105 SLIST_REMOVE_HEAD(&h
->ords
, entry
);
1111 mdoc_it_pre(MDOC_ARGS
)
1115 if (MDOC_BLOCK
== n
->type
)
1116 type
= a2list(n
->parent
->parent
);
1118 type
= a2list(n
->parent
->parent
->parent
);
1120 return(mdoc_tbl_pre(m
, n
, h
, type
));
1126 mdoc_ex_pre(MDOC_ARGS
)
1128 const struct mdoc_node
*nn
;
1130 struct htmlpair tag
;
1132 print_text(h
, "The");
1134 tag
.key
= ATTR_CLASS
;
1135 tag
.val
= "utility";
1137 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1138 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1139 print_text(h
, nn
->string
);
1142 h
->flags
|= HTML_NOSPACE
;
1144 if (nn
->next
&& NULL
== nn
->next
->next
)
1145 print_text(h
, ", and");
1149 h
->flags
&= ~HTML_NOSPACE
;
1153 print_text(h
, "utilities exit");
1155 print_text(h
, "utility exits");
1157 print_text(h
, "0 on success, and >0 if an error occurs.");
1164 mdoc_dq_pre(MDOC_ARGS
)
1167 if (MDOC_BODY
!= n
->type
)
1169 print_text(h
, "\\(lq");
1170 h
->flags
|= HTML_NOSPACE
;
1177 mdoc_dq_post(MDOC_ARGS
)
1180 if (MDOC_BODY
!= n
->type
)
1182 h
->flags
|= HTML_NOSPACE
;
1183 print_text(h
, "\\(rq");
1189 mdoc_pq_pre(MDOC_ARGS
)
1192 if (MDOC_BODY
!= n
->type
)
1194 print_text(h
, "\\&(");
1195 h
->flags
|= HTML_NOSPACE
;
1202 mdoc_pq_post(MDOC_ARGS
)
1205 if (MDOC_BODY
!= n
->type
)
1213 mdoc_sq_pre(MDOC_ARGS
)
1216 if (MDOC_BODY
!= n
->type
)
1218 print_text(h
, "\\(oq");
1219 h
->flags
|= HTML_NOSPACE
;
1226 mdoc_sq_post(MDOC_ARGS
)
1229 if (MDOC_BODY
!= n
->type
)
1231 h
->flags
|= HTML_NOSPACE
;
1232 print_text(h
, "\\(aq");
1238 mdoc_em_pre(MDOC_ARGS
)
1240 struct htmlpair tag
;
1242 tag
.key
= ATTR_CLASS
;
1245 print_otag(h
, TAG_SPAN
, 1, &tag
);
1252 mdoc_d1_pre(MDOC_ARGS
)
1254 struct htmlpair tag
[2];
1256 if (MDOC_BLOCK
!= n
->type
)
1259 buffmt(h
, "margin-left: %dem;", INDENT
);
1261 tag
[0].key
= ATTR_CLASS
;
1263 tag
[1].key
= ATTR_STYLE
;
1264 tag
[1].val
= h
->buf
;
1266 print_otag(h
, TAG_DIV
, 2, tag
);
1273 mdoc_sx_pre(MDOC_ARGS
)
1275 struct htmlpair tag
[2];
1276 const struct mdoc_node
*nn
;
1279 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1280 bufcat(h
, nn
->string
);
1285 tag
[0].key
= ATTR_HREF
;
1286 tag
[0].val
= h
->buf
;
1287 tag
[1].key
= ATTR_CLASS
;
1288 tag
[1].val
= "link-sec";
1290 print_otag(h
, TAG_A
, 2, tag
);
1297 mdoc_aq_pre(MDOC_ARGS
)
1300 if (MDOC_BODY
!= n
->type
)
1302 print_text(h
, "\\(la");
1303 h
->flags
|= HTML_NOSPACE
;
1310 mdoc_aq_post(MDOC_ARGS
)
1313 if (MDOC_BODY
!= n
->type
)
1315 h
->flags
|= HTML_NOSPACE
;
1316 print_text(h
, "\\(ra");
1322 mdoc_bd_pre(MDOC_ARGS
)
1324 struct htmlpair tag
[2];
1326 const struct mdoc_node
*bl
, *nn
;
1328 if (MDOC_BLOCK
== n
->type
)
1330 else if (MDOC_HEAD
== n
->type
)
1337 for (i
= 0; i
< (int)bl
->args
->argc
; i
++)
1338 switch (bl
->args
->argv
[i
].arg
) {
1340 assert(bl
->args
->argv
[i
].sz
);
1341 o
= a2offs(bl
->args
->argv
[i
].value
[0]);
1343 case (MDOC_Compact
):
1350 case (MDOC_Unfilled
):
1352 case (MDOC_Literal
):
1353 t
= bl
->args
->argv
[i
].arg
;
1357 if (MDOC_BLOCK
== n
->type
) {
1359 buffmt(h
, "margin-left: %dem;", o
);
1361 for (nn
= n
; nn
; nn
= nn
->parent
) {
1362 if (MDOC_BLOCK
!= nn
->type
)
1377 bufcat(h
, "margin-top: 1em;");
1379 tag
[0].key
= ATTR_STYLE
;
1380 tag
[0].val
= h
->buf
;
1381 print_otag(h
, TAG_DIV
, 1, tag
);
1385 if (MDOC_Unfilled
!= t
&& MDOC_Literal
!= t
)
1388 bufcat(h
, "white-space: pre;");
1389 tag
[0].key
= ATTR_STYLE
;
1390 tag
[0].val
= h
->buf
;
1391 tag
[1].key
= ATTR_CLASS
;
1394 print_otag(h
, TAG_DIV
, 2, tag
);
1396 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1397 print_mdoc_node(m
, nn
, h
);
1398 if (NULL
== nn
->next
)
1400 if (nn
->prev
&& nn
->prev
->line
< nn
->line
)
1401 print_text(h
, "\n");
1410 mdoc_pa_pre(MDOC_ARGS
)
1412 struct htmlpair tag
;
1414 tag
.key
= ATTR_CLASS
;
1417 print_otag(h
, TAG_SPAN
, 1, &tag
);
1424 mdoc_ad_pre(MDOC_ARGS
)
1426 struct htmlpair tag
;
1428 tag
.key
= ATTR_CLASS
;
1430 print_otag(h
, TAG_SPAN
, 1, &tag
);
1437 mdoc_an_pre(MDOC_ARGS
)
1439 struct htmlpair tag
;
1441 /* TODO: -split and -nosplit (see termp_an_pre()). */
1443 tag
.key
= ATTR_CLASS
;
1445 print_otag(h
, TAG_SPAN
, 1, &tag
);
1452 mdoc_cd_pre(MDOC_ARGS
)
1454 struct htmlpair tag
;
1456 tag
.key
= ATTR_CLASS
;
1458 print_otag(h
, TAG_SPAN
, 1, &tag
);
1465 mdoc_dv_pre(MDOC_ARGS
)
1467 struct htmlpair tag
;
1469 tag
.key
= ATTR_CLASS
;
1471 print_otag(h
, TAG_SPAN
, 1, &tag
);
1478 mdoc_ev_pre(MDOC_ARGS
)
1480 struct htmlpair tag
;
1482 tag
.key
= ATTR_CLASS
;
1484 print_otag(h
, TAG_SPAN
, 1, &tag
);
1491 mdoc_er_pre(MDOC_ARGS
)
1493 struct htmlpair tag
;
1495 tag
.key
= ATTR_CLASS
;
1497 print_otag(h
, TAG_SPAN
, 1, &tag
);
1504 mdoc_fa_pre(MDOC_ARGS
)
1506 const struct mdoc_node
*nn
;
1507 struct htmlpair tag
;
1510 tag
.key
= ATTR_CLASS
;
1513 if (n
->parent
->tok
!= MDOC_Fo
) {
1514 print_otag(h
, TAG_SPAN
, 1, &tag
);
1518 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1519 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1520 print_text(h
, nn
->string
);
1526 if (n
->child
&& n
->next
&& n
->next
->tok
== MDOC_Fa
)
1535 mdoc_fd_pre(MDOC_ARGS
)
1537 struct htmlpair tag
;
1539 if (SEC_SYNOPSIS
== n
->sec
) {
1540 if (n
->next
&& MDOC_Fd
!= n
->next
->tok
) {
1541 tag
.key
= ATTR_STYLE
;
1542 tag
.val
= "margin-bottom: 1em;";
1543 print_otag(h
, TAG_DIV
, 1, &tag
);
1545 print_otag(h
, TAG_DIV
, 0, NULL
);
1548 tag
.key
= ATTR_CLASS
;
1550 print_otag(h
, TAG_SPAN
, 1, &tag
);
1557 mdoc_vt_pre(MDOC_ARGS
)
1559 struct htmlpair tag
;
1561 if (SEC_SYNOPSIS
== n
->sec
) {
1562 if (n
->next
&& MDOC_Vt
!= n
->next
->tok
) {
1563 tag
.key
= ATTR_STYLE
;
1564 tag
.val
= "margin-bottom: 1em;";
1565 print_otag(h
, TAG_DIV
, 1, &tag
);
1567 print_otag(h
, TAG_DIV
, 0, NULL
);
1570 tag
.key
= ATTR_CLASS
;
1572 print_otag(h
, TAG_SPAN
, 1, &tag
);
1579 mdoc_ft_pre(MDOC_ARGS
)
1581 struct htmlpair tag
;
1583 if (SEC_SYNOPSIS
== n
->sec
) {
1584 if (n
->prev
&& MDOC_Fo
== n
->prev
->tok
) {
1585 tag
.key
= ATTR_STYLE
;
1586 tag
.val
= "margin-top: 1em;";
1587 print_otag(h
, TAG_DIV
, 1, &tag
);
1589 print_otag(h
, TAG_DIV
, 0, NULL
);
1592 tag
.key
= ATTR_CLASS
;
1594 print_otag(h
, TAG_SPAN
, 1, &tag
);
1601 mdoc_fn_pre(MDOC_ARGS
)
1604 struct htmlpair tag
[2];
1605 const struct mdoc_node
*nn
;
1607 const char *sp
, *ep
;
1610 if (SEC_SYNOPSIS
== n
->sec
) {
1611 bufcat(h
, "margin-left: 6em;");
1612 bufcat(h
, "text-indent: -6em;");
1614 bufcat(h
, "margin-bottom: 1em;");
1615 tag
[0].key
= ATTR_STYLE
;
1616 tag
[0].val
= h
->buf
;
1617 print_otag(h
, TAG_DIV
, 1, tag
);
1620 /* Split apart into type and name. */
1621 assert(n
->child
->string
);
1622 sp
= n
->child
->string
;
1624 if ((ep
= strchr(sp
, ' '))) {
1625 tag
[0].key
= ATTR_CLASS
;
1626 tag
[0].val
= "ftype";
1628 t
= print_otag(h
, TAG_SPAN
, 1, tag
);
1631 sz
= MIN((int)(ep
- sp
), BUFSIZ
- 1);
1632 (void)memcpy(nbuf
, sp
, (size_t)sz
);
1634 print_text(h
, nbuf
);
1636 ep
= strchr(sp
, ' ');
1641 tag
[0].key
= ATTR_CLASS
;
1642 tag
[0].val
= "fname";
1643 t
= print_otag(h
, TAG_SPAN
, 1, tag
);
1646 (void)strlcpy(nbuf
, sp
, BUFSIZ
);
1647 print_text(h
, nbuf
);
1652 h
->flags
|= HTML_NOSPACE
;
1655 for (nn
= n
->child
->next
; nn
; nn
= nn
->next
) {
1657 tag
[i
].key
= ATTR_CLASS
;
1658 tag
[i
++].val
= "farg";
1659 if (SEC_SYNOPSIS
== n
->sec
) {
1660 tag
[i
].key
= ATTR_STYLE
;
1661 tag
[i
++].val
= "white-space: nowrap;";
1664 t
= print_otag(h
, TAG_SPAN
, i
, tag
);
1665 print_text(h
, nn
->string
);
1673 if (SEC_SYNOPSIS
== n
->sec
)
1682 mdoc_sp_pre(MDOC_ARGS
)
1685 struct htmlpair tag
;
1689 len
= n
->child
? atoi(n
->child
->string
) : 1;
1699 buffmt(h
, "height: %dem", len
);
1700 tag
.key
= ATTR_STYLE
;
1702 print_otag(h
, TAG_DIV
, 1, &tag
);
1710 mdoc_brq_pre(MDOC_ARGS
)
1713 if (MDOC_BODY
!= n
->type
)
1715 print_text(h
, "\\(lC");
1716 h
->flags
|= HTML_NOSPACE
;
1723 mdoc_brq_post(MDOC_ARGS
)
1726 if (MDOC_BODY
!= n
->type
)
1728 h
->flags
|= HTML_NOSPACE
;
1729 print_text(h
, "\\(rC");
1735 mdoc_lk_pre(MDOC_ARGS
)
1737 const struct mdoc_node
*nn
;
1738 struct htmlpair tag
[2];
1742 tag
[0].key
= ATTR_CLASS
;
1743 tag
[0].val
= "link-ext";
1744 tag
[1].key
= ATTR_HREF
;
1745 tag
[1].val
= nn
->string
;
1747 print_otag(h
, TAG_A
, 2, tag
);
1749 if (NULL
== nn
->next
)
1752 for (nn
= nn
->next
; nn
; nn
= nn
->next
)
1753 print_text(h
, nn
->string
);
1761 mdoc_mt_pre(MDOC_ARGS
)
1763 struct htmlpair tag
[2];
1765 const struct mdoc_node
*nn
;
1767 tag
[0].key
= ATTR_CLASS
;
1768 tag
[0].val
= "link-mail";
1770 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1772 bufcat(h
, "mailto:");
1773 bufcat(h
, nn
->string
);
1775 tag
[1].key
= ATTR_HREF
;
1776 tag
[1].val
= h
->buf
;
1778 t
= print_otag(h
, TAG_A
, 2, tag
);
1779 print_text(h
, nn
->string
);
1789 mdoc_fo_pre(MDOC_ARGS
)
1791 struct htmlpair tag
;
1793 if (MDOC_BODY
== n
->type
) {
1794 h
->flags
|= HTML_NOSPACE
;
1796 h
->flags
|= HTML_NOSPACE
;
1798 } else if (MDOC_BLOCK
== n
->type
)
1801 tag
.key
= ATTR_CLASS
;
1803 print_otag(h
, TAG_SPAN
, 1, &tag
);
1810 mdoc_fo_post(MDOC_ARGS
)
1812 if (MDOC_BODY
!= n
->type
)
1814 h
->flags
|= HTML_NOSPACE
;
1816 h
->flags
|= HTML_NOSPACE
;
1823 mdoc_in_pre(MDOC_ARGS
)
1825 const struct mdoc_node
*nn
;
1826 struct htmlpair tag
[2];
1830 if (SEC_SYNOPSIS
== n
->sec
) {
1831 if (n
->next
&& MDOC_In
!= n
->next
->tok
) {
1832 tag
[0].key
= ATTR_STYLE
;
1833 tag
[0].val
= "margin-bottom: 1em;";
1834 print_otag(h
, TAG_DIV
, 1, tag
);
1836 print_otag(h
, TAG_DIV
, 0, NULL
);
1839 tag
[0].key
= ATTR_CLASS
;
1840 tag
[0].val
= "includes";
1842 print_otag(h
, TAG_SPAN
, 1, tag
);
1844 if (SEC_SYNOPSIS
== n
->sec
)
1845 print_text(h
, "#include");
1848 h
->flags
|= HTML_NOSPACE
;
1850 /* XXX -- see warning in termp_in_post(). */
1852 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1853 assert(MDOC_TEXT
== nn
->type
);
1855 tag
[i
].key
= ATTR_CLASS
;
1856 tag
[i
++].val
= "link-includes";
1857 if (h
->base_includes
) {
1858 buffmt_includes(h
, nn
->string
);
1859 tag
[i
].key
= ATTR_HREF
;
1860 tag
[i
++].val
= h
->buf
;
1862 t
= print_otag(h
, TAG_A
, i
, tag
);
1863 print_mdoc_node(m
, nn
, h
);
1867 h
->flags
|= HTML_NOSPACE
;
1876 mdoc_ic_pre(MDOC_ARGS
)
1878 struct htmlpair tag
;
1880 tag
.key
= ATTR_CLASS
;
1883 print_otag(h
, TAG_SPAN
, 1, &tag
);
1890 mdoc_rv_pre(MDOC_ARGS
)
1892 const struct mdoc_node
*nn
;
1893 struct htmlpair tag
;
1896 print_otag(h
, TAG_DIV
, 0, NULL
);
1898 print_text(h
, "The");
1900 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1901 tag
.key
= ATTR_CLASS
;
1903 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1904 print_text(h
, nn
->string
);
1907 h
->flags
|= HTML_NOSPACE
;
1908 if (nn
->next
&& NULL
== nn
->next
->next
)
1909 print_text(h
, "(), and");
1911 print_text(h
, "(),");
1913 print_text(h
, "()");
1917 print_text(h
, "functions return");
1919 print_text(h
, "function returns");
1921 print_text(h
, "the value 0 if successful; otherwise the value "
1922 "-1 is returned and the global variable");
1924 tag
.key
= ATTR_CLASS
;
1926 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1927 print_text(h
, "errno");
1929 print_text(h
, "is set to indicate the error.");
1936 mdoc_va_pre(MDOC_ARGS
)
1938 struct htmlpair tag
;
1940 tag
.key
= ATTR_CLASS
;
1942 print_otag(h
, TAG_SPAN
, 1, &tag
);
1949 mdoc_bq_pre(MDOC_ARGS
)
1952 if (MDOC_BODY
!= n
->type
)
1954 print_text(h
, "\\(lB");
1955 h
->flags
|= HTML_NOSPACE
;
1962 mdoc_bq_post(MDOC_ARGS
)
1965 if (MDOC_BODY
!= n
->type
)
1967 h
->flags
|= HTML_NOSPACE
;
1968 print_text(h
, "\\(rB");
1974 mdoc_ap_pre(MDOC_ARGS
)
1977 h
->flags
|= HTML_NOSPACE
;
1978 print_text(h
, "\\(aq");
1979 h
->flags
|= HTML_NOSPACE
;
1986 mdoc_bf_pre(MDOC_ARGS
)
1989 struct htmlpair tag
[2];
1991 if (MDOC_HEAD
== n
->type
)
1993 else if (MDOC_BLOCK
!= n
->type
)
1996 tag
[0].key
= ATTR_CLASS
;
1999 if (n
->head
->child
) {
2000 if ( ! strcmp("Em", n
->head
->child
->string
))
2001 tag
[0].val
= "emph";
2002 else if ( ! strcmp("Sy", n
->head
->child
->string
))
2003 tag
[0].val
= "symb";
2004 else if ( ! strcmp("Li", n
->head
->child
->string
))
2008 for (i
= 0; i
< (int)n
->args
->argc
; i
++)
2009 switch (n
->args
->argv
[i
].arg
) {
2010 case (MDOC_Symbolic
):
2011 tag
[0].val
= "symb";
2013 case (MDOC_Literal
):
2016 case (MDOC_Emphasis
):
2017 tag
[0].val
= "emph";
2024 /* FIXME: div's have spaces stripped--we want them. */
2027 tag
[1].key
= ATTR_STYLE
;
2028 tag
[1].val
= "display: inline; margin-right: 1em;";
2029 print_otag(h
, TAG_DIV
, 2, tag
);
2036 mdoc_ms_pre(MDOC_ARGS
)
2038 struct htmlpair tag
;
2040 tag
.key
= ATTR_CLASS
;
2042 print_otag(h
, TAG_SPAN
, 1, &tag
);
2049 mdoc_pf_pre(MDOC_ARGS
)
2052 h
->flags
|= HTML_IGNDELIM
;
2059 mdoc_pf_post(MDOC_ARGS
)
2062 h
->flags
&= ~HTML_IGNDELIM
;
2063 h
->flags
|= HTML_NOSPACE
;
2069 mdoc_rs_pre(MDOC_ARGS
)
2071 struct htmlpair tag
;
2073 if (MDOC_BLOCK
!= n
->type
)
2076 if (n
->prev
&& SEC_SEE_ALSO
== n
->sec
) {
2077 tag
.key
= ATTR_STYLE
;
2078 tag
.val
= "margin-top: 1em;";
2079 print_otag(h
, TAG_DIV
, 1, &tag
);
2082 tag
.key
= ATTR_CLASS
;
2084 print_otag(h
, TAG_SPAN
, 1, &tag
);
2092 mdoc_li_pre(MDOC_ARGS
)
2094 struct htmlpair tag
;
2096 tag
.key
= ATTR_CLASS
;
2099 print_otag(h
, TAG_SPAN
, 1, &tag
);
2106 mdoc_sy_pre(MDOC_ARGS
)
2108 struct htmlpair tag
;
2110 tag
.key
= ATTR_CLASS
;
2113 print_otag(h
, TAG_SPAN
, 1, &tag
);
2120 mdoc_bt_pre(MDOC_ARGS
)
2123 print_text(h
, "is currently in beta test.");
2130 mdoc_ud_pre(MDOC_ARGS
)
2133 print_text(h
, "currently under development.");
2140 mdoc_lb_pre(MDOC_ARGS
)
2142 struct htmlpair tag
;
2144 tag
.key
= ATTR_CLASS
;
2147 if (SEC_SYNOPSIS
== n
->sec
)
2148 print_otag(h
, TAG_DIV
, 0, NULL
);
2150 print_otag(h
, TAG_SPAN
, 1, &tag
);
2157 mdoc__x_pre(MDOC_ARGS
)
2159 struct htmlpair tag
;
2161 tag
.key
= ATTR_CLASS
;
2165 tag
.val
= "ref-auth";
2168 tag
.val
= "ref-book";
2171 tag
.val
= "ref-city";
2174 tag
.val
= "ref-date";
2177 tag
.val
= "ref-issue";
2180 tag
.val
= "ref-jrnl";
2183 tag
.val
= "ref-num";
2186 tag
.val
= "ref-opt";
2189 tag
.val
= "ref-page";
2192 tag
.val
= "ref-corp";
2195 tag
.val
= "ref-rep";
2198 print_text(h
, "\\(lq");
2199 h
->flags
|= HTML_NOSPACE
;
2200 tag
.val
= "ref-title";
2203 tag
.val
= "ref-vol";
2210 print_otag(h
, TAG_SPAN
, 1, &tag
);
2217 mdoc__x_post(MDOC_ARGS
)
2220 h
->flags
|= HTML_NOSPACE
;
2223 print_text(h
, "\\(rq");
2224 h
->flags
|= HTML_NOSPACE
;
2229 print_text(h
, n
->next
? "," : ".");