]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_html.c
1 /* $Id: mdoc_html.c,v 1.123 2010/12/17 00:18:29 kristaps Exp $ */
3 * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
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.
21 #include <sys/types.h>
39 #define MDOC_ARGS const struct mdoc_meta *m, \
40 const struct mdoc_node *n, \
44 #define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b))
48 int (*pre
)(MDOC_ARGS
);
49 void (*post
)(MDOC_ARGS
);
52 static void print_mdoc(MDOC_ARGS
);
53 static void print_mdoc_head(MDOC_ARGS
);
54 static void print_mdoc_node(MDOC_ARGS
);
55 static void print_mdoc_nodelist(MDOC_ARGS
);
56 static void synopsis_pre(struct html
*,
57 const struct mdoc_node
*);
59 static void a2width(const char *, struct roffsu
*);
60 static void a2offs(const char *, struct roffsu
*);
62 static void mdoc_root_post(MDOC_ARGS
);
63 static int mdoc_root_pre(MDOC_ARGS
);
65 static void mdoc__x_post(MDOC_ARGS
);
66 static int mdoc__x_pre(MDOC_ARGS
);
67 static int mdoc_ad_pre(MDOC_ARGS
);
68 static int mdoc_an_pre(MDOC_ARGS
);
69 static int mdoc_ap_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_bk_post(MDOC_ARGS
);
74 static int mdoc_bk_pre(MDOC_ARGS
);
75 static int mdoc_bl_pre(MDOC_ARGS
);
76 static int mdoc_bt_pre(MDOC_ARGS
);
77 static int mdoc_bx_pre(MDOC_ARGS
);
78 static int mdoc_cd_pre(MDOC_ARGS
);
79 static int mdoc_d1_pre(MDOC_ARGS
);
80 static int mdoc_dv_pre(MDOC_ARGS
);
81 static int mdoc_fa_pre(MDOC_ARGS
);
82 static int mdoc_fd_pre(MDOC_ARGS
);
83 static int mdoc_fl_pre(MDOC_ARGS
);
84 static int mdoc_fn_pre(MDOC_ARGS
);
85 static int mdoc_ft_pre(MDOC_ARGS
);
86 static int mdoc_em_pre(MDOC_ARGS
);
87 static int mdoc_er_pre(MDOC_ARGS
);
88 static int mdoc_ev_pre(MDOC_ARGS
);
89 static int mdoc_ex_pre(MDOC_ARGS
);
90 static void mdoc_fo_post(MDOC_ARGS
);
91 static int mdoc_fo_pre(MDOC_ARGS
);
92 static int mdoc_ic_pre(MDOC_ARGS
);
93 static int mdoc_igndelim_pre(MDOC_ARGS
);
94 static int mdoc_in_pre(MDOC_ARGS
);
95 static int mdoc_it_pre(MDOC_ARGS
);
96 static int mdoc_lb_pre(MDOC_ARGS
);
97 static int mdoc_li_pre(MDOC_ARGS
);
98 static int mdoc_lk_pre(MDOC_ARGS
);
99 static int mdoc_mt_pre(MDOC_ARGS
);
100 static int mdoc_ms_pre(MDOC_ARGS
);
101 static int mdoc_nd_pre(MDOC_ARGS
);
102 static int mdoc_nm_pre(MDOC_ARGS
);
103 static int mdoc_ns_pre(MDOC_ARGS
);
104 static int mdoc_pa_pre(MDOC_ARGS
);
105 static void mdoc_pf_post(MDOC_ARGS
);
106 static int mdoc_pp_pre(MDOC_ARGS
);
107 static void mdoc_quote_post(MDOC_ARGS
);
108 static int mdoc_quote_pre(MDOC_ARGS
);
109 static int mdoc_rs_pre(MDOC_ARGS
);
110 static int mdoc_rv_pre(MDOC_ARGS
);
111 static int mdoc_sh_pre(MDOC_ARGS
);
112 static int mdoc_sm_pre(MDOC_ARGS
);
113 static int mdoc_sp_pre(MDOC_ARGS
);
114 static int mdoc_ss_pre(MDOC_ARGS
);
115 static int mdoc_sx_pre(MDOC_ARGS
);
116 static int mdoc_sy_pre(MDOC_ARGS
);
117 static int mdoc_ud_pre(MDOC_ARGS
);
118 static int mdoc_va_pre(MDOC_ARGS
);
119 static int mdoc_vt_pre(MDOC_ARGS
);
120 static int mdoc_xr_pre(MDOC_ARGS
);
121 static int mdoc_xx_pre(MDOC_ARGS
);
123 static const struct htmlmdoc mdocs
[MDOC_MAX
] = {
124 {mdoc_ap_pre
, NULL
}, /* Ap */
125 {NULL
, NULL
}, /* Dd */
126 {NULL
, NULL
}, /* Dt */
127 {NULL
, NULL
}, /* Os */
128 {mdoc_sh_pre
, NULL
}, /* Sh */
129 {mdoc_ss_pre
, NULL
}, /* Ss */
130 {mdoc_pp_pre
, NULL
}, /* Pp */
131 {mdoc_d1_pre
, NULL
}, /* D1 */
132 {mdoc_d1_pre
, NULL
}, /* Dl */
133 {mdoc_bd_pre
, NULL
}, /* Bd */
134 {NULL
, NULL
}, /* Ed */
135 {mdoc_bl_pre
, NULL
}, /* Bl */
136 {NULL
, NULL
}, /* El */
137 {mdoc_it_pre
, NULL
}, /* It */
138 {mdoc_ad_pre
, NULL
}, /* Ad */
139 {mdoc_an_pre
, NULL
}, /* An */
140 {mdoc_ar_pre
, NULL
}, /* Ar */
141 {mdoc_cd_pre
, NULL
}, /* Cd */
142 {mdoc_fl_pre
, NULL
}, /* Cm */
143 {mdoc_dv_pre
, NULL
}, /* Dv */
144 {mdoc_er_pre
, NULL
}, /* Er */
145 {mdoc_ev_pre
, NULL
}, /* Ev */
146 {mdoc_ex_pre
, NULL
}, /* Ex */
147 {mdoc_fa_pre
, NULL
}, /* Fa */
148 {mdoc_fd_pre
, NULL
}, /* Fd */
149 {mdoc_fl_pre
, NULL
}, /* Fl */
150 {mdoc_fn_pre
, NULL
}, /* Fn */
151 {mdoc_ft_pre
, NULL
}, /* Ft */
152 {mdoc_ic_pre
, NULL
}, /* Ic */
153 {mdoc_in_pre
, NULL
}, /* In */
154 {mdoc_li_pre
, NULL
}, /* Li */
155 {mdoc_nd_pre
, NULL
}, /* Nd */
156 {mdoc_nm_pre
, NULL
}, /* Nm */
157 {mdoc_quote_pre
, mdoc_quote_post
}, /* Op */
158 {NULL
, NULL
}, /* Ot */
159 {mdoc_pa_pre
, NULL
}, /* Pa */
160 {mdoc_rv_pre
, NULL
}, /* Rv */
161 {NULL
, NULL
}, /* St */
162 {mdoc_va_pre
, NULL
}, /* Va */
163 {mdoc_vt_pre
, NULL
}, /* Vt */
164 {mdoc_xr_pre
, NULL
}, /* Xr */
165 {mdoc__x_pre
, mdoc__x_post
}, /* %A */
166 {mdoc__x_pre
, mdoc__x_post
}, /* %B */
167 {mdoc__x_pre
, mdoc__x_post
}, /* %D */
168 {mdoc__x_pre
, mdoc__x_post
}, /* %I */
169 {mdoc__x_pre
, mdoc__x_post
}, /* %J */
170 {mdoc__x_pre
, mdoc__x_post
}, /* %N */
171 {mdoc__x_pre
, mdoc__x_post
}, /* %O */
172 {mdoc__x_pre
, mdoc__x_post
}, /* %P */
173 {mdoc__x_pre
, mdoc__x_post
}, /* %R */
174 {mdoc__x_pre
, mdoc__x_post
}, /* %T */
175 {mdoc__x_pre
, mdoc__x_post
}, /* %V */
176 {NULL
, NULL
}, /* Ac */
177 {mdoc_quote_pre
, mdoc_quote_post
}, /* Ao */
178 {mdoc_quote_pre
, mdoc_quote_post
}, /* Aq */
179 {NULL
, NULL
}, /* At */
180 {NULL
, NULL
}, /* Bc */
181 {mdoc_bf_pre
, NULL
}, /* Bf */
182 {mdoc_quote_pre
, mdoc_quote_post
}, /* Bo */
183 {mdoc_quote_pre
, mdoc_quote_post
}, /* Bq */
184 {mdoc_xx_pre
, NULL
}, /* Bsx */
185 {mdoc_bx_pre
, NULL
}, /* Bx */
186 {NULL
, NULL
}, /* Db */
187 {NULL
, NULL
}, /* Dc */
188 {mdoc_quote_pre
, mdoc_quote_post
}, /* Do */
189 {mdoc_quote_pre
, mdoc_quote_post
}, /* Dq */
190 {NULL
, NULL
}, /* Ec */ /* FIXME: no space */
191 {NULL
, NULL
}, /* Ef */
192 {mdoc_em_pre
, NULL
}, /* Em */
193 {NULL
, NULL
}, /* Eo */
194 {mdoc_xx_pre
, NULL
}, /* Fx */
195 {mdoc_ms_pre
, NULL
}, /* Ms */
196 {mdoc_igndelim_pre
, NULL
}, /* No */
197 {mdoc_ns_pre
, NULL
}, /* Ns */
198 {mdoc_xx_pre
, NULL
}, /* Nx */
199 {mdoc_xx_pre
, NULL
}, /* Ox */
200 {NULL
, NULL
}, /* Pc */
201 {mdoc_igndelim_pre
, mdoc_pf_post
}, /* Pf */
202 {mdoc_quote_pre
, mdoc_quote_post
}, /* Po */
203 {mdoc_quote_pre
, mdoc_quote_post
}, /* Pq */
204 {NULL
, NULL
}, /* Qc */
205 {mdoc_quote_pre
, mdoc_quote_post
}, /* Ql */
206 {mdoc_quote_pre
, mdoc_quote_post
}, /* Qo */
207 {mdoc_quote_pre
, mdoc_quote_post
}, /* Qq */
208 {NULL
, NULL
}, /* Re */
209 {mdoc_rs_pre
, NULL
}, /* Rs */
210 {NULL
, NULL
}, /* Sc */
211 {mdoc_quote_pre
, mdoc_quote_post
}, /* So */
212 {mdoc_quote_pre
, mdoc_quote_post
}, /* Sq */
213 {mdoc_sm_pre
, NULL
}, /* Sm */
214 {mdoc_sx_pre
, NULL
}, /* Sx */
215 {mdoc_sy_pre
, NULL
}, /* Sy */
216 {NULL
, NULL
}, /* Tn */
217 {mdoc_xx_pre
, NULL
}, /* Ux */
218 {NULL
, NULL
}, /* Xc */
219 {NULL
, NULL
}, /* Xo */
220 {mdoc_fo_pre
, mdoc_fo_post
}, /* Fo */
221 {NULL
, NULL
}, /* Fc */
222 {mdoc_quote_pre
, mdoc_quote_post
}, /* Oo */
223 {NULL
, NULL
}, /* Oc */
224 {mdoc_bk_pre
, mdoc_bk_post
}, /* Bk */
225 {NULL
, NULL
}, /* Ek */
226 {mdoc_bt_pre
, NULL
}, /* Bt */
227 {NULL
, NULL
}, /* Hf */
228 {NULL
, NULL
}, /* Fr */
229 {mdoc_ud_pre
, NULL
}, /* Ud */
230 {mdoc_lb_pre
, NULL
}, /* Lb */
231 {mdoc_pp_pre
, NULL
}, /* Lp */
232 {mdoc_lk_pre
, NULL
}, /* Lk */
233 {mdoc_mt_pre
, NULL
}, /* Mt */
234 {mdoc_quote_pre
, mdoc_quote_post
}, /* Brq */
235 {mdoc_quote_pre
, mdoc_quote_post
}, /* Bro */
236 {NULL
, NULL
}, /* Brc */
237 {mdoc__x_pre
, mdoc__x_post
}, /* %C */
238 {NULL
, NULL
}, /* Es */ /* TODO */
239 {NULL
, NULL
}, /* En */ /* TODO */
240 {mdoc_xx_pre
, NULL
}, /* Dx */
241 {mdoc__x_pre
, mdoc__x_post
}, /* %Q */
242 {mdoc_sp_pre
, NULL
}, /* br */
243 {mdoc_sp_pre
, NULL
}, /* sp */
244 {mdoc__x_pre
, mdoc__x_post
}, /* %U */
245 {NULL
, NULL
}, /* Ta */
248 static const char * const lists
[LIST_MAX
] = {
264 html_mdoc(void *arg
, const struct mdoc
*m
)
269 h
= (struct html
*)arg
;
272 t
= print_otag(h
, TAG_HTML
, 0, NULL
);
273 print_mdoc(mdoc_meta(m
), mdoc_node(m
), h
);
281 * Calculate the scaling unit passed in a `-width' argument. This uses
282 * either a native scaling unit (e.g., 1i, 2m) or the string length of
286 a2width(const char *p
, struct roffsu
*su
)
289 if ( ! a2roffsu(p
, su
, SCALE_MAX
)) {
291 su
->scale
= (int)strlen(p
);
297 * See the same function in mdoc_term.c for documentation.
300 synopsis_pre(struct html
*h
, const struct mdoc_node
*n
)
305 if (NULL
== n
->prev
|| ! (MDOC_SYNPRETTY
& n
->flags
))
308 SCALE_VS_INIT(&su
, 1);
309 bufcat_su(h
, "margin-top", &su
);
310 PAIR_STYLE_INIT(&tag
, h
);
312 if (n
->prev
->tok
== n
->tok
&&
316 print_otag(h
, TAG_DIV
, 0, NULL
);
320 switch (n
->prev
->tok
) {
330 print_otag(h
, TAG_DIV
, 1, &tag
);
333 if (MDOC_Fn
!= n
->tok
&& MDOC_Fo
!= n
->tok
) {
334 print_otag(h
, TAG_DIV
, 1, &tag
);
339 print_otag(h
, TAG_DIV
, 0, NULL
);
346 * Calculate the scaling unit passed in an `-offset' argument. This
347 * uses either a native scaling unit (e.g., 1i, 2m), one of a set of
348 * predefined strings (indent, etc.), or the string length of the value.
351 a2offs(const char *p
, struct roffsu
*su
)
354 /* FIXME: "right"? */
356 if (0 == strcmp(p
, "left"))
357 SCALE_HS_INIT(su
, 0);
358 else if (0 == strcmp(p
, "indent"))
359 SCALE_HS_INIT(su
, INDENT
);
360 else if (0 == strcmp(p
, "indent-two"))
361 SCALE_HS_INIT(su
, INDENT
* 2);
362 else if ( ! a2roffsu(p
, su
, SCALE_MAX
)) {
364 su
->scale
= (int)strlen(p
);
370 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
);
379 print_mdoc_nodelist(m
, n
, h
);
386 print_mdoc_head(MDOC_ARGS
)
391 buffmt(h
, "%s(%s)", m
->title
, m
->msec
);
399 print_otag(h
, TAG_TITLE
, 0, NULL
);
400 print_text(h
, h
->buf
);
405 print_mdoc_nodelist(MDOC_ARGS
)
408 print_mdoc_node(m
, n
, h
);
410 print_mdoc_nodelist(m
, n
->next
, h
);
415 print_mdoc_node(MDOC_ARGS
)
426 child
= mdoc_root_pre(m
, n
, h
);
429 print_text(h
, n
->string
);
432 if (mdocs
[n
->tok
].pre
&& ENDBODY_NOT
== n
->end
)
433 child
= (*mdocs
[n
->tok
].pre
)(m
, n
, h
);
437 if (HTML_KEEP
& h
->flags
) {
438 if (n
->prev
&& n
->prev
->line
!= n
->line
) {
439 h
->flags
&= ~HTML_KEEP
;
440 h
->flags
|= HTML_PREKEEP
;
441 } else if (NULL
== n
->prev
) {
442 if (n
->parent
&& n
->parent
->line
!= n
->line
) {
443 h
->flags
&= ~HTML_KEEP
;
444 h
->flags
|= HTML_PREKEEP
;
449 if (child
&& n
->child
)
450 print_mdoc_nodelist(m
, n
->child
, h
);
457 mdoc_root_post(m
, n
, h
);
460 if (mdocs
[n
->tok
].post
&& ENDBODY_NOT
== n
->end
)
461 (*mdocs
[n
->tok
].post
)(m
, n
, h
);
469 mdoc_root_post(MDOC_ARGS
)
471 struct htmlpair tag
[3];
475 time2a(m
->date
, b
, DATESIZ
);
477 PAIR_CLASS_INIT(&tag
[0], "footer");
478 bufcat_style(h
, "width", "100%");
479 PAIR_STYLE_INIT(&tag
[1], h
);
480 PAIR_SUMMARY_INIT(&tag
[2], "footer");
482 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
483 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
486 bufcat_style(h
, "width", "50%");
487 PAIR_STYLE_INIT(&tag
[0], h
);
488 print_otag(h
, TAG_TD
, 1, tag
);
493 bufcat_style(h
, "width", "50%");
494 bufcat_style(h
, "text-align", "right");
495 PAIR_STYLE_INIT(&tag
[0], h
);
496 print_otag(h
, TAG_TD
, 1, tag
);
497 print_text(h
, m
->os
);
504 mdoc_root_pre(MDOC_ARGS
)
506 struct htmlpair tag
[3];
508 char b
[BUFSIZ
], title
[BUFSIZ
];
510 strlcpy(b
, m
->vol
, BUFSIZ
);
513 strlcat(b
, " (", BUFSIZ
);
514 strlcat(b
, m
->arch
, BUFSIZ
);
515 strlcat(b
, ")", BUFSIZ
);
518 snprintf(title
, BUFSIZ
- 1, "%s(%s)", m
->title
, m
->msec
);
520 PAIR_CLASS_INIT(&tag
[0], "header");
521 bufcat_style(h
, "width", "100%");
522 PAIR_STYLE_INIT(&tag
[1], h
);
523 PAIR_SUMMARY_INIT(&tag
[2], "header");
525 t
= print_otag(h
, TAG_TABLE
, 3, tag
);
527 tt
= print_otag(h
, TAG_TR
, 0, NULL
);
530 bufcat_style(h
, "width", "10%");
531 PAIR_STYLE_INIT(&tag
[0], h
);
532 print_otag(h
, TAG_TD
, 1, tag
);
533 print_text(h
, title
);
537 bufcat_style(h
, "text-align", "center");
538 bufcat_style(h
, "white-space", "nowrap");
539 bufcat_style(h
, "width", "80%");
540 PAIR_STYLE_INIT(&tag
[0], h
);
541 print_otag(h
, TAG_TD
, 1, tag
);
546 bufcat_style(h
, "text-align", "right");
547 bufcat_style(h
, "width", "10%");
548 PAIR_STYLE_INIT(&tag
[0], h
);
549 print_otag(h
, TAG_TD
, 1, tag
);
550 print_text(h
, title
);
558 mdoc_sh_pre(MDOC_ARGS
)
563 if (MDOC_BLOCK
== n
->type
) {
564 PAIR_CLASS_INIT(&tag
, "section");
565 print_otag(h
, TAG_DIV
, 1, &tag
);
567 } else if (MDOC_BODY
== n
->type
)
571 for (n
= n
->child
; n
; n
= n
->next
) {
572 html_idcat(buf
, n
->string
, BUFSIZ
);
574 html_idcat(buf
, " ", BUFSIZ
);
577 PAIR_ID_INIT(&tag
, buf
);
578 print_otag(h
, TAG_H1
, 1, &tag
);
585 mdoc_ss_pre(MDOC_ARGS
)
590 if (MDOC_BLOCK
== n
->type
) {
591 PAIR_CLASS_INIT(&tag
, "subsection");
592 print_otag(h
, TAG_DIV
, 1, &tag
);
594 } else if (MDOC_BODY
== n
->type
)
598 for (n
= n
->child
; n
; n
= n
->next
) {
599 html_idcat(buf
, n
->string
, BUFSIZ
);
601 html_idcat(buf
, " ", BUFSIZ
);
604 PAIR_ID_INIT(&tag
, buf
);
605 print_otag(h
, TAG_H2
, 1, &tag
);
612 mdoc_fl_pre(MDOC_ARGS
)
616 PAIR_CLASS_INIT(&tag
, "flag");
617 print_otag(h
, TAG_SPAN
, 1, &tag
);
619 /* `Cm' has no leading hyphen. */
621 if (MDOC_Cm
== n
->tok
)
624 print_text(h
, "\\-");
627 h
->flags
|= HTML_NOSPACE
;
628 else if (n
->next
&& n
->next
->line
== n
->line
)
629 h
->flags
|= HTML_NOSPACE
;
637 mdoc_nd_pre(MDOC_ARGS
)
641 if (MDOC_BODY
!= n
->type
)
644 /* XXX: this tag in theory can contain block elements. */
646 print_text(h
, "\\(em");
647 PAIR_CLASS_INIT(&tag
, "desc-body");
648 print_otag(h
, TAG_SPAN
, 1, &tag
);
654 mdoc_nm_pre(MDOC_ARGS
)
661 * Accomodate for `Nm' being both an element (which may have
662 * NULL children AND no m->name) and a block.
667 if (MDOC_ELEM
== n
->type
) {
668 if (NULL
== n
->child
&& NULL
== m
->name
)
671 PAIR_CLASS_INIT(&tag
, "name");
672 print_otag(h
, TAG_SPAN
, 1, &tag
);
673 if (NULL
== n
->child
)
674 print_text(h
, m
->name
);
675 } else if (MDOC_BLOCK
== n
->type
) {
678 bufcat_style(h
, "clear", "both");
679 if (n
->head
->child
|| m
->name
) {
680 if (n
->head
->child
&& MDOC_TEXT
==
681 n
->head
->child
->type
)
682 cp
= n
->head
->child
->string
;
683 if (NULL
== cp
|| '\0' == *cp
)
686 SCALE_HS_INIT(&su
, (double)strlen(cp
));
687 bufcat_su(h
, "padding-left", &su
);
690 PAIR_STYLE_INIT(&tag
, h
);
691 print_otag(h
, TAG_DIV
, 1, &tag
);
692 } else if (MDOC_HEAD
== n
->type
) {
693 if (NULL
== n
->child
&& NULL
== m
->name
)
696 if (n
->child
&& MDOC_TEXT
== n
->child
->type
)
697 cp
= n
->child
->string
;
698 if (NULL
== cp
|| '\0' == *cp
)
701 SCALE_HS_INIT(&su
, (double)strlen(cp
));
703 bufcat_style(h
, "float", "left");
704 bufcat_su(h
, "min-width", &su
);
706 bufcat_su(h
, "margin-left", &su
);
708 PAIR_STYLE_INIT(&tag
, h
);
709 print_otag(h
, TAG_DIV
, 1, &tag
);
711 if (NULL
== n
->child
)
712 print_text(h
, m
->name
);
713 } else if (MDOC_BODY
== n
->type
) {
714 SCALE_HS_INIT(&su
, 2);
715 bufcat_su(h
, "margin-left", &su
);
716 PAIR_STYLE_INIT(&tag
, h
);
717 print_otag(h
, TAG_DIV
, 1, &tag
);
726 mdoc_xr_pre(MDOC_ARGS
)
728 struct htmlpair tag
[2];
729 const struct mdoc_node
*nn
;
731 if (NULL
== n
->child
)
734 PAIR_CLASS_INIT(&tag
[0], "link-man");
737 buffmt_man(h
, n
->child
->string
,
739 n
->child
->next
->string
: NULL
);
740 PAIR_HREF_INIT(&tag
[1], h
->buf
);
741 print_otag(h
, TAG_A
, 2, tag
);
743 print_otag(h
, TAG_A
, 1, tag
);
746 print_text(h
, nn
->string
);
748 if (NULL
== (nn
= nn
->next
))
751 h
->flags
|= HTML_NOSPACE
;
753 h
->flags
|= HTML_NOSPACE
;
754 print_text(h
, nn
->string
);
755 h
->flags
|= HTML_NOSPACE
;
763 mdoc_ns_pre(MDOC_ARGS
)
766 h
->flags
|= HTML_NOSPACE
;
773 mdoc_ar_pre(MDOC_ARGS
)
777 PAIR_CLASS_INIT(&tag
, "arg");
778 print_otag(h
, TAG_SPAN
, 1, &tag
);
785 mdoc_xx_pre(MDOC_ARGS
)
813 PAIR_CLASS_INIT(&tag
, "unix");
814 print_otag(h
, TAG_SPAN
, 1, &tag
);
822 mdoc_bx_pre(MDOC_ARGS
)
824 const struct mdoc_node
*nn
;
827 PAIR_CLASS_INIT(&tag
, "unix");
828 print_otag(h
, TAG_SPAN
, 1, &tag
);
830 for (nn
= n
->child
; nn
; nn
= nn
->next
)
831 print_mdoc_node(m
, nn
, h
);
834 h
->flags
|= HTML_NOSPACE
;
836 print_text(h
, "BSD");
841 mdoc_it_pre(MDOC_ARGS
)
845 struct htmlpair tag
[2];
846 const struct mdoc_node
*bl
;
849 while (bl
&& MDOC_Bl
!= bl
->tok
)
854 type
= bl
->data
.Bl
->type
;
857 PAIR_CLASS_INIT(&tag
[0], lists
[type
]);
859 if (MDOC_HEAD
== n
->type
) {
880 SCALE_VS_INIT(&su
, ! bl
->data
.Bl
->comp
);
881 bufcat_su(h
, "margin-top", &su
);
882 PAIR_STYLE_INIT(&tag
[1], h
);
883 print_otag(h
, TAG_DT
, 2, tag
);
890 } else if (MDOC_BODY
== n
->type
) {
901 SCALE_VS_INIT(&su
, ! bl
->data
.Bl
->comp
);
902 bufcat_su(h
, "margin-top", &su
);
903 PAIR_STYLE_INIT(&tag
[1], h
);
904 print_otag(h
, TAG_LI
, 2, tag
);
915 if (NULL
== bl
->data
.Bl
->width
) {
916 print_otag(h
, TAG_DD
, 1, tag
);
919 a2width(bl
->data
.Bl
->width
, &su
);
920 bufcat_su(h
, "margin-left", &su
);
921 PAIR_STYLE_INIT(&tag
[1], h
);
922 print_otag(h
, TAG_DD
, 2, tag
);
925 SCALE_VS_INIT(&su
, ! bl
->data
.Bl
->comp
);
926 bufcat_su(h
, "margin-top", &su
);
927 PAIR_STYLE_INIT(&tag
[1], h
);
928 print_otag(h
, TAG_TD
, 2, tag
);
936 print_otag(h
, TAG_TR
, 1, tag
);
948 mdoc_bl_pre(MDOC_ARGS
)
951 struct htmlpair tag
[3];
954 if (MDOC_BODY
== n
->type
) {
955 if (LIST_column
== n
->data
.Bl
->type
)
956 print_otag(h
, TAG_TBODY
, 0, NULL
);
960 if (MDOC_HEAD
== n
->type
) {
961 if (LIST_column
!= n
->data
.Bl
->type
)
965 * For each column, print out the <COL> tag with our
966 * suggested width. The last column gets min-width, as
967 * in terminal mode it auto-sizes to the width of the
968 * screen and we want to preserve that behaviour.
971 for (i
= 0; i
< n
->data
.Bl
->ncols
; i
++) {
972 a2width(n
->data
.Bl
->cols
[i
], &su
);
974 if (i
< n
->data
.Bl
->ncols
- 1)
975 bufcat_su(h
, "width", &su
);
977 bufcat_su(h
, "min-width", &su
);
978 PAIR_STYLE_INIT(&tag
[0], h
);
979 print_otag(h
, TAG_COL
, 1, tag
);
985 SCALE_VS_INIT(&su
, 0);
986 bufcat_su(h
, "margin-top", &su
);
987 bufcat_su(h
, "margin-bottom", &su
);
988 PAIR_STYLE_INIT(&tag
[0], h
);
990 assert(lists
[n
->data
.Bl
->type
]);
991 PAIR_CLASS_INIT(&tag
[1], lists
[n
->data
.Bl
->type
]);
994 /* Set the block's left-hand margin. */
996 if (n
->data
.Bl
->offs
) {
997 a2offs(n
->data
.Bl
->offs
, &su
);
998 bufcat_su(h
, "margin-left", &su
);
999 PAIR_STYLE_INIT(&tag
[2], h
);
1003 switch (n
->data
.Bl
->type
) {
1011 print_otag(h
, TAG_UL
, i
, tag
);
1014 print_otag(h
, TAG_OL
, i
, tag
);
1025 print_otag(h
, TAG_DL
, i
, tag
);
1028 print_otag(h
, TAG_TABLE
, i
, tag
);
1040 mdoc_ex_pre(MDOC_ARGS
)
1042 const struct mdoc_node
*nn
;
1044 struct htmlpair tag
;
1046 PAIR_CLASS_INIT(&tag
, "utility");
1048 print_text(h
, "The");
1049 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1050 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1051 print_text(h
, nn
->string
);
1054 h
->flags
|= HTML_NOSPACE
;
1056 if (nn
->next
&& NULL
== nn
->next
->next
)
1057 print_text(h
, ", and");
1061 h
->flags
&= ~HTML_NOSPACE
;
1064 if (n
->child
&& n
->child
->next
)
1065 print_text(h
, "utilities exit");
1067 print_text(h
, "utility exits");
1069 print_text(h
, "0 on success, and >0 if an error occurs.");
1076 mdoc_em_pre(MDOC_ARGS
)
1078 struct htmlpair tag
;
1080 PAIR_CLASS_INIT(&tag
, "emph");
1081 print_otag(h
, TAG_SPAN
, 1, &tag
);
1088 mdoc_d1_pre(MDOC_ARGS
)
1090 struct htmlpair tag
[2];
1093 if (MDOC_BLOCK
!= n
->type
)
1096 SCALE_VS_INIT(&su
, 0);
1097 bufcat_su(h
, "margin-top", &su
);
1098 bufcat_su(h
, "margin-bottom", &su
);
1099 PAIR_STYLE_INIT(&tag
[0], h
);
1100 print_otag(h
, TAG_BLOCKQUOTE
, 1, tag
);
1102 /* BLOCKQUOTE needs a block body. */
1104 if (MDOC_Dl
== n
->tok
) {
1105 PAIR_CLASS_INIT(&tag
[1], "lit");
1106 print_otag(h
, TAG_DIV
, 1, tag
);
1108 print_otag(h
, TAG_DIV
, 0, tag
);
1116 mdoc_sx_pre(MDOC_ARGS
)
1118 struct htmlpair tag
[2];
1119 const struct mdoc_node
*nn
;
1122 strlcpy(buf
, "#", BUFSIZ
);
1123 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1124 html_idcat(buf
, nn
->string
, BUFSIZ
);
1126 html_idcat(buf
, " ", BUFSIZ
);
1129 PAIR_CLASS_INIT(&tag
[0], "link-sec");
1130 PAIR_HREF_INIT(&tag
[1], buf
);
1132 print_otag(h
, TAG_A
, 2, tag
);
1139 mdoc_bd_pre(MDOC_ARGS
)
1141 struct htmlpair tag
[2];
1143 const struct mdoc_node
*nn
;
1146 if (MDOC_HEAD
== n
->type
)
1149 SCALE_VS_INIT(&su
, 0);
1152 if (n
->data
.Bd
->offs
)
1153 a2offs(n
->data
.Bd
->offs
, &su
);
1155 comp
= n
->data
.Bd
->comp
;
1157 /* FIXME: -centered, etc. formatting. */
1158 /* FIXME: does not respect -offset ??? */
1160 if (MDOC_BLOCK
== n
->type
) {
1161 bufcat_su(h
, "margin-left", &su
);
1162 for (nn
= n
; nn
&& ! comp
; nn
= nn
->parent
) {
1163 if (MDOC_BLOCK
!= nn
->type
)
1165 if (MDOC_Ss
== nn
->tok
|| MDOC_Sh
== nn
->tok
)
1171 PAIR_STYLE_INIT(&tag
[0], h
);
1172 print_otag(h
, TAG_DIV
, 1, tag
);
1175 SCALE_VS_INIT(&su
, 1);
1176 bufcat_su(h
, "margin-top", &su
);
1177 PAIR_STYLE_INIT(&tag
[0], h
);
1178 print_otag(h
, TAG_DIV
, 1, tag
);
1182 if (DISP_unfilled
!= n
->data
.Bd
->type
&&
1183 DISP_literal
!= n
->data
.Bd
->type
)
1186 PAIR_CLASS_INIT(&tag
[0], "lit");
1187 bufcat_style(h
, "white-space", "pre");
1188 PAIR_STYLE_INIT(&tag
[1], h
);
1189 print_otag(h
, TAG_DIV
, 2, tag
);
1191 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1192 print_mdoc_node(m
, nn
, h
);
1194 * If the printed node flushes its own line, then we
1195 * needn't do it here as well. This is hacky, but the
1196 * notion of selective eoln whitespace is pretty dumb
1197 * anyway, so don't sweat it.
1219 if (nn
->next
&& nn
->next
->line
== nn
->line
)
1221 print_text(h
, "\n");
1222 h
->flags
|= HTML_NOSPACE
;
1231 mdoc_pa_pre(MDOC_ARGS
)
1233 struct htmlpair tag
;
1235 PAIR_CLASS_INIT(&tag
, "file");
1236 print_otag(h
, TAG_SPAN
, 1, &tag
);
1243 mdoc_ad_pre(MDOC_ARGS
)
1245 struct htmlpair tag
;
1247 PAIR_CLASS_INIT(&tag
, "addr");
1248 print_otag(h
, TAG_SPAN
, 1, &tag
);
1255 mdoc_an_pre(MDOC_ARGS
)
1257 struct htmlpair tag
;
1259 /* TODO: -split and -nosplit (see termp_an_pre()). */
1261 PAIR_CLASS_INIT(&tag
, "author");
1262 print_otag(h
, TAG_SPAN
, 1, &tag
);
1269 mdoc_cd_pre(MDOC_ARGS
)
1271 struct htmlpair tag
;
1274 PAIR_CLASS_INIT(&tag
, "config");
1275 print_otag(h
, TAG_SPAN
, 1, &tag
);
1282 mdoc_dv_pre(MDOC_ARGS
)
1284 struct htmlpair tag
;
1286 PAIR_CLASS_INIT(&tag
, "define");
1287 print_otag(h
, TAG_SPAN
, 1, &tag
);
1294 mdoc_ev_pre(MDOC_ARGS
)
1296 struct htmlpair tag
;
1298 PAIR_CLASS_INIT(&tag
, "env");
1299 print_otag(h
, TAG_SPAN
, 1, &tag
);
1306 mdoc_er_pre(MDOC_ARGS
)
1308 struct htmlpair tag
;
1310 PAIR_CLASS_INIT(&tag
, "errno");
1311 print_otag(h
, TAG_SPAN
, 1, &tag
);
1318 mdoc_fa_pre(MDOC_ARGS
)
1320 const struct mdoc_node
*nn
;
1321 struct htmlpair tag
;
1324 PAIR_CLASS_INIT(&tag
, "farg");
1325 if (n
->parent
->tok
!= MDOC_Fo
) {
1326 print_otag(h
, TAG_SPAN
, 1, &tag
);
1330 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1331 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1332 print_text(h
, nn
->string
);
1338 if (n
->child
&& n
->next
&& n
->next
->tok
== MDOC_Fa
)
1347 mdoc_fd_pre(MDOC_ARGS
)
1349 struct htmlpair tag
;
1353 PAIR_CLASS_INIT(&tag
, "macro");
1354 print_otag(h
, TAG_SPAN
, 1, &tag
);
1361 mdoc_vt_pre(MDOC_ARGS
)
1363 struct htmlpair tag
;
1365 if (MDOC_BLOCK
== n
->type
) {
1368 } else if (MDOC_ELEM
== n
->type
) {
1370 } else if (MDOC_HEAD
== n
->type
)
1373 PAIR_CLASS_INIT(&tag
, "type");
1374 print_otag(h
, TAG_SPAN
, 1, &tag
);
1381 mdoc_ft_pre(MDOC_ARGS
)
1383 struct htmlpair tag
;
1386 PAIR_CLASS_INIT(&tag
, "ftype");
1387 print_otag(h
, TAG_SPAN
, 1, &tag
);
1394 mdoc_fn_pre(MDOC_ARGS
)
1397 struct htmlpair tag
[2];
1398 const struct mdoc_node
*nn
;
1400 const char *sp
, *ep
;
1405 /* Split apart into type and name. */
1406 assert(n
->child
->string
);
1407 sp
= n
->child
->string
;
1409 ep
= strchr(sp
, ' ');
1411 PAIR_CLASS_INIT(&tag
[0], "ftype");
1412 t
= print_otag(h
, TAG_SPAN
, 1, tag
);
1415 sz
= MIN((int)(ep
- sp
), BUFSIZ
- 1);
1416 (void)memcpy(nbuf
, sp
, (size_t)sz
);
1418 print_text(h
, nbuf
);
1420 ep
= strchr(sp
, ' ');
1425 PAIR_CLASS_INIT(&tag
[0], "fname");
1428 * FIXME: only refer to IDs that we know exist.
1432 if (MDOC_SYNPRETTY
& n
->flags
) {
1434 html_idcat(nbuf
, sp
, BUFSIZ
);
1435 PAIR_ID_INIT(&tag
[1], nbuf
);
1437 strlcpy(nbuf
, "#", BUFSIZ
);
1438 html_idcat(nbuf
, sp
, BUFSIZ
);
1439 PAIR_HREF_INIT(&tag
[1], nbuf
);
1443 t
= print_otag(h
, TAG_SPAN
, 1, tag
);
1446 strlcpy(nbuf
, sp
, BUFSIZ
);
1447 print_text(h
, nbuf
);
1452 h
->flags
|= HTML_NOSPACE
;
1456 PAIR_CLASS_INIT(&tag
[0], "farg");
1457 bufcat_style(h
, "white-space", "nowrap");
1458 PAIR_STYLE_INIT(&tag
[1], h
);
1460 for (nn
= n
->child
->next
; nn
; nn
= nn
->next
) {
1462 if (MDOC_SYNPRETTY
& n
->flags
)
1464 t
= print_otag(h
, TAG_SPAN
, i
, tag
);
1465 print_text(h
, nn
->string
);
1472 if (MDOC_SYNPRETTY
& n
->flags
)
1481 mdoc_sm_pre(MDOC_ARGS
)
1484 assert(n
->child
&& MDOC_TEXT
== n
->child
->type
);
1485 if (0 == strcmp("on", n
->child
->string
)) {
1487 * FIXME: no p->col to check. Thus, if we have
1494 * the "3" is preceded by a space.
1496 h
->flags
&= ~HTML_NOSPACE
;
1497 h
->flags
&= ~HTML_NONOSPACE
;
1499 h
->flags
|= HTML_NONOSPACE
;
1506 mdoc_pp_pre(MDOC_ARGS
)
1509 print_otag(h
, TAG_P
, 0, NULL
);
1516 mdoc_sp_pre(MDOC_ARGS
)
1519 struct htmlpair tag
;
1521 SCALE_VS_INIT(&su
, 1);
1523 if (MDOC_sp
== n
->tok
) {
1525 a2roffsu(n
->child
->string
, &su
, SCALE_VS
);
1529 bufcat_su(h
, "height", &su
);
1530 PAIR_STYLE_INIT(&tag
, h
);
1531 print_otag(h
, TAG_DIV
, 1, &tag
);
1533 /* So the div isn't empty: */
1534 print_text(h
, "\\~");
1542 mdoc_lk_pre(MDOC_ARGS
)
1544 const struct mdoc_node
*nn
;
1545 struct htmlpair tag
[2];
1549 PAIR_CLASS_INIT(&tag
[0], "link-ext");
1550 PAIR_HREF_INIT(&tag
[1], nn
->string
);
1551 print_otag(h
, TAG_A
, 2, tag
);
1553 if (NULL
== nn
|| NULL
== nn
->next
)
1556 for (nn
= nn
->next
; nn
; nn
= nn
->next
)
1557 print_text(h
, nn
->string
);
1565 mdoc_mt_pre(MDOC_ARGS
)
1567 struct htmlpair tag
[2];
1569 const struct mdoc_node
*nn
;
1571 PAIR_CLASS_INIT(&tag
[0], "link-mail");
1573 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1575 bufcat(h
, "mailto:");
1576 bufcat(h
, nn
->string
);
1577 PAIR_HREF_INIT(&tag
[1], h
->buf
);
1578 t
= print_otag(h
, TAG_A
, 2, tag
);
1579 print_text(h
, nn
->string
);
1589 mdoc_fo_pre(MDOC_ARGS
)
1591 struct htmlpair tag
;
1594 if (MDOC_BODY
== n
->type
) {
1595 h
->flags
|= HTML_NOSPACE
;
1597 h
->flags
|= HTML_NOSPACE
;
1599 } else if (MDOC_BLOCK
== n
->type
) {
1604 /* XXX: we drop non-initial arguments as per groff. */
1607 assert(n
->child
->string
);
1609 PAIR_CLASS_INIT(&tag
, "fname");
1610 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1611 print_text(h
, n
->child
->string
);
1619 mdoc_fo_post(MDOC_ARGS
)
1622 if (MDOC_BODY
!= n
->type
)
1631 mdoc_in_pre(MDOC_ARGS
)
1633 const struct mdoc_node
*nn
;
1635 struct htmlpair tag
[2];
1640 PAIR_CLASS_INIT(&tag
[0], "includes");
1641 print_otag(h
, TAG_SPAN
, 1, tag
);
1643 if (MDOC_SYNPRETTY
& n
->flags
&& MDOC_LINE
& n
->flags
)
1644 print_text(h
, "#include");
1647 h
->flags
|= HTML_NOSPACE
;
1649 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1650 PAIR_CLASS_INIT(&tag
[0], "link-includes");
1653 if (h
->base_includes
) {
1654 buffmt_includes(h
, nn
->string
);
1655 PAIR_HREF_INIT(&tag
[i
], h
->buf
);
1658 t
= print_otag(h
, TAG_A
, i
, tag
);
1659 print_mdoc_node(m
, nn
, h
);
1663 h
->flags
|= HTML_NOSPACE
;
1672 mdoc_ic_pre(MDOC_ARGS
)
1674 struct htmlpair tag
;
1676 PAIR_CLASS_INIT(&tag
, "cmd");
1677 print_otag(h
, TAG_SPAN
, 1, &tag
);
1684 mdoc_rv_pre(MDOC_ARGS
)
1686 const struct mdoc_node
*nn
;
1687 struct htmlpair tag
;
1690 print_otag(h
, TAG_DIV
, 0, NULL
);
1691 print_text(h
, "The");
1693 for (nn
= n
->child
; nn
; nn
= nn
->next
) {
1694 PAIR_CLASS_INIT(&tag
, "fname");
1695 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1696 print_text(h
, nn
->string
);
1699 h
->flags
|= HTML_NOSPACE
;
1700 if (nn
->next
&& NULL
== nn
->next
->next
)
1701 print_text(h
, "(), and");
1703 print_text(h
, "(),");
1705 print_text(h
, "()");
1708 if (n
->child
&& n
->child
->next
)
1709 print_text(h
, "functions return");
1711 print_text(h
, "function returns");
1713 print_text(h
, "the value 0 if successful; otherwise the value "
1714 "-1 is returned and the global variable");
1716 PAIR_CLASS_INIT(&tag
, "var");
1717 t
= print_otag(h
, TAG_SPAN
, 1, &tag
);
1718 print_text(h
, "errno");
1720 print_text(h
, "is set to indicate the error.");
1727 mdoc_va_pre(MDOC_ARGS
)
1729 struct htmlpair tag
;
1731 PAIR_CLASS_INIT(&tag
, "var");
1732 print_otag(h
, TAG_SPAN
, 1, &tag
);
1739 mdoc_ap_pre(MDOC_ARGS
)
1742 h
->flags
|= HTML_NOSPACE
;
1743 print_text(h
, "\\(aq");
1744 h
->flags
|= HTML_NOSPACE
;
1751 mdoc_bf_pre(MDOC_ARGS
)
1753 struct htmlpair tag
[2];
1756 if (MDOC_HEAD
== n
->type
)
1758 else if (MDOC_BODY
!= n
->type
)
1763 if (FONT_Em
== n
->data
.Bf
->font
)
1764 PAIR_CLASS_INIT(&tag
[0], "emph");
1765 else if (FONT_Sy
== n
->data
.Bf
->font
)
1766 PAIR_CLASS_INIT(&tag
[0], "symb");
1767 else if (FONT_Li
== n
->data
.Bf
->font
)
1768 PAIR_CLASS_INIT(&tag
[0], "lit");
1770 PAIR_CLASS_INIT(&tag
[0], "none");
1773 * We want this to be inline-formatted, but needs to be div to
1774 * accept block children.
1776 bufcat_style(h
, "display", "inline");
1777 SCALE_HS_INIT(&su
, 1);
1778 /* Needs a left-margin for spacing. */
1779 bufcat_su(h
, "margin-left", &su
);
1780 PAIR_STYLE_INIT(&tag
[1], h
);
1781 print_otag(h
, TAG_DIV
, 2, tag
);
1788 mdoc_ms_pre(MDOC_ARGS
)
1790 struct htmlpair tag
;
1792 PAIR_CLASS_INIT(&tag
, "symb");
1793 print_otag(h
, TAG_SPAN
, 1, &tag
);
1800 mdoc_igndelim_pre(MDOC_ARGS
)
1803 h
->flags
|= HTML_IGNDELIM
;
1810 mdoc_pf_post(MDOC_ARGS
)
1813 h
->flags
|= HTML_NOSPACE
;
1819 mdoc_rs_pre(MDOC_ARGS
)
1821 struct htmlpair tag
;
1823 if (MDOC_BLOCK
!= n
->type
)
1826 if (n
->prev
&& SEC_SEE_ALSO
== n
->sec
)
1827 print_otag(h
, TAG_P
, 0, NULL
);
1829 PAIR_CLASS_INIT(&tag
, "ref");
1830 print_otag(h
, TAG_SPAN
, 1, &tag
);
1838 mdoc_li_pre(MDOC_ARGS
)
1840 struct htmlpair tag
;
1842 PAIR_CLASS_INIT(&tag
, "lit");
1843 print_otag(h
, TAG_SPAN
, 1, &tag
);
1850 mdoc_sy_pre(MDOC_ARGS
)
1852 struct htmlpair tag
;
1854 PAIR_CLASS_INIT(&tag
, "symb");
1855 print_otag(h
, TAG_SPAN
, 1, &tag
);
1862 mdoc_bt_pre(MDOC_ARGS
)
1865 print_text(h
, "is currently in beta test.");
1872 mdoc_ud_pre(MDOC_ARGS
)
1875 print_text(h
, "currently under development.");
1882 mdoc_lb_pre(MDOC_ARGS
)
1884 struct htmlpair tag
;
1886 if (SEC_LIBRARY
== n
->sec
&& MDOC_LINE
& n
->flags
)
1887 print_otag(h
, TAG_DIV
, 0, NULL
);
1888 PAIR_CLASS_INIT(&tag
, "lib");
1889 print_otag(h
, TAG_SPAN
, 1, &tag
);
1896 mdoc__x_pre(MDOC_ARGS
)
1898 struct htmlpair tag
[2];
1902 PAIR_CLASS_INIT(&tag
[0], "ref-auth");
1903 if (n
->prev
&& MDOC__A
== n
->prev
->tok
)
1904 if (NULL
== n
->next
|| MDOC__A
!= n
->next
->tok
)
1905 print_text(h
, "and");
1908 PAIR_CLASS_INIT(&tag
[0], "ref-book");
1911 PAIR_CLASS_INIT(&tag
[0], "ref-city");
1914 PAIR_CLASS_INIT(&tag
[0], "ref-date");
1917 PAIR_CLASS_INIT(&tag
[0], "ref-issue");
1920 PAIR_CLASS_INIT(&tag
[0], "ref-jrnl");
1923 PAIR_CLASS_INIT(&tag
[0], "ref-num");
1926 PAIR_CLASS_INIT(&tag
[0], "ref-opt");
1929 PAIR_CLASS_INIT(&tag
[0], "ref-page");
1932 PAIR_CLASS_INIT(&tag
[0], "ref-corp");
1935 PAIR_CLASS_INIT(&tag
[0], "ref-rep");
1938 PAIR_CLASS_INIT(&tag
[0], "ref-title");
1941 PAIR_CLASS_INIT(&tag
[0], "link-ref");
1944 PAIR_CLASS_INIT(&tag
[0], "ref-vol");
1951 if (MDOC__U
!= n
->tok
) {
1952 print_otag(h
, TAG_SPAN
, 1, tag
);
1956 PAIR_HREF_INIT(&tag
[1], n
->child
->string
);
1957 print_otag(h
, TAG_A
, 2, tag
);
1965 mdoc__x_post(MDOC_ARGS
)
1968 if (MDOC__A
== n
->tok
&& n
->next
&& MDOC__A
== n
->next
->tok
)
1969 if (NULL
== n
->next
->next
|| MDOC__A
!= n
->next
->next
->tok
)
1970 if (NULL
== n
->prev
|| MDOC__A
!= n
->prev
->tok
)
1975 if (NULL
== n
->parent
|| MDOC_Rs
!= n
->parent
->tok
)
1978 print_text(h
, n
->next
? "," : ".");
1984 mdoc_bk_pre(MDOC_ARGS
)
1993 h
->flags
|= HTML_PREKEEP
;
2006 mdoc_bk_post(MDOC_ARGS
)
2009 if (MDOC_BODY
== n
->type
)
2010 h
->flags
&= ~(HTML_KEEP
| HTML_PREKEEP
);
2016 mdoc_quote_pre(MDOC_ARGS
)
2018 struct htmlpair tag
;
2020 if (MDOC_BODY
!= n
->type
)
2027 print_text(h
, "\\(la");
2032 print_text(h
, "\\(lC");
2037 print_text(h
, "\\(lB");
2042 print_text(h
, "\\(lB");
2043 h
->flags
|= HTML_NOSPACE
;
2044 PAIR_CLASS_INIT(&tag
, "opt");
2045 print_otag(h
, TAG_SPAN
, 1, &tag
);
2054 print_text(h
, "\\(lq");
2066 print_text(h
, "\\(oq");
2073 h
->flags
|= HTML_NOSPACE
;
2080 mdoc_quote_post(MDOC_ARGS
)
2083 if (MDOC_BODY
!= n
->type
)
2086 h
->flags
|= HTML_NOSPACE
;
2092 print_text(h
, "\\(ra");
2097 print_text(h
, "\\(rC");
2106 print_text(h
, "\\(rB");
2115 print_text(h
, "\\(rq");
2127 print_text(h
, "\\(aq");