Annotation of src/usr.bin/mandoc/man_html.c, Revision 1.51
1.51 ! schwarze 1: /* $Id: man_html.c,v 1.50 2014/03/08 15:50:21 schwarze Exp $ */
1.1 schwarze 2: /*
1.49 schwarze 3: * Copyright (c) 2008-2012 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.14 schwarze 26: #include "mandoc.h"
1.1 schwarze 27: #include "out.h"
28: #include "html.h"
29: #include "man.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.39 schwarze 52: static void print_bvspace(struct html *,
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 */
89: { man_HP_pre, NULL }, /* HP */
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.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:
141: print_otag(h, TAG_P, 0, NULL);
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
155: print_man(MAN_ARGS)
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);
170: } else
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:
178: /* ARGSUSED */
179: static void
180: print_man_head(MAN_ARGS)
181: {
182:
183: print_gen_head(h);
1.48 schwarze 184: assert(man->title);
185: assert(man->msec);
186: bufcat_fmt(h, "%s(%s)", man->title, man->msec);
1.1 schwarze 187: print_otag(h, TAG_TITLE, 0, NULL);
188: print_text(h, h->buf);
189: }
190:
191:
192: static void
193: print_man_nodelist(MAN_ARGS)
194: {
195:
1.48 schwarze 196: print_man_node(man, n, mh, h);
1.1 schwarze 197: if (n->next)
1.48 schwarze 198: print_man_nodelist(man, n->next, mh, h);
1.1 schwarze 199: }
200:
201:
202: static void
203: print_man_node(MAN_ARGS)
204: {
205: int child;
206: struct tag *t;
207:
208: child = 1;
1.2 schwarze 209: t = h->tags.head;
1.1 schwarze 210:
211: switch (n->type) {
212: case (MAN_ROOT):
1.48 schwarze 213: man_root_pre(man, n, mh, h);
1.1 schwarze 214: break;
215: case (MAN_TEXT):
1.38 schwarze 216: /*
217: * If we have a blank line, output a vertical space.
218: * If we have a space as the first character, break
219: * before printing the line's data.
220: */
1.31 schwarze 221: if ('\0' == *n->string) {
222: print_otag(h, TAG_P, 0, NULL);
223: return;
1.40 schwarze 224: }
225:
226: if (' ' == *n->string && MAN_LINE & n->flags)
227: print_otag(h, TAG_BR, 0, NULL);
228: else if (MANH_LITERAL & mh->fl && n->prev)
1.31 schwarze 229: print_otag(h, TAG_BR, 0, NULL);
230:
1.1 schwarze 231: print_text(h, n->string);
1.36 schwarze 232: return;
233: case (MAN_EQN):
1.41 schwarze 234: print_eqn(h, n->eqn);
1.37 schwarze 235: break;
1.29 schwarze 236: case (MAN_TBL):
1.33 schwarze 237: /*
238: * This will take care of initialising all of the table
239: * state data for the first table, then tearing it down
240: * for the last one.
241: */
1.29 schwarze 242: print_tbl(h, n->span);
1.32 schwarze 243: return;
1.1 schwarze 244: default:
1.4 schwarze 245: /*
246: * Close out scope of font prior to opening a macro
1.33 schwarze 247: * scope.
1.4 schwarze 248: */
1.27 schwarze 249: if (HTMLFONT_NONE != h->metac) {
250: h->metal = h->metac;
251: h->metac = HTMLFONT_NONE;
1.33 schwarze 252: }
253:
254: /*
255: * Close out the current table, if it's open, and unset
256: * the "meta" table state. This will be reopened on the
257: * next table element.
258: */
259: if (h->tblt) {
260: print_tblclose(h);
261: t = h->tags.head;
1.4 schwarze 262: }
1.1 schwarze 263: if (mans[n->tok].pre)
1.48 schwarze 264: child = (*mans[n->tok].pre)(man, n, mh, h);
1.1 schwarze 265: break;
266: }
267:
268: if (child && n->child)
1.48 schwarze 269: print_man_nodelist(man, n->child, mh, h);
1.1 schwarze 270:
1.4 schwarze 271: /* This will automatically close out any font scope. */
1.1 schwarze 272: print_stagq(h, t);
273:
274: switch (n->type) {
275: case (MAN_ROOT):
1.48 schwarze 276: man_root_post(man, n, mh, h);
1.37 schwarze 277: break;
278: case (MAN_EQN):
1.1 schwarze 279: break;
280: default:
281: if (mans[n->tok].post)
1.48 schwarze 282: (*mans[n->tok].post)(man, n, mh, h);
1.1 schwarze 283: break;
284: }
285: }
286:
287:
288: static int
289: a2width(const struct man_node *n, struct roffsu *su)
290: {
291:
292: if (MAN_TEXT != n->type)
293: return(0);
294: if (a2roffsu(n->string, su, SCALE_BU))
295: return(1);
296:
297: return(0);
298: }
299:
300:
301: /* ARGSUSED */
1.38 schwarze 302: static void
1.1 schwarze 303: man_root_pre(MAN_ARGS)
304: {
1.26 schwarze 305: struct htmlpair tag[3];
1.1 schwarze 306: struct tag *t, *tt;
307: char b[BUFSIZ], title[BUFSIZ];
308:
309: b[0] = 0;
1.48 schwarze 310: if (man->vol)
311: (void)strlcat(b, man->vol, BUFSIZ);
1.1 schwarze 312:
1.48 schwarze 313: assert(man->title);
314: assert(man->msec);
315: snprintf(title, BUFSIZ - 1, "%s(%s)", man->title, man->msec);
1.1 schwarze 316:
1.26 schwarze 317: PAIR_SUMMARY_INIT(&tag[0], "Document Header");
318: PAIR_CLASS_INIT(&tag[1], "head");
1.44 schwarze 319: PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
320: t = print_otag(h, TAG_TABLE, 3, tag);
321: PAIR_INIT(&tag[0], ATTR_WIDTH, "30%");
322: print_otag(h, TAG_COL, 1, tag);
323: print_otag(h, TAG_COL, 1, tag);
324: print_otag(h, TAG_COL, 1, tag);
1.26 schwarze 325:
326: print_otag(h, TAG_TBODY, 0, NULL);
1.3 schwarze 327:
1.1 schwarze 328: tt = print_otag(h, TAG_TR, 0, NULL);
329:
1.25 schwarze 330: PAIR_CLASS_INIT(&tag[0], "head-ltitle");
1.1 schwarze 331: print_otag(h, TAG_TD, 1, tag);
332: print_text(h, title);
333: print_stagq(h, tt);
334:
1.25 schwarze 335: PAIR_CLASS_INIT(&tag[0], "head-vol");
1.44 schwarze 336: PAIR_INIT(&tag[1], ATTR_ALIGN, "center");
337: print_otag(h, TAG_TD, 2, tag);
1.1 schwarze 338: print_text(h, b);
339: print_stagq(h, tt);
340:
1.25 schwarze 341: PAIR_CLASS_INIT(&tag[0], "head-rtitle");
1.44 schwarze 342: PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
343: print_otag(h, TAG_TD, 2, tag);
1.1 schwarze 344: print_text(h, title);
345: print_tagq(h, t);
346: }
347:
348:
349: /* ARGSUSED */
350: static void
351: man_root_post(MAN_ARGS)
352: {
1.26 schwarze 353: struct htmlpair tag[3];
1.1 schwarze 354: struct tag *t, *tt;
355:
1.26 schwarze 356: PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
357: PAIR_CLASS_INIT(&tag[1], "foot");
1.44 schwarze 358: PAIR_INIT(&tag[2], ATTR_WIDTH, "100%");
359: t = print_otag(h, TAG_TABLE, 3, tag);
360: PAIR_INIT(&tag[0], ATTR_WIDTH, "50%");
361: print_otag(h, TAG_COL, 1, tag);
362: print_otag(h, TAG_COL, 1, tag);
1.3 schwarze 363:
1.1 schwarze 364: tt = print_otag(h, TAG_TR, 0, NULL);
365:
1.25 schwarze 366: PAIR_CLASS_INIT(&tag[0], "foot-date");
1.1 schwarze 367: print_otag(h, TAG_TD, 1, tag);
1.25 schwarze 368:
1.48 schwarze 369: assert(man->date);
370: print_text(h, man->date);
1.1 schwarze 371: print_stagq(h, tt);
372:
1.25 schwarze 373: PAIR_CLASS_INIT(&tag[0], "foot-os");
1.44 schwarze 374: PAIR_INIT(&tag[1], ATTR_ALIGN, "right");
375: print_otag(h, TAG_TD, 2, tag);
1.25 schwarze 376:
1.48 schwarze 377: if (man->source)
378: print_text(h, man->source);
1.1 schwarze 379: print_tagq(h, t);
380: }
381:
382:
383: /* ARGSUSED */
384: static int
385: man_br_pre(MAN_ARGS)
386: {
387: struct roffsu su;
388: struct htmlpair tag;
389:
390: SCALE_VS_INIT(&su, 1);
391:
1.21 schwarze 392: if (MAN_sp == n->tok) {
1.39 schwarze 393: if (NULL != (n = n->child))
394: if ( ! a2roffsu(n->string, &su, SCALE_VS))
395: SCALE_VS_INIT(&su, atoi(n->string));
1.21 schwarze 396: } else
1.1 schwarze 397: su.scale = 0;
398:
1.38 schwarze 399: bufinit(h);
1.1 schwarze 400: bufcat_su(h, "height", &su);
401: PAIR_STYLE_INIT(&tag, h);
402: print_otag(h, TAG_DIV, 1, &tag);
1.4 schwarze 403:
1.3 schwarze 404: /* So the div isn't empty: */
405: print_text(h, "\\~");
406:
1.1 schwarze 407: return(0);
408: }
409:
410: /* ARGSUSED */
411: static int
412: man_SH_pre(MAN_ARGS)
413: {
1.25 schwarze 414: struct htmlpair tag;
1.1 schwarze 415:
1.25 schwarze 416: if (MAN_BLOCK == n->type) {
1.39 schwarze 417: mh->fl &= ~MANH_LITERAL;
1.25 schwarze 418: PAIR_CLASS_INIT(&tag, "section");
419: print_otag(h, TAG_DIV, 1, &tag);
1.1 schwarze 420: return(1);
1.25 schwarze 421: } else if (MAN_BODY == n->type)
1.1 schwarze 422: return(1);
423:
1.25 schwarze 424: print_otag(h, TAG_H1, 0, NULL);
1.1 schwarze 425: return(1);
426: }
427:
428: /* ARGSUSED */
429: static int
430: man_alt_pre(MAN_ARGS)
431: {
432: const struct man_node *nn;
1.40 schwarze 433: int i, savelit;
1.27 schwarze 434: enum htmltag fp;
435: struct tag *t;
1.1 schwarze 436:
1.40 schwarze 437: if ((savelit = mh->fl & MANH_LITERAL))
438: print_otag(h, TAG_BR, 0, NULL);
439:
440: mh->fl &= ~MANH_LITERAL;
441:
1.1 schwarze 442: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.27 schwarze 443: t = NULL;
1.1 schwarze 444: switch (n->tok) {
445: case (MAN_BI):
1.27 schwarze 446: fp = i % 2 ? TAG_I : TAG_B;
1.1 schwarze 447: break;
448: case (MAN_IB):
1.27 schwarze 449: fp = i % 2 ? TAG_B : TAG_I;
1.1 schwarze 450: break;
451: case (MAN_RI):
1.27 schwarze 452: fp = i % 2 ? TAG_I : TAG_MAX;
1.1 schwarze 453: break;
454: case (MAN_IR):
1.27 schwarze 455: fp = i % 2 ? TAG_MAX : TAG_I;
1.1 schwarze 456: break;
457: case (MAN_BR):
1.27 schwarze 458: fp = i % 2 ? TAG_MAX : TAG_B;
1.1 schwarze 459: break;
460: case (MAN_RB):
1.27 schwarze 461: fp = i % 2 ? TAG_B : TAG_MAX;
1.1 schwarze 462: break;
463: default:
464: abort();
465: /* NOTREACHED */
466: }
467:
468: if (i)
469: h->flags |= HTML_NOSPACE;
470:
1.27 schwarze 471: if (TAG_MAX != fp)
472: t = print_otag(h, fp, 0, NULL);
473:
1.48 schwarze 474: print_man_node(man, nn, mh, h);
1.27 schwarze 475:
476: if (t)
477: print_tagq(h, t);
1.1 schwarze 478: }
479:
1.40 schwarze 480: if (savelit)
481: mh->fl |= MANH_LITERAL;
482:
1.1 schwarze 483: return(0);
484: }
485:
486: /* ARGSUSED */
487: static int
1.26 schwarze 488: man_SM_pre(MAN_ARGS)
1.1 schwarze 489: {
490:
1.27 schwarze 491: print_otag(h, TAG_SMALL, 0, NULL);
1.26 schwarze 492: if (MAN_SB == n->tok)
1.27 schwarze 493: print_otag(h, TAG_B, 0, NULL);
1.1 schwarze 494: return(1);
495: }
496:
497: /* ARGSUSED */
498: static int
499: man_SS_pre(MAN_ARGS)
500: {
1.25 schwarze 501: struct htmlpair tag;
1.1 schwarze 502:
1.25 schwarze 503: if (MAN_BLOCK == n->type) {
1.39 schwarze 504: mh->fl &= ~MANH_LITERAL;
1.25 schwarze 505: PAIR_CLASS_INIT(&tag, "subsection");
506: print_otag(h, TAG_DIV, 1, &tag);
1.1 schwarze 507: return(1);
1.25 schwarze 508: } else if (MAN_BODY == n->type)
1.1 schwarze 509: return(1);
510:
1.25 schwarze 511: print_otag(h, TAG_H2, 0, NULL);
1.1 schwarze 512: return(1);
513: }
514:
515: /* ARGSUSED */
516: static int
517: man_PP_pre(MAN_ARGS)
518: {
519:
1.22 schwarze 520: if (MAN_HEAD == n->type)
521: return(0);
1.39 schwarze 522: else if (MAN_BLOCK == n->type)
523: print_bvspace(h, n);
1.22 schwarze 524:
1.1 schwarze 525: return(1);
526: }
527:
528: /* ARGSUSED */
529: static int
530: man_IP_pre(MAN_ARGS)
531: {
532: const struct man_node *nn;
533:
534: if (MAN_BODY == n->type) {
1.40 schwarze 535: print_otag(h, TAG_DD, 0, NULL);
536: return(1);
537: } else if (MAN_HEAD != n->type) {
538: print_otag(h, TAG_DL, 0, NULL);
1.1 schwarze 539: return(1);
540: }
541:
1.40 schwarze 542: /* FIXME: width specification. */
1.7 schwarze 543:
1.40 schwarze 544: print_otag(h, TAG_DT, 0, NULL);
1.1 schwarze 545:
1.28 schwarze 546: /* For IP, only print the first header element. */
1.1 schwarze 547:
1.28 schwarze 548: if (MAN_IP == n->tok && n->child)
1.48 schwarze 549: print_man_node(man, n->child, mh, h);
1.7 schwarze 550:
1.28 schwarze 551: /* For TP, only print next-line header elements. */
1.1 schwarze 552:
1.50 schwarze 553: if (MAN_TP == n->tok) {
554: nn = n->child;
555: while (NULL != nn && 0 == (MAN_LINE & nn->flags))
556: nn = nn->next;
557: while (NULL != nn) {
558: print_man_node(man, nn, mh, h);
559: nn = nn->next;
560: }
561: }
1.1 schwarze 562:
563: return(0);
564: }
565:
566: /* ARGSUSED */
567: static int
568: man_HP_pre(MAN_ARGS)
569: {
1.26 schwarze 570: struct htmlpair tag;
571: struct roffsu su;
572: const struct man_node *np;
1.1 schwarze 573:
1.40 schwarze 574: if (MAN_HEAD == n->type)
575: return(0);
576: else if (MAN_BLOCK != n->type)
577: return(1);
1.38 schwarze 578:
1.40 schwarze 579: np = n->head->child;
1.1 schwarze 580:
1.26 schwarze 581: if (NULL == np || ! a2width(np, &su))
582: SCALE_HS_INIT(&su, INDENT);
1.1 schwarze 583:
1.40 schwarze 584: bufinit(h);
1.1 schwarze 585:
1.40 schwarze 586: print_bvspace(h, n);
587: bufcat_su(h, "margin-left", &su);
1.26 schwarze 588: su.scale = -su.scale;
1.1 schwarze 589: bufcat_su(h, "text-indent", &su);
590: PAIR_STYLE_INIT(&tag, h);
1.40 schwarze 591: print_otag(h, TAG_P, 1, &tag);
1.1 schwarze 592: return(1);
593: }
1.46 schwarze 594:
595: /* ARGSUSED */
596: static int
597: man_OP_pre(MAN_ARGS)
598: {
599: struct tag *tt;
600: struct htmlpair tag;
601:
602: print_text(h, "[");
603: h->flags |= HTML_NOSPACE;
604: PAIR_CLASS_INIT(&tag, "opt");
605: tt = print_otag(h, TAG_SPAN, 1, &tag);
606:
607: if (NULL != (n = n->child)) {
608: print_otag(h, TAG_B, 0, NULL);
609: print_text(h, n->string);
610: }
611:
612: print_stagq(h, tt);
613:
614: if (NULL != n && NULL != n->next) {
615: print_otag(h, TAG_I, 0, NULL);
616: print_text(h, n->next->string);
617: }
618:
619: print_stagq(h, tt);
620: h->flags |= HTML_NOSPACE;
621: print_text(h, "]");
622: return(0);
623: }
624:
1.1 schwarze 625:
626: /* ARGSUSED */
627: static int
628: man_B_pre(MAN_ARGS)
629: {
630:
1.27 schwarze 631: print_otag(h, TAG_B, 0, NULL);
1.1 schwarze 632: return(1);
633: }
634:
635: /* ARGSUSED */
636: static int
637: man_I_pre(MAN_ARGS)
638: {
1.4 schwarze 639:
1.27 schwarze 640: print_otag(h, TAG_I, 0, NULL);
1.1 schwarze 641: return(1);
1.18 schwarze 642: }
643:
644: /* ARGSUSED */
645: static int
646: man_literal_pre(MAN_ARGS)
647: {
648:
1.47 schwarze 649: if (MAN_fi == n->tok || MAN_EE == n->tok) {
1.18 schwarze 650: print_otag(h, TAG_BR, 0, NULL);
1.40 schwarze 651: mh->fl &= ~MANH_LITERAL;
652: } else
1.18 schwarze 653: mh->fl |= MANH_LITERAL;
654:
1.34 schwarze 655: return(0);
1.18 schwarze 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.1 schwarze 665: }
666:
667: /* ARGSUSED */
668: static int
669: man_ign_pre(MAN_ARGS)
670: {
671:
672: return(0);
673: }
674:
675: /* ARGSUSED */
676: static int
677: man_RS_pre(MAN_ARGS)
678: {
679: struct htmlpair tag;
680: struct roffsu su;
681:
682: if (MAN_HEAD == n->type)
683: return(0);
684: else if (MAN_BODY == n->type)
685: return(1);
686:
687: SCALE_HS_INIT(&su, INDENT);
1.26 schwarze 688: if (n->head->child)
1.1 schwarze 689: a2width(n->head->child, &su);
690:
1.38 schwarze 691: bufinit(h);
1.26 schwarze 692: bufcat_su(h, "margin-left", &su);
1.1 schwarze 693: PAIR_STYLE_INIT(&tag, h);
694: print_otag(h, TAG_DIV, 1, &tag);
695: return(1);
1.49 schwarze 696: }
697:
698: /* ARGSUSED */
699: static int
700: man_UR_pre(MAN_ARGS)
701: {
702: struct htmlpair tag[2];
703:
704: n = n->child;
705: assert(MAN_HEAD == n->type);
706: if (n->nchild) {
707: assert(MAN_TEXT == n->child->type);
708: PAIR_CLASS_INIT(&tag[0], "link-ext");
709: PAIR_HREF_INIT(&tag[1], n->child->string);
710: print_otag(h, TAG_A, 2, tag);
711: }
712:
713: assert(MAN_BODY == n->next->type);
714: if (n->next->nchild)
715: n = n->next;
716:
717: print_man_nodelist(man, n->child, mh, h);
718:
719: return(0);
1.1 schwarze 720: }