Annotation of mandoc/man_html.c, Revision 1.57
1.57 ! kristaps 1: /* $Id: man_html.c,v 1.56 2010/12/22 09:51:27 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);
70: static int man_root_pre(MAN_ARGS);
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.3 kristaps 103: { NULL, 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;
183:
184: child = 1;
1.14 kristaps 185: t = h->tags.head;
1.4 kristaps 186:
187: bufinit(h);
188:
1.28 kristaps 189: /*
190: * FIXME: embedded elements within next-line scopes (e.g., `br'
191: * within an empty `B') will cause formatting to be forgotten
192: * due to scope closing out.
193: */
194:
1.4 kristaps 195: switch (n->type) {
196: case (MAN_ROOT):
1.45 kristaps 197: child = man_root_pre(m, n, mh, h);
1.4 kristaps 198: break;
199: case (MAN_TEXT):
200: print_text(h, n->string);
1.45 kristaps 201:
202: if (MANH_LITERAL & mh->fl)
203: print_otag(h, TAG_BR, 0, NULL);
204:
1.19 kristaps 205: return;
1.4 kristaps 206: default:
1.21 kristaps 207: /*
208: * Close out scope of font prior to opening a macro
209: * scope. Assert that the metafont is on the top of the
210: * stack (it's never nested).
211: */
1.57 ! kristaps 212: if (HTMLFONT_NONE != h->metac) {
! 213: h->metal = h->metac;
! 214: h->metac = HTMLFONT_NONE;
1.20 kristaps 215: }
1.4 kristaps 216: if (mans[n->tok].pre)
1.45 kristaps 217: child = (*mans[n->tok].pre)(m, n, mh, h);
1.4 kristaps 218: break;
219: }
220:
1.21 kristaps 221: if (child && n->child)
1.45 kristaps 222: print_man_nodelist(m, n->child, mh, h);
1.21 kristaps 223:
1.24 kristaps 224: /* This will automatically close out any font scope. */
1.4 kristaps 225: print_stagq(h, t);
226:
227: bufinit(h);
228:
229: switch (n->type) {
230: case (MAN_ROOT):
1.45 kristaps 231: man_root_post(m, n, mh, h);
1.4 kristaps 232: break;
233: case (MAN_TEXT):
234: break;
235: default:
236: if (mans[n->tok].post)
1.45 kristaps 237: (*mans[n->tok].post)(m, n, mh, h);
1.4 kristaps 238: break;
239: }
240: }
241:
242:
1.5 kristaps 243: static int
1.7 kristaps 244: a2width(const struct man_node *n, struct roffsu *su)
1.5 kristaps 245: {
246:
1.6 kristaps 247: if (MAN_TEXT != n->type)
1.7 kristaps 248: return(0);
1.11 kristaps 249: if (a2roffsu(n->string, su, SCALE_BU))
1.7 kristaps 250: return(1);
1.5 kristaps 251:
1.7 kristaps 252: return(0);
1.5 kristaps 253: }
254:
255:
1.40 kristaps 256: /* ARGSUSED */
1.4 kristaps 257: static int
258: man_root_pre(MAN_ARGS)
259: {
1.56 kristaps 260: struct htmlpair tag[3];
1.4 kristaps 261: struct tag *t, *tt;
262: char b[BUFSIZ], title[BUFSIZ];
263:
264: b[0] = 0;
265: if (m->vol)
266: (void)strlcat(b, m->vol, BUFSIZ);
267:
1.31 kristaps 268: snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec);
1.4 kristaps 269:
1.56 kristaps 270: PAIR_SUMMARY_INIT(&tag[0], "Document Header");
271: PAIR_CLASS_INIT(&tag[1], "head");
272: if (NULL == h->style) {
273: PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
274: t = print_otag(h, TAG_TABLE, 3, tag);
275: PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
276: print_otag(h, TAG_COL, 1, tag);
277: print_otag(h, TAG_COL, 1, tag);
278: print_otag(h, TAG_COL, 1, tag);
279: } else
280: t = print_otag(h, TAG_TABLE, 2, tag);
281:
282: print_otag(h, TAG_TBODY, 0, NULL);
1.15 kristaps 283:
1.4 kristaps 284: tt = print_otag(h, TAG_TR, 0, NULL);
285:
1.55 kristaps 286: PAIR_CLASS_INIT(&tag[0], "head-ltitle");
1.4 kristaps 287: print_otag(h, TAG_TD, 1, tag);
1.55 kristaps 288:
1.4 kristaps 289: print_text(h, title);
290: print_stagq(h, tt);
291:
1.55 kristaps 292: PAIR_CLASS_INIT(&tag[0], "head-vol");
1.56 kristaps 293: if (NULL == h->style) {
294: PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
295: print_otag(h, TAG_TD, 2, tag);
296: } else
297: print_otag(h, TAG_TD, 1, tag);
1.55 kristaps 298:
1.4 kristaps 299: print_text(h, b);
300: print_stagq(h, tt);
301:
1.55 kristaps 302: PAIR_CLASS_INIT(&tag[0], "head-rtitle");
1.56 kristaps 303: if (NULL == h->style) {
304: PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
305: print_otag(h, TAG_TD, 2, tag);
306: } else
307: print_otag(h, TAG_TD, 1, tag);
1.55 kristaps 308:
1.4 kristaps 309: print_text(h, title);
310: print_tagq(h, t);
311: return(1);
312: }
313:
314:
315: /* ARGSUSED */
316: static void
317: man_root_post(MAN_ARGS)
318: {
1.56 kristaps 319: struct htmlpair tag[3];
1.4 kristaps 320: struct tag *t, *tt;
1.12 kristaps 321: char b[DATESIZ];
1.4 kristaps 322:
1.36 kristaps 323: if (m->rawdate)
324: strlcpy(b, m->rawdate, DATESIZ);
325: else
326: time2a(m->date, b, DATESIZ);
1.4 kristaps 327:
1.56 kristaps 328: PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
329: PAIR_CLASS_INIT(&tag[1], "foot");
330: if (NULL == h->style) {
331: PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
332: t = print_otag(h, TAG_TABLE, 3, tag);
333: PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
334: print_otag(h, TAG_COL, 1, tag);
335: print_otag(h, TAG_COL, 1, tag);
336: } else
337: t = print_otag(h, TAG_TABLE, 2, tag);
1.15 kristaps 338:
1.4 kristaps 339: tt = print_otag(h, TAG_TR, 0, NULL);
340:
1.55 kristaps 341: PAIR_CLASS_INIT(&tag[0], "foot-date");
1.4 kristaps 342: print_otag(h, TAG_TD, 1, tag);
1.55 kristaps 343:
1.4 kristaps 344: print_text(h, b);
345: print_stagq(h, tt);
346:
1.55 kristaps 347: PAIR_CLASS_INIT(&tag[0], "foot-os");
1.56 kristaps 348: if (NULL == h->style) {
349: PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
350: print_otag(h, TAG_TD, 2, tag);
351: } else
352: print_otag(h, TAG_TD, 1, tag);
1.55 kristaps 353:
1.4 kristaps 354: if (m->source)
355: print_text(h, m->source);
356: print_tagq(h, t);
357: }
358:
359:
360:
361: /* ARGSUSED */
362: static int
363: man_br_pre(MAN_ARGS)
364: {
1.7 kristaps 365: struct roffsu su;
366: struct htmlpair tag;
1.4 kristaps 367:
1.7 kristaps 368: SCALE_VS_INIT(&su, 1);
369:
1.49 kristaps 370: if (MAN_sp == n->tok) {
1.29 kristaps 371: if (n->child)
372: a2roffsu(n->child->string, &su, SCALE_VS);
1.49 kristaps 373: } else
1.7 kristaps 374: su.scale = 0;
1.4 kristaps 375:
1.7 kristaps 376: bufcat_su(h, "height", &su);
377: PAIR_STYLE_INIT(&tag, h);
1.4 kristaps 378: print_otag(h, TAG_DIV, 1, &tag);
1.24 kristaps 379:
1.16 kristaps 380: /* So the div isn't empty: */
381: print_text(h, "\\~");
382:
1.7 kristaps 383: return(0);
1.4 kristaps 384: }
385:
386:
387: /* ARGSUSED */
388: static int
389: man_SH_pre(MAN_ARGS)
390: {
1.54 kristaps 391: struct htmlpair tag;
1.4 kristaps 392:
1.54 kristaps 393: if (MAN_BLOCK == n->type) {
394: PAIR_CLASS_INIT(&tag, "section");
395: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 396: return(1);
1.54 kristaps 397: } else if (MAN_BODY == n->type)
1.4 kristaps 398: return(1);
399:
1.54 kristaps 400: print_otag(h, TAG_H1, 0, NULL);
1.4 kristaps 401: return(1);
402: }
403:
404:
405: /* ARGSUSED */
406: static int
1.8 kristaps 407: man_alt_pre(MAN_ARGS)
408: {
409: const struct man_node *nn;
1.57 ! kristaps 410: int i;
! 411: enum htmltag fp;
! 412: struct tag *t;
1.8 kristaps 413:
414: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.57 ! kristaps 415: t = NULL;
1.8 kristaps 416: switch (n->tok) {
417: case (MAN_BI):
1.57 ! kristaps 418: fp = i % 2 ? TAG_I : TAG_B;
1.8 kristaps 419: break;
420: case (MAN_IB):
1.57 ! kristaps 421: fp = i % 2 ? TAG_B : TAG_I;
1.8 kristaps 422: break;
423: case (MAN_RI):
1.57 ! kristaps 424: fp = i % 2 ? TAG_I : TAG_MAX;
1.8 kristaps 425: break;
426: case (MAN_IR):
1.57 ! kristaps 427: fp = i % 2 ? TAG_MAX : TAG_I;
1.8 kristaps 428: break;
429: case (MAN_BR):
1.57 ! kristaps 430: fp = i % 2 ? TAG_MAX : TAG_B;
1.8 kristaps 431: break;
432: case (MAN_RB):
1.57 ! kristaps 433: fp = i % 2 ? TAG_B : TAG_MAX;
1.8 kristaps 434: break;
435: default:
436: abort();
437: /* NOTREACHED */
438: }
439:
440: if (i)
441: h->flags |= HTML_NOSPACE;
442:
1.57 ! kristaps 443: if (TAG_MAX != fp)
! 444: t = print_otag(h, fp, 0, NULL);
! 445:
1.45 kristaps 446: print_man_node(m, nn, mh, h);
1.57 ! kristaps 447:
! 448: if (t)
! 449: print_tagq(h, t);
1.8 kristaps 450: }
451:
452: return(0);
453: }
454:
455:
456: /* ARGSUSED */
457: static int
1.56 kristaps 458: man_SM_pre(MAN_ARGS)
1.8 kristaps 459: {
460:
1.57 ! kristaps 461: print_otag(h, TAG_SMALL, 0, NULL);
1.56 kristaps 462: if (MAN_SB == n->tok)
1.57 ! kristaps 463: print_otag(h, TAG_B, 0, NULL);
1.8 kristaps 464: return(1);
465: }
466:
467:
468: /* ARGSUSED */
469: static int
1.4 kristaps 470: man_SS_pre(MAN_ARGS)
471: {
1.54 kristaps 472: struct htmlpair tag;
1.4 kristaps 473:
1.54 kristaps 474: if (MAN_BLOCK == n->type) {
475: PAIR_CLASS_INIT(&tag, "subsection");
476: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 477: return(1);
1.54 kristaps 478: } else if (MAN_BODY == n->type)
1.4 kristaps 479: return(1);
480:
1.54 kristaps 481: print_otag(h, TAG_H2, 0, NULL);
1.4 kristaps 482: return(1);
483: }
484:
485:
486: /* ARGSUSED */
487: static int
488: man_PP_pre(MAN_ARGS)
489: {
490:
1.47 kristaps 491: if (MAN_HEAD == n->type)
492: return(0);
1.56 kristaps 493: else if (MAN_BODY == n->type && n->prev)
494: print_otag(h, TAG_P, 0, NULL);
1.47 kristaps 495:
1.5 kristaps 496: return(1);
497: }
498:
499:
500: /* ARGSUSED */
501: static int
502: man_IP_pre(MAN_ARGS)
503: {
1.7 kristaps 504: struct roffsu su;
1.5 kristaps 505: struct htmlpair tag;
506: const struct man_node *nn;
1.7 kristaps 507: int width;
1.5 kristaps 508:
1.7 kristaps 509: /*
510: * This scattering of 1-BU margins and pads is to make sure that
511: * when text overruns its box, the subsequent text isn't flush
512: * up against it. However, the rest of the right-hand box must
513: * also be adjusted in consideration of this 1-BU space.
514: */
515:
516: if (MAN_BODY == n->type) {
1.56 kristaps 517: print_otag(h, TAG_TD, 0, NULL);
1.6 kristaps 518: return(1);
519: }
520:
521: nn = MAN_BLOCK == n->type ?
522: n->head->child : n->parent->head->child;
523:
1.7 kristaps 524: SCALE_HS_INIT(&su, INDENT);
525: width = 0;
1.6 kristaps 526:
1.28 kristaps 527: /* Width is the last token. */
528:
1.7 kristaps 529: if (MAN_IP == n->tok && NULL != nn)
1.5 kristaps 530: if (NULL != (nn = nn->next)) {
531: for ( ; nn->next; nn = nn->next)
532: /* Do nothing. */ ;
1.7 kristaps 533: width = a2width(nn, &su);
1.5 kristaps 534: }
535:
1.28 kristaps 536: /* Width is the first token. */
537:
1.27 kristaps 538: if (MAN_TP == n->tok && NULL != nn) {
1.28 kristaps 539: /* Skip past non-text children. */
1.27 kristaps 540: while (nn && MAN_TEXT != nn->type)
541: nn = nn->next;
1.28 kristaps 542: if (nn)
543: width = a2width(nn, &su);
1.27 kristaps 544: }
1.7 kristaps 545:
1.5 kristaps 546: if (MAN_BLOCK == n->type) {
1.56 kristaps 547: print_otag(h, TAG_P, 0, NULL);
548: print_otag(h, TAG_TABLE, 0, NULL);
549: bufcat_su(h, "width", &su);
1.7 kristaps 550: PAIR_STYLE_INIT(&tag, h);
1.56 kristaps 551: print_otag(h, TAG_COL, 1, &tag);
552: print_otag(h, TAG_COL, 0, NULL);
553: print_otag(h, TAG_TBODY, 0, NULL);
554: print_otag(h, TAG_TR, 0, NULL);
1.5 kristaps 555: return(1);
1.6 kristaps 556: }
557:
1.56 kristaps 558: print_otag(h, TAG_TD, 0, NULL);
1.6 kristaps 559:
1.28 kristaps 560: /*
561: * Without a length string, we can print all of our children.
562: */
1.7 kristaps 563:
564: if ( ! width)
1.6 kristaps 565: return(1);
1.27 kristaps 566:
1.28 kristaps 567: /*
568: * When a length has been specified, we need to carefully print
569: * our child context: IP gets all children printed but the last
570: * (the width), while TP gets all children printed but the first
571: * (the width).
572: */
1.6 kristaps 573:
1.7 kristaps 574: if (MAN_IP == n->tok)
575: for (nn = n->child; nn->next; nn = nn->next)
1.45 kristaps 576: print_man_node(m, nn, mh, h);
1.7 kristaps 577: if (MAN_TP == n->tok)
578: for (nn = n->child->next; nn; nn = nn->next)
1.45 kristaps 579: print_man_node(m, nn, mh, h);
1.6 kristaps 580:
581: return(0);
582: }
583:
584:
585: /* ARGSUSED */
586: static int
587: man_HP_pre(MAN_ARGS)
588: {
1.56 kristaps 589: struct htmlpair tag;
590: struct roffsu su;
591: const struct man_node *np;
1.6 kristaps 592:
1.56 kristaps 593: np = MAN_BLOCK == n->type ?
594: n->head->child :
595: n->parent->head->child;
1.6 kristaps 596:
1.56 kristaps 597: if (NULL == np || ! a2width(np, &su))
598: SCALE_HS_INIT(&su, INDENT);
1.6 kristaps 599:
1.56 kristaps 600: if (MAN_HEAD == n->type) {
601: print_otag(h, TAG_TD, 0, NULL);
602: return(0);
603: } else if (MAN_BLOCK == n->type) {
604: print_otag(h, TAG_P, 0, NULL);
605: print_otag(h, TAG_TABLE, 0, NULL);
606: bufcat_su(h, "width", &su);
1.7 kristaps 607: PAIR_STYLE_INIT(&tag, h);
1.56 kristaps 608: print_otag(h, TAG_COL, 1, &tag);
609: print_otag(h, TAG_COL, 0, NULL);
610: print_otag(h, TAG_TBODY, 0, NULL);
611: print_otag(h, TAG_TR, 0, NULL);
1.6 kristaps 612: return(1);
613: }
1.5 kristaps 614:
1.56 kristaps 615: su.scale = -su.scale;
1.7 kristaps 616: bufcat_su(h, "text-indent", &su);
617: PAIR_STYLE_INIT(&tag, h);
1.56 kristaps 618: print_otag(h, TAG_TD, 1, &tag);
1.4 kristaps 619: return(1);
620: }
1.6 kristaps 621:
1.8 kristaps 622:
623: /* ARGSUSED */
624: static int
625: man_B_pre(MAN_ARGS)
626: {
627:
1.57 ! kristaps 628: print_otag(h, TAG_B, 0, NULL);
1.8 kristaps 629: return(1);
630: }
631:
632:
633: /* ARGSUSED */
634: static int
635: man_I_pre(MAN_ARGS)
636: {
1.23 kristaps 637:
1.57 ! kristaps 638: print_otag(h, TAG_I, 0, NULL);
1.8 kristaps 639: return(1);
1.45 kristaps 640: }
641:
642:
643: /* ARGSUSED */
644: static int
645: man_literal_pre(MAN_ARGS)
646: {
647:
1.48 kristaps 648: if (MAN_nf == n->tok) {
1.45 kristaps 649: print_otag(h, TAG_BR, 0, NULL);
650: mh->fl |= MANH_LITERAL;
1.48 kristaps 651: } else
1.45 kristaps 652: mh->fl &= ~MANH_LITERAL;
653:
654: return(1);
655: }
656:
657:
658: /* ARGSUSED */
659: static int
660: man_in_pre(MAN_ARGS)
661: {
662:
663: print_otag(h, TAG_BR, 0, NULL);
664: return(0);
1.8 kristaps 665: }
666:
667:
668: /* ARGSUSED */
669: static int
670: man_ign_pre(MAN_ARGS)
671: {
672:
673: return(0);
674: }
1.9 kristaps 675:
676:
677: /* ARGSUSED */
678: static int
679: man_RS_pre(MAN_ARGS)
680: {
681: struct htmlpair tag;
682: struct roffsu su;
683:
684: if (MAN_HEAD == n->type)
685: return(0);
686: else if (MAN_BODY == n->type)
687: return(1);
688:
689: SCALE_HS_INIT(&su, INDENT);
1.56 kristaps 690: if (n->head->child)
1.9 kristaps 691: a2width(n->head->child, &su);
692:
1.56 kristaps 693: bufcat_su(h, "margin-left", &su);
1.9 kristaps 694: PAIR_STYLE_INIT(&tag, h);
695: print_otag(h, TAG_DIV, 1, &tag);
696: return(1);
697: }
CVSweb