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