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