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