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