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