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