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