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