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