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