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