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