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