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