]> git.cameronkatri.com Git - mandoc.git/blob - mdoc_html.c
Fix man.7 to include AT and UC in its syntax table.
[mandoc.git] / mdoc_html.c
1 /* $Id: mdoc_html.c,v 1.67 2010/05/24 12:17:09 kristaps Exp $ */
2 /*
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
4 *
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.
8 *
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.
16 */
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20
21 #include <sys/types.h>
22
23 #include <assert.h>
24 #include <ctype.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <unistd.h>
29
30 #include "mandoc.h"
31 #include "out.h"
32 #include "html.h"
33 #include "mdoc.h"
34 #include "main.h"
35
36 #define INDENT 5
37 #define HALFINDENT 3
38
39 #define MDOC_ARGS const struct mdoc_meta *m, \
40 const struct mdoc_node *n, \
41 struct html *h
42
43 #ifndef MIN
44 #define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b))
45 #endif
46
47 struct htmlmdoc {
48 int (*pre)(MDOC_ARGS);
49 void (*post)(MDOC_ARGS);
50 };
51
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
57 static void a2width(const char *, struct roffsu *);
58 static void a2offs(const char *, struct roffsu *);
59
60 static void mdoc_root_post(MDOC_ARGS);
61 static int mdoc_root_pre(MDOC_ARGS);
62
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_block_pre(MDOC_ARGS, enum mdoc_list,
100 int, struct roffsu *, struct roffsu *);
101 static int mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list,
102 struct roffsu *);
103 static int mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list);
104 static int mdoc_it_pre(MDOC_ARGS);
105 static int mdoc_lb_pre(MDOC_ARGS);
106 static int mdoc_li_pre(MDOC_ARGS);
107 static int mdoc_lk_pre(MDOC_ARGS);
108 static int mdoc_mt_pre(MDOC_ARGS);
109 static int mdoc_ms_pre(MDOC_ARGS);
110 static int mdoc_nd_pre(MDOC_ARGS);
111 static int mdoc_nm_pre(MDOC_ARGS);
112 static int mdoc_ns_pre(MDOC_ARGS);
113 static void mdoc_op_post(MDOC_ARGS);
114 static int mdoc_op_pre(MDOC_ARGS);
115 static int mdoc_pa_pre(MDOC_ARGS);
116 static void mdoc_pf_post(MDOC_ARGS);
117 static int mdoc_pf_pre(MDOC_ARGS);
118 static void mdoc_pq_post(MDOC_ARGS);
119 static int mdoc_pq_pre(MDOC_ARGS);
120 static int mdoc_rs_pre(MDOC_ARGS);
121 static int mdoc_rv_pre(MDOC_ARGS);
122 static int mdoc_sh_pre(MDOC_ARGS);
123 static int mdoc_sp_pre(MDOC_ARGS);
124 static void mdoc_sq_post(MDOC_ARGS);
125 static int mdoc_sq_pre(MDOC_ARGS);
126 static int mdoc_ss_pre(MDOC_ARGS);
127 static int mdoc_sx_pre(MDOC_ARGS);
128 static int mdoc_sy_pre(MDOC_ARGS);
129 static int mdoc_ud_pre(MDOC_ARGS);
130 static int mdoc_va_pre(MDOC_ARGS);
131 static int mdoc_vt_pre(MDOC_ARGS);
132 static int mdoc_xr_pre(MDOC_ARGS);
133 static int mdoc_xx_pre(MDOC_ARGS);
134
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 */ /* FIXME: no space */
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 */
256 {mdoc__x_pre, mdoc__x_post}, /* %U */
257 };
258
259
260 void
261 html_mdoc(void *arg, const struct mdoc *m)
262 {
263 struct html *h;
264 struct tag *t;
265
266 h = (struct html *)arg;
267
268 print_gen_decls(h);
269 t = print_otag(h, TAG_HTML, 0, NULL);
270 print_mdoc(mdoc_meta(m), mdoc_node(m), h);
271 print_tagq(h, t);
272
273 printf("\n");
274 }
275
276
277 /*
278 * Calculate the scaling unit passed in a `-width' argument. This uses
279 * either a native scaling unit (e.g., 1i, 2m) or the string length of
280 * the value.
281 */
282 static void
283 a2width(const char *p, struct roffsu *su)
284 {
285
286 if ( ! a2roffsu(p, su, SCALE_MAX)) {
287 su->unit = SCALE_EM;
288 su->scale = (int)strlen(p);
289 }
290 }
291
292
293 /*
294 * Calculate the scaling unit passed in an `-offset' argument. This
295 * uses either a native scaling unit (e.g., 1i, 2m), one of a set of
296 * predefined strings (indent, etc.), or the string length of the value.
297 */
298 static void
299 a2offs(const char *p, struct roffsu *su)
300 {
301
302 /* FIXME: "right"? */
303
304 if (0 == strcmp(p, "left"))
305 SCALE_HS_INIT(su, 0);
306 else if (0 == strcmp(p, "indent"))
307 SCALE_HS_INIT(su, INDENT);
308 else if (0 == strcmp(p, "indent-two"))
309 SCALE_HS_INIT(su, INDENT * 2);
310 else if ( ! a2roffsu(p, su, SCALE_MAX)) {
311 su->unit = SCALE_EM;
312 su->scale = (int)strlen(p);
313 }
314 }
315
316
317 static void
318 print_mdoc(MDOC_ARGS)
319 {
320 struct tag *t;
321 struct htmlpair tag;
322
323 t = print_otag(h, TAG_HEAD, 0, NULL);
324 print_mdoc_head(m, n, h);
325 print_tagq(h, t);
326
327 t = print_otag(h, TAG_BODY, 0, NULL);
328
329 tag.key = ATTR_CLASS;
330 tag.val = "body";
331 print_otag(h, TAG_DIV, 1, &tag);
332
333 print_mdoc_nodelist(m, n, h);
334 print_tagq(h, t);
335 }
336
337
338 /* ARGSUSED */
339 static void
340 print_mdoc_head(MDOC_ARGS)
341 {
342
343 print_gen_head(h);
344 bufinit(h);
345 buffmt(h, "%s(%s)", m->title, m->msec);
346
347 if (m->arch) {
348 bufcat(h, " (");
349 bufcat(h, m->arch);
350 bufcat(h, ")");
351 }
352
353 print_otag(h, TAG_TITLE, 0, NULL);
354 print_text(h, h->buf);
355 }
356
357
358 static void
359 print_mdoc_nodelist(MDOC_ARGS)
360 {
361
362 print_mdoc_node(m, n, h);
363 if (n->next)
364 print_mdoc_nodelist(m, n->next, h);
365 }
366
367
368 static void
369 print_mdoc_node(MDOC_ARGS)
370 {
371 int child;
372 struct tag *t;
373
374 child = 1;
375 t = h->tags.head;
376
377 bufinit(h);
378 switch (n->type) {
379 case (MDOC_ROOT):
380 child = mdoc_root_pre(m, n, h);
381 break;
382 case (MDOC_TEXT):
383 print_text(h, n->string);
384 return;
385 default:
386 if (mdocs[n->tok].pre)
387 child = (*mdocs[n->tok].pre)(m, n, h);
388 break;
389 }
390
391 if (child && n->child)
392 print_mdoc_nodelist(m, n->child, h);
393
394 print_stagq(h, t);
395
396 bufinit(h);
397 switch (n->type) {
398 case (MDOC_ROOT):
399 mdoc_root_post(m, n, h);
400 break;
401 default:
402 if (mdocs[n->tok].post)
403 (*mdocs[n->tok].post)(m, n, h);
404 break;
405 }
406 }
407
408
409 /* ARGSUSED */
410 static void
411 mdoc_root_post(MDOC_ARGS)
412 {
413 struct htmlpair tag[3];
414 struct tag *t, *tt;
415 char b[DATESIZ];
416
417 time2a(m->date, b, DATESIZ);
418
419 /*
420 * XXX: this should use divs, but in Firefox, divs with nested
421 * divs for some reason puke when trying to put a border line
422 * below. So I use tables, instead.
423 */
424
425 PAIR_CLASS_INIT(&tag[0], "footer");
426 bufcat_style(h, "width", "100%");
427 PAIR_STYLE_INIT(&tag[1], h);
428 PAIR_SUMMARY_INIT(&tag[2], "footer");
429
430 t = print_otag(h, TAG_TABLE, 3, tag);
431 tt = print_otag(h, TAG_TR, 0, NULL);
432
433 bufinit(h);
434 bufcat_style(h, "width", "50%");
435 PAIR_STYLE_INIT(&tag[0], h);
436 print_otag(h, TAG_TD, 1, tag);
437 print_text(h, b);
438 print_stagq(h, tt);
439
440 bufinit(h);
441 bufcat_style(h, "width", "50%");
442 bufcat_style(h, "text-align", "right");
443 PAIR_STYLE_INIT(&tag[0], h);
444 print_otag(h, TAG_TD, 1, tag);
445 print_text(h, m->os);
446 print_tagq(h, t);
447 }
448
449
450 /* ARGSUSED */
451 static int
452 mdoc_root_pre(MDOC_ARGS)
453 {
454 struct htmlpair tag[3];
455 struct tag *t, *tt;
456 char b[BUFSIZ], title[BUFSIZ];
457
458 (void)strlcpy(b, m->vol, BUFSIZ);
459
460 if (m->arch) {
461 (void)strlcat(b, " (", BUFSIZ);
462 (void)strlcat(b, m->arch, BUFSIZ);
463 (void)strlcat(b, ")", BUFSIZ);
464 }
465
466 (void)snprintf(title, BUFSIZ - 1,
467 "%s(%s)", m->title, m->msec);
468
469 /* XXX: see note in mdoc_root_post() about divs. */
470
471 PAIR_CLASS_INIT(&tag[0], "header");
472 bufcat_style(h, "width", "100%");
473 PAIR_STYLE_INIT(&tag[1], h);
474 PAIR_SUMMARY_INIT(&tag[2], "header");
475
476 t = print_otag(h, TAG_TABLE, 3, tag);
477
478 tt = print_otag(h, TAG_TR, 0, NULL);
479
480 bufinit(h);
481 bufcat_style(h, "width", "10%");
482 PAIR_STYLE_INIT(&tag[0], h);
483 print_otag(h, TAG_TD, 1, tag);
484 print_text(h, title);
485 print_stagq(h, tt);
486
487 bufinit(h);
488 bufcat_style(h, "text-align", "center");
489 bufcat_style(h, "white-space", "nowrap");
490 bufcat_style(h, "width", "80%");
491 PAIR_STYLE_INIT(&tag[0], h);
492 print_otag(h, TAG_TD, 1, tag);
493 print_text(h, b);
494 print_stagq(h, tt);
495
496 bufinit(h);
497 bufcat_style(h, "text-align", "right");
498 bufcat_style(h, "width", "10%");
499 PAIR_STYLE_INIT(&tag[0], h);
500 print_otag(h, TAG_TD, 1, tag);
501 print_text(h, title);
502 print_tagq(h, t);
503 return(1);
504 }
505
506
507 /* ARGSUSED */
508 static int
509 mdoc_sh_pre(MDOC_ARGS)
510 {
511 struct htmlpair tag[2];
512 const struct mdoc_node *nn;
513 char buf[BUFSIZ];
514 struct roffsu su;
515
516 if (MDOC_BODY == n->type) {
517 SCALE_HS_INIT(&su, INDENT);
518 bufcat_su(h, "margin-left", &su);
519 PAIR_CLASS_INIT(&tag[0], "sec-body");
520 PAIR_STYLE_INIT(&tag[1], h);
521 print_otag(h, TAG_DIV, 2, tag);
522 return(1);
523 } else if (MDOC_BLOCK == n->type) {
524 PAIR_CLASS_INIT(&tag[0], "sec-block");
525 if (n->prev && NULL == n->prev->body->child) {
526 print_otag(h, TAG_DIV, 1, tag);
527 return(1);
528 }
529
530 SCALE_VS_INIT(&su, 1);
531 bufcat_su(h, "margin-top", &su);
532 if (NULL == n->next)
533 bufcat_su(h, "margin-bottom", &su);
534
535 PAIR_STYLE_INIT(&tag[1], h);
536 print_otag(h, TAG_DIV, 2, tag);
537 return(1);
538 }
539
540 buf[0] = '\0';
541 for (nn = n->child; nn; nn = nn->next) {
542 html_idcat(buf, nn->string, BUFSIZ);
543 if (nn->next)
544 html_idcat(buf, " ", BUFSIZ);
545 }
546
547 PAIR_CLASS_INIT(&tag[0], "sec-head");
548 PAIR_ID_INIT(&tag[1], buf);
549
550 print_otag(h, TAG_DIV, 2, tag);
551 return(1);
552 }
553
554
555 /* ARGSUSED */
556 static int
557 mdoc_ss_pre(MDOC_ARGS)
558 {
559 struct htmlpair tag[3];
560 const struct mdoc_node *nn;
561 char buf[BUFSIZ];
562 struct roffsu su;
563
564 SCALE_VS_INIT(&su, 1);
565
566 if (MDOC_BODY == n->type) {
567 PAIR_CLASS_INIT(&tag[0], "ssec-body");
568 if (n->parent->next && n->child) {
569 bufcat_su(h, "margin-bottom", &su);
570 PAIR_STYLE_INIT(&tag[1], h);
571 print_otag(h, TAG_DIV, 2, tag);
572 } else
573 print_otag(h, TAG_DIV, 1, tag);
574 return(1);
575 } else if (MDOC_BLOCK == n->type) {
576 PAIR_CLASS_INIT(&tag[0], "ssec-block");
577 if (n->prev) {
578 bufcat_su(h, "margin-top", &su);
579 PAIR_STYLE_INIT(&tag[1], h);
580 print_otag(h, TAG_DIV, 2, tag);
581 } else
582 print_otag(h, TAG_DIV, 1, tag);
583 return(1);
584 }
585
586 /* TODO: see note in mdoc_sh_pre() about duplicates. */
587
588 buf[0] = '\0';
589 for (nn = n->child; nn; nn = nn->next) {
590 html_idcat(buf, nn->string, BUFSIZ);
591 if (nn->next)
592 html_idcat(buf, " ", BUFSIZ);
593 }
594
595 SCALE_HS_INIT(&su, INDENT - HALFINDENT);
596 su.scale = -su.scale;
597 bufcat_su(h, "margin-left", &su);
598
599 PAIR_CLASS_INIT(&tag[0], "ssec-head");
600 PAIR_STYLE_INIT(&tag[1], h);
601 PAIR_ID_INIT(&tag[2], buf);
602
603 print_otag(h, TAG_DIV, 3, tag);
604 return(1);
605 }
606
607
608 /* ARGSUSED */
609 static int
610 mdoc_fl_pre(MDOC_ARGS)
611 {
612 struct htmlpair tag;
613
614 PAIR_CLASS_INIT(&tag, "flag");
615 print_otag(h, TAG_SPAN, 1, &tag);
616
617 /* `Cm' has no leading hyphen. */
618
619 if (MDOC_Cm == n->tok)
620 return(1);
621
622 print_text(h, "\\-");
623
624 if (n->child)
625 h->flags |= HTML_NOSPACE;
626 else if (n->next && n->next->line == n->line)
627 h->flags |= HTML_NOSPACE;
628
629 return(1);
630 }
631
632
633 /* ARGSUSED */
634 static int
635 mdoc_nd_pre(MDOC_ARGS)
636 {
637 struct htmlpair tag;
638
639 if (MDOC_BODY != n->type)
640 return(1);
641
642 /* XXX: this tag in theory can contain block elements. */
643
644 print_text(h, "\\(em");
645 PAIR_CLASS_INIT(&tag, "desc-body");
646 print_otag(h, TAG_SPAN, 1, &tag);
647 return(1);
648 }
649
650
651 /* ARGSUSED */
652 static int
653 mdoc_op_pre(MDOC_ARGS)
654 {
655 struct htmlpair tag;
656
657 if (MDOC_BODY != n->type)
658 return(1);
659
660 /* XXX: this tag in theory can contain block elements. */
661
662 print_text(h, "\\(lB");
663 h->flags |= HTML_NOSPACE;
664 PAIR_CLASS_INIT(&tag, "opt");
665 print_otag(h, TAG_SPAN, 1, &tag);
666 return(1);
667 }
668
669
670 /* ARGSUSED */
671 static void
672 mdoc_op_post(MDOC_ARGS)
673 {
674
675 if (MDOC_BODY != n->type)
676 return;
677 h->flags |= HTML_NOSPACE;
678 print_text(h, "\\(rB");
679 }
680
681
682 static int
683 mdoc_nm_pre(MDOC_ARGS)
684 {
685 struct htmlpair tag;
686
687 if (NULL == n->child && NULL == m->name)
688 return(1);
689
690 if (SEC_SYNOPSIS == n->sec &&
691 n->prev && MDOC_LINE & n->flags) {
692 bufcat_style(h, "clear", "both");
693 PAIR_STYLE_INIT(&tag, h);
694 print_otag(h, TAG_BR, 1, &tag);
695 }
696
697 PAIR_CLASS_INIT(&tag, "name");
698 print_otag(h, TAG_SPAN, 1, &tag);
699 if (NULL == n->child)
700 print_text(h, m->name);
701
702 return(1);
703 }
704
705
706 /* ARGSUSED */
707 static int
708 mdoc_xr_pre(MDOC_ARGS)
709 {
710 struct htmlpair tag[2];
711 const struct mdoc_node *nn;
712
713 if (NULL == n->child)
714 return(0);
715
716 PAIR_CLASS_INIT(&tag[0], "link-man");
717
718 if (h->base_man) {
719 buffmt_man(h, n->child->string,
720 n->child->next ?
721 n->child->next->string : NULL);
722 PAIR_HREF_INIT(&tag[1], h->buf);
723 print_otag(h, TAG_A, 2, tag);
724 } else
725 print_otag(h, TAG_A, 1, tag);
726
727 nn = n->child;
728 print_text(h, nn->string);
729
730 if (NULL == (nn = nn->next))
731 return(0);
732
733 h->flags |= HTML_NOSPACE;
734 print_text(h, "(");
735 h->flags |= HTML_NOSPACE;
736 print_text(h, nn->string);
737 h->flags |= HTML_NOSPACE;
738 print_text(h, ")");
739 return(0);
740 }
741
742
743 /* ARGSUSED */
744 static int
745 mdoc_ns_pre(MDOC_ARGS)
746 {
747
748 h->flags |= HTML_NOSPACE;
749 return(1);
750 }
751
752
753 /* ARGSUSED */
754 static int
755 mdoc_ar_pre(MDOC_ARGS)
756 {
757 struct htmlpair tag;
758
759 PAIR_CLASS_INIT(&tag, "arg");
760 print_otag(h, TAG_SPAN, 1, &tag);
761 return(1);
762 }
763
764
765 /* ARGSUSED */
766 static int
767 mdoc_xx_pre(MDOC_ARGS)
768 {
769 const char *pp;
770 struct htmlpair tag;
771
772 switch (n->tok) {
773 case (MDOC_Bsx):
774 pp = "BSDI BSD/OS";
775 break;
776 case (MDOC_Dx):
777 pp = "DragonFly";
778 break;
779 case (MDOC_Fx):
780 pp = "FreeBSD";
781 break;
782 case (MDOC_Nx):
783 pp = "NetBSD";
784 break;
785 case (MDOC_Ox):
786 pp = "OpenBSD";
787 break;
788 case (MDOC_Ux):
789 pp = "UNIX";
790 break;
791 default:
792 return(1);
793 }
794
795 PAIR_CLASS_INIT(&tag, "unix");
796 print_otag(h, TAG_SPAN, 1, &tag);
797 print_text(h, pp);
798 return(1);
799 }
800
801
802 /* ARGSUSED */
803 static int
804 mdoc_bx_pre(MDOC_ARGS)
805 {
806 const struct mdoc_node *nn;
807 struct htmlpair tag;
808
809 PAIR_CLASS_INIT(&tag, "unix");
810 print_otag(h, TAG_SPAN, 1, &tag);
811
812 for (nn = n->child; nn; nn = nn->next)
813 print_mdoc_node(m, nn, h);
814
815 if (n->child)
816 h->flags |= HTML_NOSPACE;
817
818 print_text(h, "BSD");
819 return(0);
820 }
821
822
823 /* ARGSUSED */
824 static int
825 mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list type, int comp,
826 struct roffsu *offs, struct roffsu *width)
827 {
828 struct htmlpair tag;
829 const struct mdoc_node *nn;
830 struct roffsu su;
831
832 nn = n->parent->parent;
833 assert(nn->args);
834
835 /* XXX: see notes in mdoc_it_pre(). */
836
837 if (LIST_column == type) {
838 /* Don't width-pad on the left. */
839 SCALE_HS_INIT(width, 0);
840 /* Also disallow non-compact. */
841 comp = 1;
842 }
843 if (LIST_diag == type)
844 /* Mandate non-compact with empty prior. */
845 if (n->prev && NULL == n->prev->body->child)
846 comp = 1;
847
848 bufcat_style(h, "clear", "both");
849 if (offs->scale > 0)
850 bufcat_su(h, "margin-left", offs);
851 if (width->scale > 0)
852 bufcat_su(h, "padding-left", width);
853
854 PAIR_STYLE_INIT(&tag, h);
855
856 /* Mandate compact following `Ss' and `Sh' starts. */
857
858 for (nn = n; nn && ! comp; nn = nn->parent) {
859 if (MDOC_BLOCK != nn->type)
860 continue;
861 if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
862 comp = 1;
863 if (nn->prev)
864 break;
865 }
866
867 if ( ! comp) {
868 SCALE_VS_INIT(&su, 1);
869 bufcat_su(h, "padding-top", &su);
870 }
871
872 PAIR_STYLE_INIT(&tag, h);
873 print_otag(h, TAG_DIV, 1, &tag);
874 return(1);
875 }
876
877
878 /* ARGSUSED */
879 static int
880 mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list type)
881 {
882 struct htmlpair tag;
883 struct roffsu su;
884
885 switch (type) {
886 case (LIST_item):
887 /* FALLTHROUGH */
888 case (LIST_ohang):
889 /* FALLTHROUGH */
890 case (LIST_column):
891 break;
892 default:
893 /*
894 * XXX: this tricks CSS into aligning the bodies with
895 * the right-padding in the head.
896 */
897 SCALE_HS_INIT(&su, 2);
898 bufcat_su(h, "margin-left", &su);
899 PAIR_STYLE_INIT(&tag, h);
900 print_otag(h, TAG_DIV, 1, &tag);
901 break;
902 }
903
904 return(1);
905 }
906
907
908 /* ARGSUSED */
909 static int
910 mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list type, struct roffsu *width)
911 {
912 struct htmlpair tag;
913 struct ord *ord;
914 char nbuf[BUFSIZ];
915
916 switch (type) {
917 case (LIST_item):
918 return(0);
919 case (LIST_ohang):
920 print_otag(h, TAG_DIV, 0, &tag);
921 return(1);
922 case (LIST_column):
923 bufcat_su(h, "min-width", width);
924 bufcat_style(h, "clear", "none");
925 if (n->next && MDOC_HEAD == n->next->type)
926 bufcat_style(h, "float", "left");
927 PAIR_STYLE_INIT(&tag, h);
928 print_otag(h, TAG_DIV, 1, &tag);
929 break;
930 default:
931 bufcat_su(h, "min-width", width);
932 SCALE_INVERT(width);
933 bufcat_su(h, "margin-left", width);
934 if (n->next && n->next->child)
935 bufcat_style(h, "float", "left");
936
937 /* XXX: buffer if we run into body. */
938 SCALE_HS_INIT(width, 1);
939 bufcat_su(h, "margin-right", width);
940 PAIR_STYLE_INIT(&tag, h);
941 print_otag(h, TAG_DIV, 1, &tag);
942 break;
943 }
944
945 switch (type) {
946 case (LIST_diag):
947 PAIR_CLASS_INIT(&tag, "diag");
948 print_otag(h, TAG_SPAN, 1, &tag);
949 break;
950 case (LIST_enum):
951 ord = h->ords.head;
952 assert(ord);
953 nbuf[BUFSIZ - 1] = 0;
954 (void)snprintf(nbuf, BUFSIZ - 1, "%d.", ord->pos++);
955 print_text(h, nbuf);
956 return(0);
957 case (LIST_dash):
958 print_text(h, "\\(en");
959 return(0);
960 case (LIST_hyphen):
961 print_text(h, "\\(hy");
962 return(0);
963 case (LIST_bullet):
964 print_text(h, "\\(bu");
965 return(0);
966 default:
967 break;
968 }
969
970 return(1);
971 }
972
973
974 static int
975 mdoc_it_pre(MDOC_ARGS)
976 {
977 int i, wp, comp;
978 const struct mdoc_node *bl, *nn;
979 struct roffsu width, offs;
980 enum mdoc_list type;
981
982 /*
983 * XXX: be very careful in changing anything, here. Lists in
984 * mandoc have many peculiarities; furthermore, they don't
985 * translate well into HTML and require a bit of mangling.
986 */
987
988 bl = n->parent->parent;
989 if (MDOC_BLOCK != n->type)
990 bl = bl->parent;
991
992 type = bl->data.list;
993
994 /* Set default width and offset. */
995
996 SCALE_HS_INIT(&offs, 0);
997
998 switch (type) {
999 case (LIST_enum):
1000 /* FALLTHROUGH */
1001 case (LIST_dash):
1002 /* FALLTHROUGH */
1003 case (LIST_hyphen):
1004 /* FALLTHROUGH */
1005 case (LIST_bullet):
1006 SCALE_HS_INIT(&width, 2);
1007 break;
1008 default:
1009 SCALE_HS_INIT(&width, INDENT);
1010 break;
1011 }
1012
1013 /* Get width, offset, and compact arguments. */
1014
1015 for (wp = -1, comp = i = 0; i < (int)bl->args->argc; i++)
1016 switch (bl->args->argv[i].arg) {
1017 case (MDOC_Column):
1018 wp = i; /* Save for later. */
1019 break;
1020 case (MDOC_Width):
1021 a2width(bl->args->argv[i].value[0], &width);
1022 break;
1023 case (MDOC_Offset):
1024 a2offs(bl->args->argv[i].value[0], &offs);
1025 break;
1026 case (MDOC_Compact):
1027 comp = 1;
1028 break;
1029 default:
1030 break;
1031 }
1032
1033 /* Override width in some cases. */
1034
1035 switch (type) {
1036 case (LIST_ohang):
1037 /* FALLTHROUGH */
1038 case (LIST_item):
1039 /* FALLTHROUGH */
1040 case (LIST_inset):
1041 /* FALLTHROUGH */
1042 case (LIST_diag):
1043 SCALE_HS_INIT(&width, 0);
1044 break;
1045 default:
1046 if (0 == width.scale)
1047 SCALE_HS_INIT(&width, INDENT);
1048 break;
1049 }
1050
1051 /* Flip to body/block processing. */
1052
1053 if (MDOC_BODY == n->type)
1054 return(mdoc_it_body_pre(m, n, h, type));
1055 if (MDOC_BLOCK == n->type)
1056 return(mdoc_it_block_pre(m, n, h, type, comp,
1057 &offs, &width));
1058
1059 /* Override column widths. */
1060
1061 if (LIST_column == type) {
1062 nn = n->parent->child;
1063 for (i = 0; nn && nn != n; nn = nn->next, i++)
1064 /* Counter... */ ;
1065 if (i < (int)bl->args->argv[wp].sz)
1066 a2width(bl->args->argv[wp].value[i], &width);
1067 }
1068
1069 return(mdoc_it_head_pre(m, n, h, type, &width));
1070 }
1071
1072
1073 /* ARGSUSED */
1074 static int
1075 mdoc_bl_pre(MDOC_ARGS)
1076 {
1077 struct ord *ord;
1078
1079 if (MDOC_HEAD == n->type)
1080 return(0);
1081 if (MDOC_BLOCK != n->type)
1082 return(1);
1083 if (LIST_enum != n->data.list)
1084 return(1);
1085
1086 ord = malloc(sizeof(struct ord));
1087 if (NULL == ord) {
1088 perror(NULL);
1089 exit(EXIT_FAILURE);
1090 }
1091 ord->cookie = n;
1092 ord->pos = 1;
1093 ord->next = h->ords.head;
1094 h->ords.head = ord;
1095 return(1);
1096 }
1097
1098
1099 /* ARGSUSED */
1100 static void
1101 mdoc_bl_post(MDOC_ARGS)
1102 {
1103 struct ord *ord;
1104
1105 if (MDOC_BLOCK != n->type)
1106 return;
1107 if (LIST_enum != n->data.list)
1108 return;
1109
1110 ord = h->ords.head;
1111 assert(ord);
1112 h->ords.head = ord->next;
1113 free(ord);
1114 }
1115
1116
1117 /* ARGSUSED */
1118 static int
1119 mdoc_ex_pre(MDOC_ARGS)
1120 {
1121 const struct mdoc_node *nn;
1122 struct tag *t;
1123 struct htmlpair tag;
1124
1125 PAIR_CLASS_INIT(&tag, "utility");
1126
1127 print_text(h, "The");
1128 for (nn = n->child; nn; nn = nn->next) {
1129 t = print_otag(h, TAG_SPAN, 1, &tag);
1130 print_text(h, nn->string);
1131 print_tagq(h, t);
1132
1133 h->flags |= HTML_NOSPACE;
1134
1135 if (nn->next && NULL == nn->next->next)
1136 print_text(h, ", and");
1137 else if (nn->next)
1138 print_text(h, ",");
1139 else
1140 h->flags &= ~HTML_NOSPACE;
1141 }
1142
1143 if (n->child && n->child->next)
1144 print_text(h, "utilities exit");
1145 else
1146 print_text(h, "utility exits");
1147
1148 print_text(h, "0 on success, and >0 if an error occurs.");
1149 return(0);
1150 }
1151
1152
1153 /* ARGSUSED */
1154 static int
1155 mdoc_dq_pre(MDOC_ARGS)
1156 {
1157
1158 if (MDOC_BODY != n->type)
1159 return(1);
1160 print_text(h, "\\(lq");
1161 h->flags |= HTML_NOSPACE;
1162 return(1);
1163 }
1164
1165
1166 /* ARGSUSED */
1167 static void
1168 mdoc_dq_post(MDOC_ARGS)
1169 {
1170
1171 if (MDOC_BODY != n->type)
1172 return;
1173 h->flags |= HTML_NOSPACE;
1174 print_text(h, "\\(rq");
1175 }
1176
1177
1178 /* ARGSUSED */
1179 static int
1180 mdoc_pq_pre(MDOC_ARGS)
1181 {
1182
1183 if (MDOC_BODY != n->type)
1184 return(1);
1185 print_text(h, "\\&(");
1186 h->flags |= HTML_NOSPACE;
1187 return(1);
1188 }
1189
1190
1191 /* ARGSUSED */
1192 static void
1193 mdoc_pq_post(MDOC_ARGS)
1194 {
1195
1196 if (MDOC_BODY != n->type)
1197 return;
1198 print_text(h, ")");
1199 }
1200
1201
1202 /* ARGSUSED */
1203 static int
1204 mdoc_sq_pre(MDOC_ARGS)
1205 {
1206
1207 if (MDOC_BODY != n->type)
1208 return(1);
1209 print_text(h, "\\(oq");
1210 h->flags |= HTML_NOSPACE;
1211 return(1);
1212 }
1213
1214
1215 /* ARGSUSED */
1216 static void
1217 mdoc_sq_post(MDOC_ARGS)
1218 {
1219
1220 if (MDOC_BODY != n->type)
1221 return;
1222 h->flags |= HTML_NOSPACE;
1223 print_text(h, "\\(aq");
1224 }
1225
1226
1227 /* ARGSUSED */
1228 static int
1229 mdoc_em_pre(MDOC_ARGS)
1230 {
1231 struct htmlpair tag;
1232
1233 PAIR_CLASS_INIT(&tag, "emph");
1234 print_otag(h, TAG_SPAN, 1, &tag);
1235 return(1);
1236 }
1237
1238
1239 /* ARGSUSED */
1240 static int
1241 mdoc_d1_pre(MDOC_ARGS)
1242 {
1243 struct htmlpair tag[2];
1244 struct roffsu su;
1245
1246 if (MDOC_BLOCK != n->type)
1247 return(1);
1248
1249 /* FIXME: D1 shouldn't be literal. */
1250
1251 SCALE_VS_INIT(&su, INDENT - 1);
1252 bufcat_su(h, "margin-left", &su);
1253 PAIR_CLASS_INIT(&tag[0], "lit");
1254 PAIR_STYLE_INIT(&tag[1], h);
1255 print_otag(h, TAG_DIV, 2, tag);
1256 return(1);
1257 }
1258
1259
1260 /* ARGSUSED */
1261 static int
1262 mdoc_sx_pre(MDOC_ARGS)
1263 {
1264 struct htmlpair tag[2];
1265 const struct mdoc_node *nn;
1266 char buf[BUFSIZ];
1267
1268 strlcpy(buf, "#", BUFSIZ);
1269 for (nn = n->child; nn; nn = nn->next) {
1270 html_idcat(buf, nn->string, BUFSIZ);
1271 if (nn->next)
1272 html_idcat(buf, " ", BUFSIZ);
1273 }
1274
1275 PAIR_CLASS_INIT(&tag[0], "link-sec");
1276 PAIR_HREF_INIT(&tag[1], buf);
1277
1278 print_otag(h, TAG_A, 2, tag);
1279 return(1);
1280 }
1281
1282
1283 /* ARGSUSED */
1284 static int
1285 mdoc_aq_pre(MDOC_ARGS)
1286 {
1287
1288 if (MDOC_BODY != n->type)
1289 return(1);
1290 print_text(h, "\\(la");
1291 h->flags |= HTML_NOSPACE;
1292 return(1);
1293 }
1294
1295
1296 /* ARGSUSED */
1297 static void
1298 mdoc_aq_post(MDOC_ARGS)
1299 {
1300
1301 if (MDOC_BODY != n->type)
1302 return;
1303 h->flags |= HTML_NOSPACE;
1304 print_text(h, "\\(ra");
1305 }
1306
1307
1308 /* ARGSUSED */
1309 static int
1310 mdoc_bd_pre(MDOC_ARGS)
1311 {
1312 struct htmlpair tag[2];
1313 int type, comp, i;
1314 const struct mdoc_node *bl, *nn;
1315 struct roffsu su;
1316
1317 if (MDOC_BLOCK == n->type)
1318 bl = n;
1319 else if (MDOC_HEAD == n->type)
1320 return(0);
1321 else
1322 bl = n->parent;
1323
1324 SCALE_VS_INIT(&su, 0);
1325
1326 type = comp = 0;
1327 for (i = 0; i < (int)bl->args->argc; i++)
1328 switch (bl->args->argv[i].arg) {
1329 case (MDOC_Offset):
1330 a2offs(bl->args->argv[i].value[0], &su);
1331 break;
1332 case (MDOC_Compact):
1333 comp = 1;
1334 break;
1335 case (MDOC_Centred):
1336 /* FALLTHROUGH */
1337 case (MDOC_Ragged):
1338 /* FALLTHROUGH */
1339 case (MDOC_Filled):
1340 /* FALLTHROUGH */
1341 case (MDOC_Unfilled):
1342 /* FALLTHROUGH */
1343 case (MDOC_Literal):
1344 type = bl->args->argv[i].arg;
1345 break;
1346 default:
1347 break;
1348 }
1349
1350 /* FIXME: -centered, etc. formatting. */
1351 /* FIXME: does not respect -offset ??? */
1352
1353 if (MDOC_BLOCK == n->type) {
1354 bufcat_su(h, "margin-left", &su);
1355 for (nn = n; nn && ! comp; nn = nn->parent) {
1356 if (MDOC_BLOCK != nn->type)
1357 continue;
1358 if (MDOC_Ss == nn->tok || MDOC_Sh == nn->tok)
1359 comp = 1;
1360 if (nn->prev)
1361 break;
1362 }
1363 if (comp) {
1364 PAIR_STYLE_INIT(&tag[0], h);
1365 print_otag(h, TAG_DIV, 1, tag);
1366 return(1);
1367 }
1368 SCALE_VS_INIT(&su, 1);
1369 bufcat_su(h, "margin-top", &su);
1370 PAIR_STYLE_INIT(&tag[0], h);
1371 print_otag(h, TAG_DIV, 1, tag);
1372 return(1);
1373 }
1374
1375 if (MDOC_Unfilled != type && MDOC_Literal != type)
1376 return(1);
1377
1378 PAIR_CLASS_INIT(&tag[0], "lit");
1379 bufcat_style(h, "white-space", "pre");
1380 PAIR_STYLE_INIT(&tag[1], h);
1381 print_otag(h, TAG_DIV, 2, tag);
1382
1383 for (nn = n->child; nn; nn = nn->next) {
1384 h->flags |= HTML_NOSPACE;
1385 print_mdoc_node(m, nn, h);
1386 if (NULL == nn->next)
1387 continue;
1388 if (nn->prev && nn->prev->line < nn->line)
1389 print_text(h, "\n");
1390 else if (NULL == nn->prev)
1391 print_text(h, "\n");
1392 }
1393
1394 return(0);
1395 }
1396
1397
1398 /* ARGSUSED */
1399 static int
1400 mdoc_pa_pre(MDOC_ARGS)
1401 {
1402 struct htmlpair tag;
1403
1404 PAIR_CLASS_INIT(&tag, "file");
1405 print_otag(h, TAG_SPAN, 1, &tag);
1406 return(1);
1407 }
1408
1409
1410 /* ARGSUSED */
1411 static int
1412 mdoc_ad_pre(MDOC_ARGS)
1413 {
1414 struct htmlpair tag;
1415
1416 PAIR_CLASS_INIT(&tag, "addr");
1417 print_otag(h, TAG_SPAN, 1, &tag);
1418 return(1);
1419 }
1420
1421
1422 /* ARGSUSED */
1423 static int
1424 mdoc_an_pre(MDOC_ARGS)
1425 {
1426 struct htmlpair tag;
1427
1428 /* TODO: -split and -nosplit (see termp_an_pre()). */
1429
1430 PAIR_CLASS_INIT(&tag, "author");
1431 print_otag(h, TAG_SPAN, 1, &tag);
1432 return(1);
1433 }
1434
1435
1436 /* ARGSUSED */
1437 static int
1438 mdoc_cd_pre(MDOC_ARGS)
1439 {
1440 struct htmlpair tag;
1441
1442 print_otag(h, TAG_DIV, 0, NULL);
1443 PAIR_CLASS_INIT(&tag, "config");
1444 print_otag(h, TAG_SPAN, 1, &tag);
1445 return(1);
1446 }
1447
1448
1449 /* ARGSUSED */
1450 static int
1451 mdoc_dv_pre(MDOC_ARGS)
1452 {
1453 struct htmlpair tag;
1454
1455 PAIR_CLASS_INIT(&tag, "define");
1456 print_otag(h, TAG_SPAN, 1, &tag);
1457 return(1);
1458 }
1459
1460
1461 /* ARGSUSED */
1462 static int
1463 mdoc_ev_pre(MDOC_ARGS)
1464 {
1465 struct htmlpair tag;
1466
1467 PAIR_CLASS_INIT(&tag, "env");
1468 print_otag(h, TAG_SPAN, 1, &tag);
1469 return(1);
1470 }
1471
1472
1473 /* ARGSUSED */
1474 static int
1475 mdoc_er_pre(MDOC_ARGS)
1476 {
1477 struct htmlpair tag;
1478
1479 PAIR_CLASS_INIT(&tag, "errno");
1480 print_otag(h, TAG_SPAN, 1, &tag);
1481 return(1);
1482 }
1483
1484
1485 /* ARGSUSED */
1486 static int
1487 mdoc_fa_pre(MDOC_ARGS)
1488 {
1489 const struct mdoc_node *nn;
1490 struct htmlpair tag;
1491 struct tag *t;
1492
1493 PAIR_CLASS_INIT(&tag, "farg");
1494 if (n->parent->tok != MDOC_Fo) {
1495 print_otag(h, TAG_SPAN, 1, &tag);
1496 return(1);
1497 }
1498
1499 for (nn = n->child; nn; nn = nn->next) {
1500 t = print_otag(h, TAG_SPAN, 1, &tag);
1501 print_text(h, nn->string);
1502 print_tagq(h, t);
1503 if (nn->next)
1504 print_text(h, ",");
1505 }
1506
1507 if (n->child && n->next && n->next->tok == MDOC_Fa)
1508 print_text(h, ",");
1509
1510 return(0);
1511 }
1512
1513
1514 /* ARGSUSED */
1515 static int
1516 mdoc_fd_pre(MDOC_ARGS)
1517 {
1518 struct htmlpair tag;
1519 struct roffsu su;
1520
1521 if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
1522 if (n->next && MDOC_Fd != n->next->tok) {
1523 SCALE_VS_INIT(&su, 1);
1524 bufcat_su(h, "margin-bottom", &su);
1525 PAIR_STYLE_INIT(&tag, h);
1526 print_otag(h, TAG_DIV, 1, &tag);
1527 } else
1528 print_otag(h, TAG_DIV, 0, NULL);
1529 }
1530
1531 PAIR_CLASS_INIT(&tag, "macro");
1532 print_otag(h, TAG_SPAN, 1, &tag);
1533 return(1);
1534 }
1535
1536
1537 /* ARGSUSED */
1538 static int
1539 mdoc_vt_pre(MDOC_ARGS)
1540 {
1541 struct htmlpair tag;
1542 struct roffsu su;
1543
1544 if (SEC_SYNOPSIS == n->sec && MDOC_BLOCK == n->type) {
1545 if (n->next && MDOC_Vt != n->next->tok) {
1546 SCALE_VS_INIT(&su, 1);
1547 bufcat_su(h, "margin-bottom", &su);
1548 PAIR_STYLE_INIT(&tag, h);
1549 print_otag(h, TAG_DIV, 1, &tag);
1550 } else
1551 print_otag(h, TAG_DIV, 0, NULL);
1552
1553 return(1);
1554 } else if (MDOC_HEAD == n->type)
1555 return(0);
1556
1557 PAIR_CLASS_INIT(&tag, "type");
1558 print_otag(h, TAG_SPAN, 1, &tag);
1559 return(1);
1560 }
1561
1562
1563 /* ARGSUSED */
1564 static int
1565 mdoc_ft_pre(MDOC_ARGS)
1566 {
1567 struct htmlpair tag;
1568
1569 if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
1570 print_otag(h, TAG_DIV, 0, NULL);
1571
1572 PAIR_CLASS_INIT(&tag, "ftype");
1573 print_otag(h, TAG_SPAN, 1, &tag);
1574 return(1);
1575 }
1576
1577
1578 /* ARGSUSED */
1579 static int
1580 mdoc_fn_pre(MDOC_ARGS)
1581 {
1582 struct tag *t;
1583 struct htmlpair tag[2];
1584 const struct mdoc_node *nn;
1585 char nbuf[BUFSIZ];
1586 const char *sp, *ep;
1587 int sz, i;
1588 struct roffsu su;
1589
1590 if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
1591 SCALE_HS_INIT(&su, INDENT);
1592 bufcat_su(h, "margin-left", &su);
1593 su.scale = -su.scale;
1594 bufcat_su(h, "text-indent", &su);
1595 if (n->next) {
1596 SCALE_VS_INIT(&su, 1);
1597 bufcat_su(h, "margin-bottom", &su);
1598 }
1599 PAIR_STYLE_INIT(&tag[0], h);
1600 print_otag(h, TAG_DIV, 1, tag);
1601 }
1602
1603 /* Split apart into type and name. */
1604 assert(n->child->string);
1605 sp = n->child->string;
1606
1607 ep = strchr(sp, ' ');
1608 if (NULL != ep) {
1609 PAIR_CLASS_INIT(&tag[0], "ftype");
1610 t = print_otag(h, TAG_SPAN, 1, tag);
1611
1612 while (ep) {
1613 sz = MIN((int)(ep - sp), BUFSIZ - 1);
1614 (void)memcpy(nbuf, sp, (size_t)sz);
1615 nbuf[sz] = '\0';
1616 print_text(h, nbuf);
1617 sp = ++ep;
1618 ep = strchr(sp, ' ');
1619 }
1620 print_tagq(h, t);
1621 }
1622
1623 PAIR_CLASS_INIT(&tag[0], "fname");
1624
1625 /*
1626 * FIXME: only refer to IDs that we know exist.
1627 */
1628
1629 #if 0
1630 if (SEC_SYNOPSIS == n->sec) {
1631 nbuf[0] = '\0';
1632 html_idcat(nbuf, sp, BUFSIZ);
1633 PAIR_ID_INIT(&tag[1], nbuf);
1634 } else {
1635 strlcpy(nbuf, "#", BUFSIZ);
1636 html_idcat(nbuf, sp, BUFSIZ);
1637 PAIR_HREF_INIT(&tag[1], nbuf);
1638 }
1639 #endif
1640
1641 t = print_otag(h, TAG_SPAN, 1, tag);
1642
1643 if (sp) {
1644 strlcpy(nbuf, sp, BUFSIZ);
1645 print_text(h, nbuf);
1646 }
1647
1648 print_tagq(h, t);
1649
1650 h->flags |= HTML_NOSPACE;
1651 print_text(h, "(");
1652
1653 bufinit(h);
1654 PAIR_CLASS_INIT(&tag[0], "farg");
1655 bufcat_style(h, "white-space", "nowrap");
1656 PAIR_STYLE_INIT(&tag[1], h);
1657
1658 for (nn = n->child->next; nn; nn = nn->next) {
1659 i = 1;
1660 if (SEC_SYNOPSIS == n->sec)
1661 i = 2;
1662 t = print_otag(h, TAG_SPAN, i, tag);
1663 print_text(h, nn->string);
1664 print_tagq(h, t);
1665 if (nn->next)
1666 print_text(h, ",");
1667 }
1668
1669 print_text(h, ")");
1670 if (SEC_SYNOPSIS == n->sec)
1671 print_text(h, ";");
1672
1673 return(0);
1674 }
1675
1676
1677 /* ARGSUSED */
1678 static int
1679 mdoc_sp_pre(MDOC_ARGS)
1680 {
1681 int len;
1682 struct htmlpair tag;
1683 struct roffsu su;
1684
1685 switch (n->tok) {
1686 case (MDOC_sp):
1687 /* FIXME: can this have a scaling indicator? */
1688 len = n->child ? atoi(n->child->string) : 1;
1689 break;
1690 case (MDOC_br):
1691 len = 0;
1692 break;
1693 default:
1694 len = 1;
1695 break;
1696 }
1697
1698 SCALE_VS_INIT(&su, len);
1699 bufcat_su(h, "height", &su);
1700 PAIR_STYLE_INIT(&tag, h);
1701 print_otag(h, TAG_DIV, 1, &tag);
1702 /* So the div isn't empty: */
1703 print_text(h, "\\~");
1704
1705 return(0);
1706
1707 }
1708
1709
1710 /* ARGSUSED */
1711 static int
1712 mdoc_brq_pre(MDOC_ARGS)
1713 {
1714
1715 if (MDOC_BODY != n->type)
1716 return(1);
1717 print_text(h, "\\(lC");
1718 h->flags |= HTML_NOSPACE;
1719 return(1);
1720 }
1721
1722
1723 /* ARGSUSED */
1724 static void
1725 mdoc_brq_post(MDOC_ARGS)
1726 {
1727
1728 if (MDOC_BODY != n->type)
1729 return;
1730 h->flags |= HTML_NOSPACE;
1731 print_text(h, "\\(rC");
1732 }
1733
1734
1735 /* ARGSUSED */
1736 static int
1737 mdoc_lk_pre(MDOC_ARGS)
1738 {
1739 const struct mdoc_node *nn;
1740 struct htmlpair tag[2];
1741
1742 nn = n->child;
1743
1744 PAIR_CLASS_INIT(&tag[0], "link-ext");
1745 PAIR_HREF_INIT(&tag[1], nn->string);
1746 print_otag(h, TAG_A, 2, tag);
1747
1748 if (NULL == nn->next)
1749 return(1);
1750
1751 for (nn = nn->next; nn; nn = nn->next)
1752 print_text(h, nn->string);
1753
1754 return(0);
1755 }
1756
1757
1758 /* ARGSUSED */
1759 static int
1760 mdoc_mt_pre(MDOC_ARGS)
1761 {
1762 struct htmlpair tag[2];
1763 struct tag *t;
1764 const struct mdoc_node *nn;
1765
1766 PAIR_CLASS_INIT(&tag[0], "link-mail");
1767
1768 for (nn = n->child; nn; nn = nn->next) {
1769 bufinit(h);
1770 bufcat(h, "mailto:");
1771 bufcat(h, nn->string);
1772 PAIR_HREF_INIT(&tag[1], h->buf);
1773 t = print_otag(h, TAG_A, 2, tag);
1774 print_text(h, nn->string);
1775 print_tagq(h, t);
1776 }
1777
1778 return(0);
1779 }
1780
1781
1782 /* ARGSUSED */
1783 static int
1784 mdoc_fo_pre(MDOC_ARGS)
1785 {
1786 struct htmlpair tag;
1787 struct roffsu su;
1788
1789 if (MDOC_BODY == n->type) {
1790 h->flags |= HTML_NOSPACE;
1791 print_text(h, "(");
1792 h->flags |= HTML_NOSPACE;
1793 return(1);
1794 } else if (MDOC_BLOCK == n->type && n->next) {
1795 SCALE_VS_INIT(&su, 1);
1796 bufcat_su(h, "margin-bottom", &su);
1797 PAIR_STYLE_INIT(&tag, h);
1798 print_otag(h, TAG_DIV, 1, &tag);
1799 return(1);
1800 }
1801
1802 PAIR_CLASS_INIT(&tag, "fname");
1803 print_otag(h, TAG_SPAN, 1, &tag);
1804 return(1);
1805 }
1806
1807
1808 /* ARGSUSED */
1809 static void
1810 mdoc_fo_post(MDOC_ARGS)
1811 {
1812 if (MDOC_BODY != n->type)
1813 return;
1814 h->flags |= HTML_NOSPACE;
1815 print_text(h, ")");
1816 h->flags |= HTML_NOSPACE;
1817 print_text(h, ";");
1818 }
1819
1820
1821 /* ARGSUSED */
1822 static int
1823 mdoc_in_pre(MDOC_ARGS)
1824 {
1825 const struct mdoc_node *nn;
1826 struct tag *t;
1827 struct htmlpair tag[2];
1828 int i;
1829 struct roffsu su;
1830
1831 if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
1832 if (n->next && MDOC_In != n->next->tok) {
1833 SCALE_VS_INIT(&su, 1);
1834 bufcat_su(h, "margin-bottom", &su);
1835 PAIR_STYLE_INIT(&tag[0], h);
1836 print_otag(h, TAG_DIV, 1, tag);
1837 } else
1838 print_otag(h, TAG_DIV, 0, NULL);
1839 }
1840
1841 /* FIXME: there's a buffer bug in here somewhere. */
1842
1843 PAIR_CLASS_INIT(&tag[0], "includes");
1844 print_otag(h, TAG_SPAN, 1, tag);
1845
1846 if (SEC_SYNOPSIS == n->sec)
1847 print_text(h, "#include");
1848
1849 print_text(h, "<");
1850 h->flags |= HTML_NOSPACE;
1851
1852 /* XXX -- see warning in termp_in_post(). */
1853
1854 for (nn = n->child; nn; nn = nn->next) {
1855 PAIR_CLASS_INIT(&tag[0], "link-includes");
1856 i = 1;
1857 bufinit(h);
1858 if (h->base_includes) {
1859 buffmt_includes(h, nn->string);
1860 PAIR_HREF_INIT(&tag[i], h->buf);
1861 i++;
1862 }
1863 t = print_otag(h, TAG_A, i, tag);
1864 print_mdoc_node(m, nn, h);
1865 print_tagq(h, t);
1866 }
1867
1868 h->flags |= HTML_NOSPACE;
1869 print_text(h, ">");
1870
1871 return(0);
1872 }
1873
1874
1875 /* ARGSUSED */
1876 static int
1877 mdoc_ic_pre(MDOC_ARGS)
1878 {
1879 struct htmlpair tag;
1880
1881 PAIR_CLASS_INIT(&tag, "cmd");
1882 print_otag(h, TAG_SPAN, 1, &tag);
1883 return(1);
1884 }
1885
1886
1887 /* ARGSUSED */
1888 static int
1889 mdoc_rv_pre(MDOC_ARGS)
1890 {
1891 const struct mdoc_node *nn;
1892 struct htmlpair tag;
1893 struct tag *t;
1894
1895 print_otag(h, TAG_DIV, 0, NULL);
1896 print_text(h, "The");
1897
1898 for (nn = n->child; nn; nn = nn->next) {
1899 PAIR_CLASS_INIT(&tag, "fname");
1900 t = print_otag(h, TAG_SPAN, 1, &tag);
1901 print_text(h, nn->string);
1902 print_tagq(h, t);
1903
1904 h->flags |= HTML_NOSPACE;
1905 if (nn->next && NULL == nn->next->next)
1906 print_text(h, "(), and");
1907 else if (nn->next)
1908 print_text(h, "(),");
1909 else
1910 print_text(h, "()");
1911 }
1912
1913 if (n->child && n->child->next)
1914 print_text(h, "functions return");
1915 else
1916 print_text(h, "function returns");
1917
1918 print_text(h, "the value 0 if successful; otherwise the value "
1919 "-1 is returned and the global variable");
1920
1921 PAIR_CLASS_INIT(&tag, "var");
1922 t = print_otag(h, TAG_SPAN, 1, &tag);
1923 print_text(h, "errno");
1924 print_tagq(h, t);
1925 print_text(h, "is set to indicate the error.");
1926 return(0);
1927 }
1928
1929
1930 /* ARGSUSED */
1931 static int
1932 mdoc_va_pre(MDOC_ARGS)
1933 {
1934 struct htmlpair tag;
1935
1936 PAIR_CLASS_INIT(&tag, "var");
1937 print_otag(h, TAG_SPAN, 1, &tag);
1938 return(1);
1939 }
1940
1941
1942 /* ARGSUSED */
1943 static int
1944 mdoc_bq_pre(MDOC_ARGS)
1945 {
1946
1947 if (MDOC_BODY != n->type)
1948 return(1);
1949 print_text(h, "\\(lB");
1950 h->flags |= HTML_NOSPACE;
1951 return(1);
1952 }
1953
1954
1955 /* ARGSUSED */
1956 static void
1957 mdoc_bq_post(MDOC_ARGS)
1958 {
1959
1960 if (MDOC_BODY != n->type)
1961 return;
1962 h->flags |= HTML_NOSPACE;
1963 print_text(h, "\\(rB");
1964 }
1965
1966
1967 /* ARGSUSED */
1968 static int
1969 mdoc_ap_pre(MDOC_ARGS)
1970 {
1971
1972 h->flags |= HTML_NOSPACE;
1973 print_text(h, "\\(aq");
1974 h->flags |= HTML_NOSPACE;
1975 return(1);
1976 }
1977
1978
1979 /* ARGSUSED */
1980 static int
1981 mdoc_bf_pre(MDOC_ARGS)
1982 {
1983 int i;
1984 struct htmlpair tag[2];
1985 struct roffsu su;
1986
1987 if (MDOC_HEAD == n->type)
1988 return(0);
1989 else if (MDOC_BLOCK != n->type)
1990 return(1);
1991
1992 PAIR_CLASS_INIT(&tag[0], "lit");
1993
1994 if (n->head->child) {
1995 if ( ! strcmp("Em", n->head->child->string))
1996 PAIR_CLASS_INIT(&tag[0], "emph");
1997 else if ( ! strcmp("Sy", n->head->child->string))
1998 PAIR_CLASS_INIT(&tag[0], "symb");
1999 else if ( ! strcmp("Li", n->head->child->string))
2000 PAIR_CLASS_INIT(&tag[0], "lit");
2001 } else {
2002 assert(n->args);
2003 for (i = 0; i < (int)n->args->argc; i++)
2004 switch (n->args->argv[i].arg) {
2005 case (MDOC_Symbolic):
2006 PAIR_CLASS_INIT(&tag[0], "symb");
2007 break;
2008 case (MDOC_Literal):
2009 PAIR_CLASS_INIT(&tag[0], "lit");
2010 break;
2011 case (MDOC_Emphasis):
2012 PAIR_CLASS_INIT(&tag[0], "emph");
2013 break;
2014 default:
2015 break;
2016 }
2017 }
2018
2019 /* FIXME: div's have spaces stripped--we want them. */
2020
2021 bufcat_style(h, "display", "inline");
2022 SCALE_HS_INIT(&su, 1);
2023 bufcat_su(h, "margin-right", &su);
2024 PAIR_STYLE_INIT(&tag[1], h);
2025 print_otag(h, TAG_DIV, 2, tag);
2026 return(1);
2027 }
2028
2029
2030 /* ARGSUSED */
2031 static int
2032 mdoc_ms_pre(MDOC_ARGS)
2033 {
2034 struct htmlpair tag;
2035
2036 PAIR_CLASS_INIT(&tag, "symb");
2037 print_otag(h, TAG_SPAN, 1, &tag);
2038 return(1);
2039 }
2040
2041
2042 /* ARGSUSED */
2043 static int
2044 mdoc_pf_pre(MDOC_ARGS)
2045 {
2046
2047 h->flags |= HTML_IGNDELIM;
2048 return(1);
2049 }
2050
2051
2052 /* ARGSUSED */
2053 static void
2054 mdoc_pf_post(MDOC_ARGS)
2055 {
2056
2057 h->flags &= ~HTML_IGNDELIM;
2058 h->flags |= HTML_NOSPACE;
2059 }
2060
2061
2062 /* ARGSUSED */
2063 static int
2064 mdoc_rs_pre(MDOC_ARGS)
2065 {
2066 struct htmlpair tag;
2067 struct roffsu su;
2068
2069 if (MDOC_BLOCK != n->type)
2070 return(1);
2071
2072 if (n->prev && SEC_SEE_ALSO == n->sec) {
2073 SCALE_VS_INIT(&su, 1);
2074 bufcat_su(h, "margin-top", &su);
2075 PAIR_STYLE_INIT(&tag, h);
2076 print_otag(h, TAG_DIV, 1, &tag);
2077 }
2078
2079 PAIR_CLASS_INIT(&tag, "ref");
2080 print_otag(h, TAG_SPAN, 1, &tag);
2081 return(1);
2082 }
2083
2084
2085
2086 /* ARGSUSED */
2087 static int
2088 mdoc_li_pre(MDOC_ARGS)
2089 {
2090 struct htmlpair tag;
2091
2092 PAIR_CLASS_INIT(&tag, "lit");
2093 print_otag(h, TAG_SPAN, 1, &tag);
2094 return(1);
2095 }
2096
2097
2098 /* ARGSUSED */
2099 static int
2100 mdoc_sy_pre(MDOC_ARGS)
2101 {
2102 struct htmlpair tag;
2103
2104 PAIR_CLASS_INIT(&tag, "symb");
2105 print_otag(h, TAG_SPAN, 1, &tag);
2106 return(1);
2107 }
2108
2109
2110 /* ARGSUSED */
2111 static int
2112 mdoc_bt_pre(MDOC_ARGS)
2113 {
2114
2115 print_text(h, "is currently in beta test.");
2116 return(0);
2117 }
2118
2119
2120 /* ARGSUSED */
2121 static int
2122 mdoc_ud_pre(MDOC_ARGS)
2123 {
2124
2125 print_text(h, "currently under development.");
2126 return(0);
2127 }
2128
2129
2130 /* ARGSUSED */
2131 static int
2132 mdoc_lb_pre(MDOC_ARGS)
2133 {
2134 struct htmlpair tag;
2135
2136 if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags)
2137 print_otag(h, TAG_DIV, 0, NULL);
2138 PAIR_CLASS_INIT(&tag, "lib");
2139 print_otag(h, TAG_SPAN, 1, &tag);
2140 return(1);
2141 }
2142
2143
2144 /* ARGSUSED */
2145 static int
2146 mdoc__x_pre(MDOC_ARGS)
2147 {
2148 struct htmlpair tag[2];
2149
2150 switch (n->tok) {
2151 case(MDOC__A):
2152 PAIR_CLASS_INIT(&tag[0], "ref-auth");
2153 break;
2154 case(MDOC__B):
2155 PAIR_CLASS_INIT(&tag[0], "ref-book");
2156 break;
2157 case(MDOC__C):
2158 PAIR_CLASS_INIT(&tag[0], "ref-city");
2159 break;
2160 case(MDOC__D):
2161 PAIR_CLASS_INIT(&tag[0], "ref-date");
2162 break;
2163 case(MDOC__I):
2164 PAIR_CLASS_INIT(&tag[0], "ref-issue");
2165 break;
2166 case(MDOC__J):
2167 PAIR_CLASS_INIT(&tag[0], "ref-jrnl");
2168 break;
2169 case(MDOC__N):
2170 PAIR_CLASS_INIT(&tag[0], "ref-num");
2171 break;
2172 case(MDOC__O):
2173 PAIR_CLASS_INIT(&tag[0], "ref-opt");
2174 break;
2175 case(MDOC__P):
2176 PAIR_CLASS_INIT(&tag[0], "ref-page");
2177 break;
2178 case(MDOC__Q):
2179 PAIR_CLASS_INIT(&tag[0], "ref-corp");
2180 break;
2181 case(MDOC__R):
2182 PAIR_CLASS_INIT(&tag[0], "ref-rep");
2183 break;
2184 case(MDOC__T):
2185 PAIR_CLASS_INIT(&tag[0], "ref-title");
2186 break;
2187 case(MDOC__U):
2188 PAIR_CLASS_INIT(&tag[0], "link-ref");
2189 break;
2190 case(MDOC__V):
2191 PAIR_CLASS_INIT(&tag[0], "ref-vol");
2192 break;
2193 default:
2194 abort();
2195 /* NOTREACHED */
2196 }
2197
2198 if (MDOC__U != n->tok) {
2199 print_otag(h, TAG_SPAN, 1, tag);
2200 return(1);
2201 }
2202
2203 PAIR_HREF_INIT(&tag[1], n->child->string);
2204 print_otag(h, TAG_A, 2, tag);
2205 return(1);
2206 }
2207
2208
2209 /* ARGSUSED */
2210 static void
2211 mdoc__x_post(MDOC_ARGS)
2212 {
2213
2214 /* TODO: %U */
2215
2216 h->flags |= HTML_NOSPACE;
2217 print_text(h, n->next ? "," : ".");
2218 }