Annotation of mandoc/man_html.c, Revision 1.92
1.92 ! schwarze 1: /* $Id: man_html.c,v 1.91 2014/03/08 15:50:41 schwarze Exp $ */
1.1 kristaps 2: /*
1.87 schwarze 3: * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
1.91 schwarze 4: * Copyright (c) 2013, 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.25 kristaps 18: #ifdef HAVE_CONFIG_H
19: #include "config.h"
20: #endif
21:
1.1 kristaps 22: #include <sys/types.h>
23:
1.5 kristaps 24: #include <assert.h>
25: #include <ctype.h>
1.2 kristaps 26: #include <stdio.h>
1.1 kristaps 27: #include <stdlib.h>
1.4 kristaps 28: #include <string.h>
1.1 kristaps 29:
1.35 kristaps 30: #include "mandoc.h"
1.7 kristaps 31: #include "out.h"
1.1 kristaps 32: #include "html.h"
33: #include "man.h"
1.10 kristaps 34: #include "main.h"
1.1 kristaps 35:
1.6 kristaps 36: /* TODO: preserve ident widths. */
1.13 kristaps 37: /* FIXME: have PD set the default vspace width. */
1.6 kristaps 38:
39: #define INDENT 5
1.4 kristaps 40:
1.89 schwarze 41: #define MAN_ARGS const struct man_meta *man, \
1.3 kristaps 42: const struct man_node *n, \
1.45 kristaps 43: struct mhtml *mh, \
1.3 kristaps 44: struct html *h
45:
1.45 kristaps 46: struct mhtml {
47: int fl;
48: #define MANH_LITERAL (1 << 0) /* literal context */
49: };
50:
1.3 kristaps 51: struct htmlman {
52: int (*pre)(MAN_ARGS);
53: int (*post)(MAN_ARGS);
54: };
55:
1.74 kristaps 56: static void print_bvspace(struct html *,
57: const struct man_node *);
1.3 kristaps 58: static void print_man(MAN_ARGS);
59: static void print_man_head(MAN_ARGS);
1.4 kristaps 60: static void print_man_nodelist(MAN_ARGS);
61: static void print_man_node(MAN_ARGS);
1.7 kristaps 62: static int a2width(const struct man_node *,
63: struct roffsu *);
1.8 kristaps 64: static int man_B_pre(MAN_ARGS);
1.6 kristaps 65: static int man_HP_pre(MAN_ARGS);
1.86 kristaps 66: static int man_IP_pre(MAN_ARGS);
1.8 kristaps 67: static int man_I_pre(MAN_ARGS);
1.86 kristaps 68: static int man_OP_pre(MAN_ARGS);
1.4 kristaps 69: static int man_PP_pre(MAN_ARGS);
1.9 kristaps 70: static int man_RS_pre(MAN_ARGS);
1.4 kristaps 71: static int man_SH_pre(MAN_ARGS);
1.8 kristaps 72: static int man_SM_pre(MAN_ARGS);
1.4 kristaps 73: static int man_SS_pre(MAN_ARGS);
1.90 schwarze 74: static int man_UR_pre(MAN_ARGS);
1.86 kristaps 75: static int man_alt_pre(MAN_ARGS);
76: static int man_br_pre(MAN_ARGS);
77: static int man_ign_pre(MAN_ARGS);
78: static int man_in_pre(MAN_ARGS);
79: static int man_literal_pre(MAN_ARGS);
80: static void man_root_post(MAN_ARGS);
81: static void man_root_pre(MAN_ARGS);
1.4 kristaps 82:
1.3 kristaps 83: static const struct htmlman mans[MAN_MAX] = {
1.4 kristaps 84: { man_br_pre, NULL }, /* br */
1.3 kristaps 85: { NULL, NULL }, /* TH */
1.4 kristaps 86: { man_SH_pre, NULL }, /* SH */
87: { man_SS_pre, NULL }, /* SS */
1.6 kristaps 88: { man_IP_pre, NULL }, /* TP */
1.4 kristaps 89: { man_PP_pre, NULL }, /* LP */
90: { man_PP_pre, NULL }, /* PP */
91: { man_PP_pre, NULL }, /* P */
1.5 kristaps 92: { man_IP_pre, NULL }, /* IP */
1.6 kristaps 93: { man_HP_pre, NULL }, /* HP */
1.8 kristaps 94: { man_SM_pre, NULL }, /* SM */
1.56 kristaps 95: { man_SM_pre, NULL }, /* SB */
1.8 kristaps 96: { man_alt_pre, NULL }, /* BI */
97: { man_alt_pre, NULL }, /* IB */
98: { man_alt_pre, NULL }, /* BR */
99: { man_alt_pre, NULL }, /* RB */
1.3 kristaps 100: { NULL, NULL }, /* R */
1.8 kristaps 101: { man_B_pre, NULL }, /* B */
102: { man_I_pre, NULL }, /* I */
103: { man_alt_pre, NULL }, /* IR */
104: { man_alt_pre, NULL }, /* RI */
1.67 schwarze 105: { man_ign_pre, NULL }, /* na */
1.4 kristaps 106: { man_br_pre, NULL }, /* sp */
1.45 kristaps 107: { man_literal_pre, NULL }, /* nf */
108: { man_literal_pre, NULL }, /* fi */
1.3 kristaps 109: { NULL, NULL }, /* RE */
1.9 kristaps 110: { man_RS_pre, NULL }, /* RS */
1.8 kristaps 111: { man_ign_pre, NULL }, /* DT */
112: { man_ign_pre, NULL }, /* UC */
1.13 kristaps 113: { man_ign_pre, NULL }, /* PD */
1.34 joerg 114: { man_ign_pre, NULL }, /* AT */
1.45 kristaps 115: { man_in_pre, NULL }, /* in */
1.51 kristaps 116: { man_ign_pre, NULL }, /* ft */
1.86 kristaps 117: { man_OP_pre, NULL }, /* OP */
1.88 schwarze 118: { man_literal_pre, NULL }, /* EX */
119: { man_literal_pre, NULL }, /* EE */
1.90 schwarze 120: { man_UR_pre, NULL }, /* UR */
121: { NULL, NULL }, /* UE */
1.92 ! schwarze 122: { man_ign_pre, NULL }, /* ll */
1.3 kristaps 123: };
124:
1.74 kristaps 125: /*
126: * Printing leading vertical space before a block.
127: * This is used for the paragraph macros.
128: * The rules are pretty simple, since there's very little nesting going
129: * on here. Basically, if we're the first within another block (SS/SH),
130: * then don't emit vertical space. If we are (RS), then do. If not the
131: * first, print it.
132: */
133: static void
134: print_bvspace(struct html *h, const struct man_node *n)
135: {
136:
137: if (n->body && n->body->child)
138: if (MAN_TBL == n->body->child->type)
139: return;
140:
141: if (MAN_ROOT == n->parent->type || MAN_RS != n->parent->tok)
142: if (NULL == n->prev)
143: return;
144:
145: print_otag(h, TAG_P, 0, NULL);
146: }
1.1 kristaps 147:
148: void
1.89 schwarze 149: html_man(void *arg, const struct man *man)
1.1 kristaps 150: {
1.45 kristaps 151: struct mhtml mh;
1.3 kristaps 152:
1.45 kristaps 153: memset(&mh, 0, sizeof(struct mhtml));
1.89 schwarze 154: print_man(man_meta(man), man_node(man), &mh, (struct html *)arg);
1.82 kristaps 155: putchar('\n');
1.3 kristaps 156: }
157:
158: static void
159: print_man(MAN_ARGS)
160: {
1.82 kristaps 161: struct tag *t, *tt;
162: struct htmlpair tag;
163:
164: PAIR_CLASS_INIT(&tag, "mandoc");
1.3 kristaps 165:
1.82 kristaps 166: if ( ! (HTML_FRAGMENT & h->oflags)) {
167: print_gen_decls(h);
168: t = print_otag(h, TAG_HTML, 0, NULL);
169: tt = print_otag(h, TAG_HEAD, 0, NULL);
1.89 schwarze 170: print_man_head(man, n, mh, h);
1.82 kristaps 171: print_tagq(h, tt);
172: print_otag(h, TAG_BODY, 0, NULL);
173: print_otag(h, TAG_DIV, 1, &tag);
174: } else
175: t = print_otag(h, TAG_DIV, 1, &tag);
1.53 kristaps 176:
1.89 schwarze 177: print_man_nodelist(man, n, mh, h);
1.3 kristaps 178: print_tagq(h, t);
179: }
180:
181:
182: /* ARGSUSED */
183: static void
184: print_man_head(MAN_ARGS)
185: {
186:
187: print_gen_head(h);
1.89 schwarze 188: assert(man->title);
189: assert(man->msec);
190: bufcat_fmt(h, "%s(%s)", man->title, man->msec);
1.3 kristaps 191: print_otag(h, TAG_TITLE, 0, NULL);
192: print_text(h, h->buf);
1.1 kristaps 193: }
1.4 kristaps 194:
195:
196: static void
197: print_man_nodelist(MAN_ARGS)
198: {
199:
1.89 schwarze 200: print_man_node(man, n, mh, h);
1.4 kristaps 201: if (n->next)
1.89 schwarze 202: print_man_nodelist(man, n->next, mh, h);
1.4 kristaps 203: }
204:
205:
206: static void
207: print_man_node(MAN_ARGS)
208: {
209: int child;
210: struct tag *t;
211:
212: child = 1;
1.14 kristaps 213: t = h->tags.head;
1.4 kristaps 214:
215: switch (n->type) {
216: case (MAN_ROOT):
1.89 schwarze 217: man_root_pre(man, n, mh, h);
1.4 kristaps 218: break;
219: case (MAN_TEXT):
1.65 kristaps 220: /*
221: * If we have a blank line, output a vertical space.
222: * If we have a space as the first character, break
223: * before printing the line's data.
224: */
1.63 kristaps 225: if ('\0' == *n->string) {
226: print_otag(h, TAG_P, 0, NULL);
227: return;
1.78 kristaps 228: }
229:
230: if (' ' == *n->string && MAN_LINE & n->flags)
231: print_otag(h, TAG_BR, 0, NULL);
232: else if (MANH_LITERAL & mh->fl && n->prev)
1.63 kristaps 233: print_otag(h, TAG_BR, 0, NULL);
234:
1.4 kristaps 235: print_text(h, n->string);
1.68 kristaps 236: return;
237: case (MAN_EQN):
1.80 kristaps 238: print_eqn(h, n->eqn);
1.69 kristaps 239: break;
1.58 kristaps 240: case (MAN_TBL):
1.66 kristaps 241: /*
242: * This will take care of initialising all of the table
243: * state data for the first table, then tearing it down
244: * for the last one.
245: */
1.60 kristaps 246: print_tbl(h, n->span);
1.64 kristaps 247: return;
1.4 kristaps 248: default:
1.21 kristaps 249: /*
250: * Close out scope of font prior to opening a macro
1.66 kristaps 251: * scope.
1.21 kristaps 252: */
1.57 kristaps 253: if (HTMLFONT_NONE != h->metac) {
254: h->metal = h->metac;
255: h->metac = HTMLFONT_NONE;
1.66 kristaps 256: }
257:
258: /*
259: * Close out the current table, if it's open, and unset
260: * the "meta" table state. This will be reopened on the
261: * next table element.
262: */
263: if (h->tblt) {
264: print_tblclose(h);
265: t = h->tags.head;
1.20 kristaps 266: }
1.4 kristaps 267: if (mans[n->tok].pre)
1.89 schwarze 268: child = (*mans[n->tok].pre)(man, n, mh, h);
1.4 kristaps 269: break;
270: }
271:
1.21 kristaps 272: if (child && n->child)
1.89 schwarze 273: print_man_nodelist(man, n->child, mh, h);
1.21 kristaps 274:
1.24 kristaps 275: /* This will automatically close out any font scope. */
1.4 kristaps 276: print_stagq(h, t);
277:
1.61 kristaps 278: switch (n->type) {
279: case (MAN_ROOT):
1.89 schwarze 280: man_root_post(man, n, mh, h);
1.69 kristaps 281: break;
282: case (MAN_EQN):
1.61 kristaps 283: break;
284: default:
285: if (mans[n->tok].post)
1.89 schwarze 286: (*mans[n->tok].post)(man, n, mh, h);
1.61 kristaps 287: break;
288: }
1.4 kristaps 289: }
290:
291:
1.5 kristaps 292: static int
1.7 kristaps 293: a2width(const struct man_node *n, struct roffsu *su)
1.5 kristaps 294: {
295:
1.6 kristaps 296: if (MAN_TEXT != n->type)
1.7 kristaps 297: return(0);
1.11 kristaps 298: if (a2roffsu(n->string, su, SCALE_BU))
1.7 kristaps 299: return(1);
1.5 kristaps 300:
1.7 kristaps 301: return(0);
1.5 kristaps 302: }
303:
304:
1.40 kristaps 305: /* ARGSUSED */
1.65 kristaps 306: static void
1.4 kristaps 307: man_root_pre(MAN_ARGS)
308: {
1.56 kristaps 309: struct htmlpair tag[3];
1.4 kristaps 310: struct tag *t, *tt;
311: char b[BUFSIZ], title[BUFSIZ];
312:
313: b[0] = 0;
1.89 schwarze 314: if (man->vol)
315: (void)strlcat(b, man->vol, BUFSIZ);
1.4 kristaps 316:
1.89 schwarze 317: assert(man->title);
318: assert(man->msec);
319: snprintf(title, BUFSIZ - 1, "%s(%s)", man->title, man->msec);
1.4 kristaps 320:
1.56 kristaps 321: PAIR_SUMMARY_INIT(&tag[0], "Document Header");
322: PAIR_CLASS_INIT(&tag[1], "head");
1.83 schwarze 323: PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
324: t = print_otag(h, TAG_TABLE, 3, tag);
325: PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
326: print_otag(h, TAG_COL, 1, tag);
327: print_otag(h, TAG_COL, 1, tag);
328: print_otag(h, TAG_COL, 1, tag);
1.56 kristaps 329:
330: print_otag(h, TAG_TBODY, 0, NULL);
1.15 kristaps 331:
1.4 kristaps 332: tt = print_otag(h, TAG_TR, 0, NULL);
333:
1.55 kristaps 334: PAIR_CLASS_INIT(&tag[0], "head-ltitle");
1.4 kristaps 335: print_otag(h, TAG_TD, 1, tag);
336: print_text(h, title);
337: print_stagq(h, tt);
338:
1.55 kristaps 339: PAIR_CLASS_INIT(&tag[0], "head-vol");
1.83 schwarze 340: PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
341: print_otag(h, TAG_TD, 2, tag);
1.4 kristaps 342: print_text(h, b);
343: print_stagq(h, tt);
344:
1.55 kristaps 345: PAIR_CLASS_INIT(&tag[0], "head-rtitle");
1.83 schwarze 346: PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
347: print_otag(h, TAG_TD, 2, tag);
1.4 kristaps 348: print_text(h, title);
349: print_tagq(h, t);
350: }
351:
352:
353: /* ARGSUSED */
354: static void
355: man_root_post(MAN_ARGS)
356: {
1.56 kristaps 357: struct htmlpair tag[3];
1.4 kristaps 358: struct tag *t, *tt;
359:
1.56 kristaps 360: PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
361: PAIR_CLASS_INIT(&tag[1], "foot");
1.83 schwarze 362: PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
363: t = print_otag(h, TAG_TABLE, 3, tag);
364: PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
365: print_otag(h, TAG_COL, 1, tag);
366: print_otag(h, TAG_COL, 1, tag);
1.15 kristaps 367:
1.4 kristaps 368: tt = print_otag(h, TAG_TR, 0, NULL);
369:
1.55 kristaps 370: PAIR_CLASS_INIT(&tag[0], "foot-date");
1.4 kristaps 371: print_otag(h, TAG_TD, 1, tag);
1.55 kristaps 372:
1.89 schwarze 373: assert(man->date);
374: print_text(h, man->date);
1.4 kristaps 375: print_stagq(h, tt);
376:
1.55 kristaps 377: PAIR_CLASS_INIT(&tag[0], "foot-os");
1.83 schwarze 378: PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
379: print_otag(h, TAG_TD, 2, tag);
1.55 kristaps 380:
1.89 schwarze 381: if (man->source)
382: print_text(h, man->source);
1.4 kristaps 383: print_tagq(h, t);
384: }
385:
386:
387: /* ARGSUSED */
388: static int
389: man_br_pre(MAN_ARGS)
390: {
1.7 kristaps 391: struct roffsu su;
392: struct htmlpair tag;
1.4 kristaps 393:
1.7 kristaps 394: SCALE_VS_INIT(&su, 1);
395:
1.49 kristaps 396: if (MAN_sp == n->tok) {
1.75 kristaps 397: if (NULL != (n = n->child))
398: if ( ! a2roffsu(n->string, &su, SCALE_VS))
399: SCALE_VS_INIT(&su, atoi(n->string));
1.49 kristaps 400: } else
1.7 kristaps 401: su.scale = 0;
1.4 kristaps 402:
1.72 kristaps 403: bufinit(h);
1.7 kristaps 404: bufcat_su(h, "height", &su);
405: PAIR_STYLE_INIT(&tag, h);
1.4 kristaps 406: print_otag(h, TAG_DIV, 1, &tag);
1.24 kristaps 407:
1.16 kristaps 408: /* So the div isn't empty: */
409: print_text(h, "\\~");
410:
1.7 kristaps 411: return(0);
1.4 kristaps 412: }
413:
414: /* ARGSUSED */
415: static int
416: man_SH_pre(MAN_ARGS)
417: {
1.54 kristaps 418: struct htmlpair tag;
1.4 kristaps 419:
1.54 kristaps 420: if (MAN_BLOCK == n->type) {
1.76 kristaps 421: mh->fl &= ~MANH_LITERAL;
1.54 kristaps 422: PAIR_CLASS_INIT(&tag, "section");
423: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 424: return(1);
1.54 kristaps 425: } else if (MAN_BODY == n->type)
1.4 kristaps 426: return(1);
427:
1.54 kristaps 428: print_otag(h, TAG_H1, 0, NULL);
1.4 kristaps 429: return(1);
430: }
431:
432: /* ARGSUSED */
433: static int
1.8 kristaps 434: man_alt_pre(MAN_ARGS)
435: {
436: const struct man_node *nn;
1.78 kristaps 437: int i, savelit;
1.57 kristaps 438: enum htmltag fp;
439: struct tag *t;
1.8 kristaps 440:
1.78 kristaps 441: if ((savelit = mh->fl & MANH_LITERAL))
442: print_otag(h, TAG_BR, 0, NULL);
443:
444: mh->fl &= ~MANH_LITERAL;
445:
1.8 kristaps 446: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.57 kristaps 447: t = NULL;
1.8 kristaps 448: switch (n->tok) {
449: case (MAN_BI):
1.57 kristaps 450: fp = i % 2 ? TAG_I : TAG_B;
1.8 kristaps 451: break;
452: case (MAN_IB):
1.57 kristaps 453: fp = i % 2 ? TAG_B : TAG_I;
1.8 kristaps 454: break;
455: case (MAN_RI):
1.57 kristaps 456: fp = i % 2 ? TAG_I : TAG_MAX;
1.8 kristaps 457: break;
458: case (MAN_IR):
1.57 kristaps 459: fp = i % 2 ? TAG_MAX : TAG_I;
1.8 kristaps 460: break;
461: case (MAN_BR):
1.57 kristaps 462: fp = i % 2 ? TAG_MAX : TAG_B;
1.8 kristaps 463: break;
464: case (MAN_RB):
1.57 kristaps 465: fp = i % 2 ? TAG_B : TAG_MAX;
1.8 kristaps 466: break;
467: default:
468: abort();
469: /* NOTREACHED */
470: }
471:
472: if (i)
473: h->flags |= HTML_NOSPACE;
474:
1.57 kristaps 475: if (TAG_MAX != fp)
476: t = print_otag(h, fp, 0, NULL);
477:
1.89 schwarze 478: print_man_node(man, nn, mh, h);
1.57 kristaps 479:
480: if (t)
481: print_tagq(h, t);
1.8 kristaps 482: }
483:
1.78 kristaps 484: if (savelit)
485: mh->fl |= MANH_LITERAL;
486:
1.8 kristaps 487: return(0);
488: }
489:
490: /* ARGSUSED */
491: static int
1.56 kristaps 492: man_SM_pre(MAN_ARGS)
1.8 kristaps 493: {
494:
1.57 kristaps 495: print_otag(h, TAG_SMALL, 0, NULL);
1.56 kristaps 496: if (MAN_SB == n->tok)
1.57 kristaps 497: print_otag(h, TAG_B, 0, NULL);
1.8 kristaps 498: return(1);
499: }
500:
501: /* ARGSUSED */
502: static int
1.4 kristaps 503: man_SS_pre(MAN_ARGS)
504: {
1.54 kristaps 505: struct htmlpair tag;
1.4 kristaps 506:
1.54 kristaps 507: if (MAN_BLOCK == n->type) {
1.76 kristaps 508: mh->fl &= ~MANH_LITERAL;
1.54 kristaps 509: PAIR_CLASS_INIT(&tag, "subsection");
510: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 511: return(1);
1.54 kristaps 512: } else if (MAN_BODY == n->type)
1.4 kristaps 513: return(1);
514:
1.54 kristaps 515: print_otag(h, TAG_H2, 0, NULL);
1.4 kristaps 516: return(1);
517: }
518:
519: /* ARGSUSED */
520: static int
521: man_PP_pre(MAN_ARGS)
522: {
523:
1.47 kristaps 524: if (MAN_HEAD == n->type)
525: return(0);
1.74 kristaps 526: else if (MAN_BLOCK == n->type)
527: print_bvspace(h, n);
1.47 kristaps 528:
1.5 kristaps 529: return(1);
530: }
531:
532: /* ARGSUSED */
533: static int
534: man_IP_pre(MAN_ARGS)
535: {
536: const struct man_node *nn;
537:
1.7 kristaps 538: if (MAN_BODY == n->type) {
1.77 kristaps 539: print_otag(h, TAG_DD, 0, NULL);
540: return(1);
541: } else if (MAN_HEAD != n->type) {
542: print_otag(h, TAG_DL, 0, NULL);
1.6 kristaps 543: return(1);
544: }
545:
1.78 kristaps 546: /* FIXME: width specification. */
547:
1.77 kristaps 548: print_otag(h, TAG_DT, 0, NULL);
1.6 kristaps 549:
1.59 schwarze 550: /* For IP, only print the first header element. */
1.7 kristaps 551:
1.59 schwarze 552: if (MAN_IP == n->tok && n->child)
1.89 schwarze 553: print_man_node(man, n->child, mh, h);
1.27 kristaps 554:
1.59 schwarze 555: /* For TP, only print next-line header elements. */
1.6 kristaps 556:
1.91 schwarze 557: if (MAN_TP == n->tok) {
558: nn = n->child;
559: while (NULL != nn && 0 == (MAN_LINE & nn->flags))
560: nn = nn->next;
561: while (NULL != nn) {
562: print_man_node(man, nn, mh, h);
563: nn = nn->next;
564: }
565: }
1.6 kristaps 566:
567: return(0);
568: }
569:
570: /* ARGSUSED */
571: static int
572: man_HP_pre(MAN_ARGS)
573: {
1.56 kristaps 574: struct htmlpair tag;
575: struct roffsu su;
576: const struct man_node *np;
1.6 kristaps 577:
1.77 kristaps 578: if (MAN_HEAD == n->type)
579: return(0);
580: else if (MAN_BLOCK != n->type)
581: return(1);
1.72 kristaps 582:
1.77 kristaps 583: np = n->head->child;
1.6 kristaps 584:
1.56 kristaps 585: if (NULL == np || ! a2width(np, &su))
586: SCALE_HS_INIT(&su, INDENT);
1.6 kristaps 587:
1.77 kristaps 588: bufinit(h);
1.5 kristaps 589:
1.77 kristaps 590: print_bvspace(h, n);
591: bufcat_su(h, "margin-left", &su);
1.56 kristaps 592: su.scale = -su.scale;
1.7 kristaps 593: bufcat_su(h, "text-indent", &su);
594: PAIR_STYLE_INIT(&tag, h);
1.77 kristaps 595: print_otag(h, TAG_P, 1, &tag);
1.4 kristaps 596: return(1);
597: }
1.86 kristaps 598:
599: /* ARGSUSED */
600: static int
601: man_OP_pre(MAN_ARGS)
602: {
603: struct tag *tt;
604: struct htmlpair tag;
605:
606: print_text(h, "[");
607: h->flags |= HTML_NOSPACE;
608: PAIR_CLASS_INIT(&tag, "opt");
609: tt = print_otag(h, TAG_SPAN, 1, &tag);
610:
611: if (NULL != (n = n->child)) {
612: print_otag(h, TAG_B, 0, NULL);
613: print_text(h, n->string);
614: }
615:
616: print_stagq(h, tt);
617:
618: if (NULL != n && NULL != n->next) {
619: print_otag(h, TAG_I, 0, NULL);
620: print_text(h, n->next->string);
621: }
622:
623: print_stagq(h, tt);
624: h->flags |= HTML_NOSPACE;
625: print_text(h, "]");
626: return(0);
627: }
628:
1.6 kristaps 629:
1.8 kristaps 630: /* ARGSUSED */
631: static int
632: man_B_pre(MAN_ARGS)
633: {
634:
1.57 kristaps 635: print_otag(h, TAG_B, 0, NULL);
1.8 kristaps 636: return(1);
637: }
638:
639: /* ARGSUSED */
640: static int
641: man_I_pre(MAN_ARGS)
642: {
1.23 kristaps 643:
1.57 kristaps 644: print_otag(h, TAG_I, 0, NULL);
1.8 kristaps 645: return(1);
1.45 kristaps 646: }
647:
648: /* ARGSUSED */
649: static int
650: man_literal_pre(MAN_ARGS)
651: {
652:
1.88 schwarze 653: if (MAN_fi == n->tok || MAN_EE == n->tok) {
1.45 kristaps 654: print_otag(h, TAG_BR, 0, NULL);
1.78 kristaps 655: mh->fl &= ~MANH_LITERAL;
656: } else
1.45 kristaps 657: mh->fl |= MANH_LITERAL;
658:
1.67 schwarze 659: return(0);
1.45 kristaps 660: }
661:
662: /* ARGSUSED */
663: static int
664: man_in_pre(MAN_ARGS)
665: {
666:
667: print_otag(h, TAG_BR, 0, NULL);
668: return(0);
1.8 kristaps 669: }
670:
671: /* ARGSUSED */
672: static int
673: man_ign_pre(MAN_ARGS)
674: {
675:
676: return(0);
677: }
1.9 kristaps 678:
679: /* ARGSUSED */
680: static int
681: man_RS_pre(MAN_ARGS)
682: {
683: struct htmlpair tag;
684: struct roffsu su;
685:
686: if (MAN_HEAD == n->type)
687: return(0);
688: else if (MAN_BODY == n->type)
689: return(1);
690:
691: SCALE_HS_INIT(&su, INDENT);
1.56 kristaps 692: if (n->head->child)
1.9 kristaps 693: a2width(n->head->child, &su);
694:
1.72 kristaps 695: bufinit(h);
1.56 kristaps 696: bufcat_su(h, "margin-left", &su);
1.9 kristaps 697: PAIR_STYLE_INIT(&tag, h);
698: print_otag(h, TAG_DIV, 1, &tag);
699: return(1);
1.90 schwarze 700: }
701:
702: /* ARGSUSED */
703: static int
704: man_UR_pre(MAN_ARGS)
705: {
706: struct htmlpair tag[2];
707:
708: n = n->child;
709: assert(MAN_HEAD == n->type);
710: if (n->nchild) {
711: assert(MAN_TEXT == n->child->type);
712: PAIR_CLASS_INIT(&tag[0], "link-ext");
713: PAIR_HREF_INIT(&tag[1], n->child->string);
714: print_otag(h, TAG_A, 2, tag);
715: }
716:
717: assert(MAN_BODY == n->next->type);
718: if (n->next->nchild)
719: n = n->next;
720:
721: print_man_nodelist(man, n->child, mh, h);
722:
723: return(0);
1.9 kristaps 724: }
CVSweb