Annotation of mandoc/man_html.c, Revision 1.85
1.85 ! schwarze 1: /* $Id: man_html.c,v 1.84 2011/11/18 17:05:50 joerg 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:
1.3 kristaps 40: #define MAN_ARGS const struct man_meta *m, \
41: const struct man_node *n, \
1.45 kristaps 42: struct mhtml *mh, \
1.3 kristaps 43: struct html *h
44:
1.45 kristaps 45: struct mhtml {
46: int fl;
47: #define MANH_LITERAL (1 << 0) /* literal context */
48: };
49:
1.3 kristaps 50: struct htmlman {
51: int (*pre)(MAN_ARGS);
52: int (*post)(MAN_ARGS);
53: };
54:
1.74 kristaps 55: static void print_bvspace(struct html *,
56: const struct man_node *);
1.3 kristaps 57: static void print_man(MAN_ARGS);
58: static void print_man_head(MAN_ARGS);
1.4 kristaps 59: static void print_man_nodelist(MAN_ARGS);
60: static void print_man_node(MAN_ARGS);
1.3 kristaps 61:
1.7 kristaps 62: static int a2width(const struct man_node *,
63: struct roffsu *);
1.5 kristaps 64:
1.8 kristaps 65: static int man_alt_pre(MAN_ARGS);
1.4 kristaps 66: static int man_br_pre(MAN_ARGS);
1.8 kristaps 67: static int man_ign_pre(MAN_ARGS);
1.45 kristaps 68: static int man_in_pre(MAN_ARGS);
69: static int man_literal_pre(MAN_ARGS);
1.8 kristaps 70: static void man_root_post(MAN_ARGS);
1.65 kristaps 71: static void man_root_pre(MAN_ARGS);
1.8 kristaps 72: static int man_B_pre(MAN_ARGS);
1.6 kristaps 73: static int man_HP_pre(MAN_ARGS);
1.8 kristaps 74: static int man_I_pre(MAN_ARGS);
1.5 kristaps 75: static int man_IP_pre(MAN_ARGS);
1.4 kristaps 76: static int man_PP_pre(MAN_ARGS);
1.9 kristaps 77: static int man_RS_pre(MAN_ARGS);
1.4 kristaps 78: static int man_SH_pre(MAN_ARGS);
1.8 kristaps 79: static int man_SM_pre(MAN_ARGS);
1.4 kristaps 80: static int man_SS_pre(MAN_ARGS);
81:
1.3 kristaps 82: static const struct htmlman mans[MAN_MAX] = {
1.4 kristaps 83: { man_br_pre, NULL }, /* br */
1.3 kristaps 84: { NULL, NULL }, /* TH */
1.4 kristaps 85: { man_SH_pre, NULL }, /* SH */
86: { man_SS_pre, NULL }, /* SS */
1.6 kristaps 87: { man_IP_pre, NULL }, /* TP */
1.4 kristaps 88: { man_PP_pre, NULL }, /* LP */
89: { man_PP_pre, NULL }, /* PP */
90: { man_PP_pre, NULL }, /* P */
1.5 kristaps 91: { man_IP_pre, NULL }, /* IP */
1.6 kristaps 92: { man_HP_pre, NULL }, /* HP */
1.8 kristaps 93: { man_SM_pre, NULL }, /* SM */
1.56 kristaps 94: { man_SM_pre, NULL }, /* SB */
1.8 kristaps 95: { man_alt_pre, NULL }, /* BI */
96: { man_alt_pre, NULL }, /* IB */
97: { man_alt_pre, NULL }, /* BR */
98: { man_alt_pre, NULL }, /* RB */
1.3 kristaps 99: { NULL, NULL }, /* R */
1.8 kristaps 100: { man_B_pre, NULL }, /* B */
101: { man_I_pre, NULL }, /* I */
102: { man_alt_pre, NULL }, /* IR */
103: { man_alt_pre, NULL }, /* RI */
1.67 schwarze 104: { man_ign_pre, NULL }, /* na */
1.4 kristaps 105: { man_br_pre, NULL }, /* sp */
1.45 kristaps 106: { man_literal_pre, NULL }, /* nf */
107: { man_literal_pre, NULL }, /* fi */
1.3 kristaps 108: { NULL, NULL }, /* RE */
1.9 kristaps 109: { man_RS_pre, NULL }, /* RS */
1.8 kristaps 110: { man_ign_pre, NULL }, /* DT */
111: { man_ign_pre, NULL }, /* UC */
1.13 kristaps 112: { man_ign_pre, NULL }, /* PD */
1.34 joerg 113: { man_ign_pre, NULL }, /* AT */
1.45 kristaps 114: { man_in_pre, NULL }, /* in */
1.51 kristaps 115: { man_ign_pre, NULL }, /* ft */
1.3 kristaps 116: };
117:
1.74 kristaps 118: /*
119: * Printing leading vertical space before a block.
120: * This is used for the paragraph macros.
121: * The rules are pretty simple, since there's very little nesting going
122: * on here. Basically, if we're the first within another block (SS/SH),
123: * then don't emit vertical space. If we are (RS), then do. If not the
124: * first, print it.
125: */
126: static void
127: print_bvspace(struct html *h, const struct man_node *n)
128: {
129:
130: if (n->body && n->body->child)
131: if (MAN_TBL == n->body->child->type)
132: return;
133:
134: if (MAN_ROOT == n->parent->type || MAN_RS != n->parent->tok)
135: if (NULL == n->prev)
136: return;
137:
138: print_otag(h, TAG_P, 0, NULL);
139: }
1.1 kristaps 140:
141: void
142: html_man(void *arg, const struct man *m)
143: {
1.45 kristaps 144: struct mhtml mh;
1.3 kristaps 145:
1.45 kristaps 146: memset(&mh, 0, sizeof(struct mhtml));
1.82 kristaps 147: print_man(man_meta(m), man_node(m), &mh, (struct html *)arg);
148: putchar('\n');
1.3 kristaps 149: }
150:
151: static void
152: print_man(MAN_ARGS)
153: {
1.82 kristaps 154: struct tag *t, *tt;
155: struct htmlpair tag;
156:
157: PAIR_CLASS_INIT(&tag, "mandoc");
1.3 kristaps 158:
1.82 kristaps 159: if ( ! (HTML_FRAGMENT & h->oflags)) {
160: print_gen_decls(h);
161: t = print_otag(h, TAG_HTML, 0, NULL);
162: tt = print_otag(h, TAG_HEAD, 0, NULL);
163: print_man_head(m, n, mh, h);
164: print_tagq(h, tt);
165: print_otag(h, TAG_BODY, 0, NULL);
166: print_otag(h, TAG_DIV, 1, &tag);
167: } else
168: t = print_otag(h, TAG_DIV, 1, &tag);
1.53 kristaps 169:
1.45 kristaps 170: print_man_nodelist(m, n, mh, h);
1.3 kristaps 171: print_tagq(h, t);
172: }
173:
174:
175: /* ARGSUSED */
176: static void
177: print_man_head(MAN_ARGS)
178: {
179:
180: print_gen_head(h);
1.85 ! schwarze 181: assert(m->title);
! 182: assert(m->msec);
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.85 ! schwarze 310: assert(m->title);
! 311: assert(m->msec);
! 312: snprintf(title, BUFSIZ - 1, "%s(%s)", m->title, m->msec);
1.4 kristaps 313:
1.56 kristaps 314: PAIR_SUMMARY_INIT(&tag[0], "Document Header");
315: PAIR_CLASS_INIT(&tag[1], "head");
1.83 schwarze 316: PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
317: t = print_otag(h, TAG_TABLE, 3, tag);
318: PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
319: print_otag(h, TAG_COL, 1, tag);
320: print_otag(h, TAG_COL, 1, tag);
321: print_otag(h, TAG_COL, 1, tag);
1.56 kristaps 322:
323: print_otag(h, TAG_TBODY, 0, NULL);
1.15 kristaps 324:
1.4 kristaps 325: tt = print_otag(h, TAG_TR, 0, NULL);
326:
1.55 kristaps 327: PAIR_CLASS_INIT(&tag[0], "head-ltitle");
1.4 kristaps 328: print_otag(h, TAG_TD, 1, tag);
329: print_text(h, title);
330: print_stagq(h, tt);
331:
1.55 kristaps 332: PAIR_CLASS_INIT(&tag[0], "head-vol");
1.83 schwarze 333: PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
334: print_otag(h, TAG_TD, 2, tag);
1.4 kristaps 335: print_text(h, b);
336: print_stagq(h, tt);
337:
1.55 kristaps 338: PAIR_CLASS_INIT(&tag[0], "head-rtitle");
1.83 schwarze 339: PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
340: print_otag(h, TAG_TD, 2, tag);
1.4 kristaps 341: print_text(h, title);
342: print_tagq(h, t);
343: }
344:
345:
346: /* ARGSUSED */
347: static void
348: man_root_post(MAN_ARGS)
349: {
1.56 kristaps 350: struct htmlpair tag[3];
1.4 kristaps 351: struct tag *t, *tt;
352:
1.56 kristaps 353: PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
354: PAIR_CLASS_INIT(&tag[1], "foot");
1.83 schwarze 355: PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
356: t = print_otag(h, TAG_TABLE, 3, tag);
357: PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
358: print_otag(h, TAG_COL, 1, tag);
359: print_otag(h, TAG_COL, 1, 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.85 ! schwarze 366: assert(m->date);
! 367: print_text(h, m->date);
1.4 kristaps 368: print_stagq(h, tt);
369:
1.55 kristaps 370: PAIR_CLASS_INIT(&tag[0], "foot-os");
1.83 schwarze 371: PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
372: print_otag(h, TAG_TD, 2, tag);
1.55 kristaps 373:
1.4 kristaps 374: if (m->source)
375: print_text(h, m->source);
376: print_tagq(h, t);
377: }
378:
379:
380: /* ARGSUSED */
381: static int
382: man_br_pre(MAN_ARGS)
383: {
1.7 kristaps 384: struct roffsu su;
385: struct htmlpair tag;
1.4 kristaps 386:
1.7 kristaps 387: SCALE_VS_INIT(&su, 1);
388:
1.49 kristaps 389: if (MAN_sp == n->tok) {
1.75 kristaps 390: if (NULL != (n = n->child))
391: if ( ! a2roffsu(n->string, &su, SCALE_VS))
392: SCALE_VS_INIT(&su, atoi(n->string));
1.49 kristaps 393: } else
1.7 kristaps 394: su.scale = 0;
1.4 kristaps 395:
1.72 kristaps 396: bufinit(h);
1.7 kristaps 397: bufcat_su(h, "height", &su);
398: PAIR_STYLE_INIT(&tag, h);
1.4 kristaps 399: print_otag(h, TAG_DIV, 1, &tag);
1.24 kristaps 400:
1.16 kristaps 401: /* So the div isn't empty: */
402: print_text(h, "\\~");
403:
1.7 kristaps 404: return(0);
1.4 kristaps 405: }
406:
407: /* ARGSUSED */
408: static int
409: man_SH_pre(MAN_ARGS)
410: {
1.54 kristaps 411: struct htmlpair tag;
1.4 kristaps 412:
1.54 kristaps 413: if (MAN_BLOCK == n->type) {
1.76 kristaps 414: mh->fl &= ~MANH_LITERAL;
1.54 kristaps 415: PAIR_CLASS_INIT(&tag, "section");
416: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 417: return(1);
1.54 kristaps 418: } else if (MAN_BODY == n->type)
1.4 kristaps 419: return(1);
420:
1.54 kristaps 421: print_otag(h, TAG_H1, 0, NULL);
1.4 kristaps 422: return(1);
423: }
424:
425: /* ARGSUSED */
426: static int
1.8 kristaps 427: man_alt_pre(MAN_ARGS)
428: {
429: const struct man_node *nn;
1.78 kristaps 430: int i, savelit;
1.57 kristaps 431: enum htmltag fp;
432: struct tag *t;
1.8 kristaps 433:
1.78 kristaps 434: if ((savelit = mh->fl & MANH_LITERAL))
435: print_otag(h, TAG_BR, 0, NULL);
436:
437: mh->fl &= ~MANH_LITERAL;
438:
1.8 kristaps 439: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.57 kristaps 440: t = NULL;
1.8 kristaps 441: switch (n->tok) {
442: case (MAN_BI):
1.57 kristaps 443: fp = i % 2 ? TAG_I : TAG_B;
1.8 kristaps 444: break;
445: case (MAN_IB):
1.57 kristaps 446: fp = i % 2 ? TAG_B : TAG_I;
1.8 kristaps 447: break;
448: case (MAN_RI):
1.57 kristaps 449: fp = i % 2 ? TAG_I : TAG_MAX;
1.8 kristaps 450: break;
451: case (MAN_IR):
1.57 kristaps 452: fp = i % 2 ? TAG_MAX : TAG_I;
1.8 kristaps 453: break;
454: case (MAN_BR):
1.57 kristaps 455: fp = i % 2 ? TAG_MAX : TAG_B;
1.8 kristaps 456: break;
457: case (MAN_RB):
1.57 kristaps 458: fp = i % 2 ? TAG_B : TAG_MAX;
1.8 kristaps 459: break;
460: default:
461: abort();
462: /* NOTREACHED */
463: }
464:
465: if (i)
466: h->flags |= HTML_NOSPACE;
467:
1.57 kristaps 468: if (TAG_MAX != fp)
469: t = print_otag(h, fp, 0, NULL);
470:
1.45 kristaps 471: print_man_node(m, nn, mh, h);
1.57 kristaps 472:
473: if (t)
474: print_tagq(h, t);
1.8 kristaps 475: }
476:
1.78 kristaps 477: if (savelit)
478: mh->fl |= MANH_LITERAL;
479:
1.8 kristaps 480: return(0);
481: }
482:
483: /* ARGSUSED */
484: static int
1.56 kristaps 485: man_SM_pre(MAN_ARGS)
1.8 kristaps 486: {
487:
1.57 kristaps 488: print_otag(h, TAG_SMALL, 0, NULL);
1.56 kristaps 489: if (MAN_SB == n->tok)
1.57 kristaps 490: print_otag(h, TAG_B, 0, NULL);
1.8 kristaps 491: return(1);
492: }
493:
494: /* ARGSUSED */
495: static int
1.4 kristaps 496: man_SS_pre(MAN_ARGS)
497: {
1.54 kristaps 498: struct htmlpair tag;
1.4 kristaps 499:
1.54 kristaps 500: if (MAN_BLOCK == n->type) {
1.76 kristaps 501: mh->fl &= ~MANH_LITERAL;
1.54 kristaps 502: PAIR_CLASS_INIT(&tag, "subsection");
503: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 504: return(1);
1.54 kristaps 505: } else if (MAN_BODY == n->type)
1.4 kristaps 506: return(1);
507:
1.54 kristaps 508: print_otag(h, TAG_H2, 0, NULL);
1.4 kristaps 509: return(1);
510: }
511:
512: /* ARGSUSED */
513: static int
514: man_PP_pre(MAN_ARGS)
515: {
516:
1.47 kristaps 517: if (MAN_HEAD == n->type)
518: return(0);
1.74 kristaps 519: else if (MAN_BLOCK == n->type)
520: print_bvspace(h, n);
1.47 kristaps 521:
1.5 kristaps 522: return(1);
523: }
524:
525: /* ARGSUSED */
526: static int
527: man_IP_pre(MAN_ARGS)
528: {
529: const struct man_node *nn;
530:
1.7 kristaps 531: if (MAN_BODY == n->type) {
1.77 kristaps 532: print_otag(h, TAG_DD, 0, NULL);
533: return(1);
534: } else if (MAN_HEAD != n->type) {
535: print_otag(h, TAG_DL, 0, NULL);
1.6 kristaps 536: return(1);
537: }
538:
1.78 kristaps 539: /* FIXME: width specification. */
540:
1.77 kristaps 541: print_otag(h, TAG_DT, 0, NULL);
1.6 kristaps 542:
1.59 schwarze 543: /* For IP, only print the first header element. */
1.7 kristaps 544:
1.59 schwarze 545: if (MAN_IP == n->tok && n->child)
546: print_man_node(m, n->child, mh, h);
1.27 kristaps 547:
1.59 schwarze 548: /* For TP, only print next-line header elements. */
1.6 kristaps 549:
1.7 kristaps 550: if (MAN_TP == n->tok)
1.59 schwarze 551: for (nn = n->child; nn; nn = nn->next)
552: if (nn->line > n->line)
553: print_man_node(m, nn, mh, h);
1.6 kristaps 554:
555: return(0);
556: }
557:
558: /* ARGSUSED */
559: static int
560: man_HP_pre(MAN_ARGS)
561: {
1.56 kristaps 562: struct htmlpair tag;
563: struct roffsu su;
564: const struct man_node *np;
1.6 kristaps 565:
1.77 kristaps 566: if (MAN_HEAD == n->type)
567: return(0);
568: else if (MAN_BLOCK != n->type)
569: return(1);
1.72 kristaps 570:
1.77 kristaps 571: np = n->head->child;
1.6 kristaps 572:
1.56 kristaps 573: if (NULL == np || ! a2width(np, &su))
574: SCALE_HS_INIT(&su, INDENT);
1.6 kristaps 575:
1.77 kristaps 576: bufinit(h);
1.5 kristaps 577:
1.77 kristaps 578: print_bvspace(h, n);
579: bufcat_su(h, "margin-left", &su);
1.56 kristaps 580: su.scale = -su.scale;
1.7 kristaps 581: bufcat_su(h, "text-indent", &su);
582: PAIR_STYLE_INIT(&tag, h);
1.77 kristaps 583: print_otag(h, TAG_P, 1, &tag);
1.4 kristaps 584: return(1);
585: }
1.6 kristaps 586:
1.8 kristaps 587: /* ARGSUSED */
588: static int
589: man_B_pre(MAN_ARGS)
590: {
591:
1.57 kristaps 592: print_otag(h, TAG_B, 0, NULL);
1.8 kristaps 593: return(1);
594: }
595:
596: /* ARGSUSED */
597: static int
598: man_I_pre(MAN_ARGS)
599: {
1.23 kristaps 600:
1.57 kristaps 601: print_otag(h, TAG_I, 0, NULL);
1.8 kristaps 602: return(1);
1.45 kristaps 603: }
604:
605: /* ARGSUSED */
606: static int
607: man_literal_pre(MAN_ARGS)
608: {
609:
1.78 kristaps 610: if (MAN_nf != n->tok) {
1.45 kristaps 611: print_otag(h, TAG_BR, 0, NULL);
1.78 kristaps 612: mh->fl &= ~MANH_LITERAL;
613: } else
1.45 kristaps 614: mh->fl |= MANH_LITERAL;
615:
1.67 schwarze 616: return(0);
1.45 kristaps 617: }
618:
619: /* ARGSUSED */
620: static int
621: man_in_pre(MAN_ARGS)
622: {
623:
624: print_otag(h, TAG_BR, 0, NULL);
625: return(0);
1.8 kristaps 626: }
627:
628: /* ARGSUSED */
629: static int
630: man_ign_pre(MAN_ARGS)
631: {
632:
633: return(0);
634: }
1.9 kristaps 635:
636: /* ARGSUSED */
637: static int
638: man_RS_pre(MAN_ARGS)
639: {
640: struct htmlpair tag;
641: struct roffsu su;
642:
643: if (MAN_HEAD == n->type)
644: return(0);
645: else if (MAN_BODY == n->type)
646: return(1);
647:
648: SCALE_HS_INIT(&su, INDENT);
1.56 kristaps 649: if (n->head->child)
1.9 kristaps 650: a2width(n->head->child, &su);
651:
1.72 kristaps 652: bufinit(h);
1.56 kristaps 653: bufcat_su(h, "margin-left", &su);
1.9 kristaps 654: PAIR_STYLE_INIT(&tag, h);
655: print_otag(h, TAG_DIV, 1, &tag);
656: return(1);
657: }
CVSweb