Annotation of src/usr.bin/mandoc/man_html.c, Revision 1.58
1.58 ! schwarze 1: /* $OpenBSD: man_html.c,v 1.57 2014/11/28 19:25:03 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.38 schwarze 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.31 schwarze 218: if ('\0' == *n->string) {
1.56 schwarze 219: print_paragraph(h);
1.31 schwarze 220: return;
1.40 schwarze 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.31 schwarze 226: print_otag(h, TAG_BR, 0, NULL);
227:
1.1 schwarze 228: print_text(h, n->string);
1.36 schwarze 229: return;
1.52 schwarze 230: case MAN_EQN:
1.41 schwarze 231: print_eqn(h, n->eqn);
1.37 schwarze 232: break;
1.52 schwarze 233: case MAN_TBL:
1.33 schwarze 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.29 schwarze 239: print_tbl(h, n->span);
1.32 schwarze 240: return;
1.1 schwarze 241: default:
1.52 schwarze 242: /*
1.4 schwarze 243: * Close out scope of font prior to opening a macro
1.33 schwarze 244: * scope.
1.4 schwarze 245: */
1.27 schwarze 246: if (HTMLFONT_NONE != h->metac) {
247: h->metal = h->metac;
248: h->metac = HTMLFONT_NONE;
1.33 schwarze 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.4 schwarze 259: }
1.1 schwarze 260: if (mans[n->tok].pre)
1.48 schwarze 261: child = (*mans[n->tok].pre)(man, n, mh, h);
1.1 schwarze 262: break;
263: }
264:
265: if (child && n->child)
1.48 schwarze 266: print_man_nodelist(man, n->child, mh, h);
1.1 schwarze 267:
1.4 schwarze 268: /* This will automatically close out any font scope. */
1.1 schwarze 269: print_stagq(h, t);
270:
271: switch (n->type) {
1.52 schwarze 272: case MAN_ROOT:
1.48 schwarze 273: man_root_post(man, n, mh, h);
1.37 schwarze 274: break;
1.52 schwarze 275: case MAN_EQN:
1.1 schwarze 276: break;
277: default:
278: if (mans[n->tok].post)
1.48 schwarze 279: (*mans[n->tok].post)(man, n, mh, h);
1.1 schwarze 280: break;
281: }
282: }
283:
284: static int
285: a2width(const struct man_node *n, struct roffsu *su)
286: {
287:
288: if (MAN_TEXT != n->type)
289: return(0);
290: if (a2roffsu(n->string, su, SCALE_BU))
291: return(1);
292:
293: return(0);
294: }
295:
1.38 schwarze 296: static void
1.1 schwarze 297: man_root_pre(MAN_ARGS)
298: {
1.56 schwarze 299: struct htmlpair tag;
1.1 schwarze 300: struct tag *t, *tt;
1.53 schwarze 301: char *title;
1.1 schwarze 302:
1.48 schwarze 303: assert(man->title);
304: assert(man->msec);
1.53 schwarze 305: mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.1 schwarze 306:
1.56 schwarze 307: PAIR_CLASS_INIT(&tag, "head");
308: t = print_otag(h, TAG_TABLE, 1, &tag);
1.26 schwarze 309:
310: print_otag(h, TAG_TBODY, 0, NULL);
1.3 schwarze 311:
1.1 schwarze 312: tt = print_otag(h, TAG_TR, 0, NULL);
313:
1.56 schwarze 314: PAIR_CLASS_INIT(&tag, "head-ltitle");
315: print_otag(h, TAG_TD, 1, &tag);
1.1 schwarze 316: print_text(h, title);
317: print_stagq(h, tt);
318:
1.56 schwarze 319: PAIR_CLASS_INIT(&tag, "head-vol");
320: print_otag(h, TAG_TD, 1, &tag);
1.54 schwarze 321: if (NULL != man->vol)
322: print_text(h, man->vol);
1.1 schwarze 323: print_stagq(h, tt);
324:
1.56 schwarze 325: PAIR_CLASS_INIT(&tag, "head-rtitle");
326: print_otag(h, TAG_TD, 1, &tag);
1.1 schwarze 327: print_text(h, title);
328: print_tagq(h, t);
1.53 schwarze 329: free(title);
1.1 schwarze 330: }
331:
332: static void
333: man_root_post(MAN_ARGS)
334: {
1.56 schwarze 335: struct htmlpair tag;
1.1 schwarze 336: struct tag *t, *tt;
337:
1.56 schwarze 338: PAIR_CLASS_INIT(&tag, "foot");
339: t = print_otag(h, TAG_TABLE, 1, &tag);
1.3 schwarze 340:
1.1 schwarze 341: tt = print_otag(h, TAG_TR, 0, NULL);
342:
1.56 schwarze 343: PAIR_CLASS_INIT(&tag, "foot-date");
344: print_otag(h, TAG_TD, 1, &tag);
1.25 schwarze 345:
1.48 schwarze 346: assert(man->date);
347: print_text(h, man->date);
1.1 schwarze 348: print_stagq(h, tt);
349:
1.56 schwarze 350: PAIR_CLASS_INIT(&tag, "foot-os");
351: print_otag(h, TAG_TD, 1, &tag);
1.25 schwarze 352:
1.48 schwarze 353: if (man->source)
354: print_text(h, man->source);
1.1 schwarze 355: print_tagq(h, t);
356: }
357:
358:
359: static int
360: man_br_pre(MAN_ARGS)
361: {
362: struct roffsu su;
363: struct htmlpair tag;
364:
365: SCALE_VS_INIT(&su, 1);
366:
1.21 schwarze 367: if (MAN_sp == n->tok) {
1.39 schwarze 368: if (NULL != (n = n->child))
369: if ( ! a2roffsu(n->string, &su, SCALE_VS))
370: SCALE_VS_INIT(&su, atoi(n->string));
1.21 schwarze 371: } else
1.55 schwarze 372: su.scale = 0.0;
1.1 schwarze 373:
1.38 schwarze 374: bufinit(h);
1.1 schwarze 375: bufcat_su(h, "height", &su);
376: PAIR_STYLE_INIT(&tag, h);
377: print_otag(h, TAG_DIV, 1, &tag);
1.4 schwarze 378:
1.3 schwarze 379: /* So the div isn't empty: */
380: print_text(h, "\\~");
381:
1.1 schwarze 382: return(0);
383: }
384:
385: static int
386: man_SH_pre(MAN_ARGS)
387: {
1.25 schwarze 388: struct htmlpair tag;
1.1 schwarze 389:
1.25 schwarze 390: if (MAN_BLOCK == n->type) {
1.39 schwarze 391: mh->fl &= ~MANH_LITERAL;
1.25 schwarze 392: PAIR_CLASS_INIT(&tag, "section");
393: print_otag(h, TAG_DIV, 1, &tag);
1.1 schwarze 394: return(1);
1.25 schwarze 395: } else if (MAN_BODY == n->type)
1.1 schwarze 396: return(1);
397:
1.25 schwarze 398: print_otag(h, TAG_H1, 0, NULL);
1.1 schwarze 399: return(1);
400: }
401:
402: static int
403: man_alt_pre(MAN_ARGS)
404: {
405: const struct man_node *nn;
1.40 schwarze 406: int i, savelit;
1.27 schwarze 407: enum htmltag fp;
408: struct tag *t;
1.1 schwarze 409:
1.52 schwarze 410: if ((savelit = mh->fl & MANH_LITERAL))
1.40 schwarze 411: print_otag(h, TAG_BR, 0, NULL);
412:
413: mh->fl &= ~MANH_LITERAL;
414:
1.1 schwarze 415: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.27 schwarze 416: t = NULL;
1.1 schwarze 417: switch (n->tok) {
1.52 schwarze 418: case MAN_BI:
1.27 schwarze 419: fp = i % 2 ? TAG_I : TAG_B;
1.1 schwarze 420: break;
1.52 schwarze 421: case MAN_IB:
1.27 schwarze 422: fp = i % 2 ? TAG_B : TAG_I;
1.1 schwarze 423: break;
1.52 schwarze 424: case MAN_RI:
1.27 schwarze 425: fp = i % 2 ? TAG_I : TAG_MAX;
1.1 schwarze 426: break;
1.52 schwarze 427: case MAN_IR:
1.27 schwarze 428: fp = i % 2 ? TAG_MAX : TAG_I;
1.1 schwarze 429: break;
1.52 schwarze 430: case MAN_BR:
1.27 schwarze 431: fp = i % 2 ? TAG_MAX : TAG_B;
1.1 schwarze 432: break;
1.52 schwarze 433: case MAN_RB:
1.27 schwarze 434: fp = i % 2 ? TAG_B : TAG_MAX;
1.1 schwarze 435: break;
436: default:
437: abort();
438: /* NOTREACHED */
439: }
440:
441: if (i)
442: h->flags |= HTML_NOSPACE;
443:
1.27 schwarze 444: if (TAG_MAX != fp)
445: t = print_otag(h, fp, 0, NULL);
446:
1.48 schwarze 447: print_man_node(man, nn, mh, h);
1.27 schwarze 448:
449: if (t)
450: print_tagq(h, t);
1.1 schwarze 451: }
452:
1.40 schwarze 453: if (savelit)
454: mh->fl |= MANH_LITERAL;
455:
1.1 schwarze 456: return(0);
457: }
458:
459: static int
1.26 schwarze 460: man_SM_pre(MAN_ARGS)
1.1 schwarze 461: {
1.52 schwarze 462:
1.27 schwarze 463: print_otag(h, TAG_SMALL, 0, NULL);
1.26 schwarze 464: if (MAN_SB == n->tok)
1.27 schwarze 465: print_otag(h, TAG_B, 0, NULL);
1.1 schwarze 466: return(1);
467: }
468:
469: static int
470: man_SS_pre(MAN_ARGS)
471: {
1.25 schwarze 472: struct htmlpair tag;
1.1 schwarze 473:
1.25 schwarze 474: if (MAN_BLOCK == n->type) {
1.39 schwarze 475: mh->fl &= ~MANH_LITERAL;
1.25 schwarze 476: PAIR_CLASS_INIT(&tag, "subsection");
477: print_otag(h, TAG_DIV, 1, &tag);
1.1 schwarze 478: return(1);
1.25 schwarze 479: } else if (MAN_BODY == n->type)
1.1 schwarze 480: return(1);
481:
1.25 schwarze 482: print_otag(h, TAG_H2, 0, NULL);
1.1 schwarze 483: return(1);
484: }
485:
486: static int
487: man_PP_pre(MAN_ARGS)
488: {
489:
1.22 schwarze 490: if (MAN_HEAD == n->type)
491: return(0);
1.39 schwarze 492: else if (MAN_BLOCK == n->type)
493: print_bvspace(h, n);
1.22 schwarze 494:
1.1 schwarze 495: return(1);
496: }
497:
498: static int
499: man_IP_pre(MAN_ARGS)
500: {
501: const struct man_node *nn;
502:
1.52 schwarze 503: if (MAN_BODY == n->type) {
1.40 schwarze 504: print_otag(h, TAG_DD, 0, NULL);
505: return(1);
506: } else if (MAN_HEAD != n->type) {
507: print_otag(h, TAG_DL, 0, NULL);
1.1 schwarze 508: return(1);
509: }
510:
1.40 schwarze 511: /* FIXME: width specification. */
1.7 schwarze 512:
1.40 schwarze 513: print_otag(h, TAG_DT, 0, NULL);
1.1 schwarze 514:
1.28 schwarze 515: /* For IP, only print the first header element. */
1.1 schwarze 516:
1.28 schwarze 517: if (MAN_IP == n->tok && n->child)
1.48 schwarze 518: print_man_node(man, n->child, mh, h);
1.7 schwarze 519:
1.28 schwarze 520: /* For TP, only print next-line header elements. */
1.1 schwarze 521:
1.50 schwarze 522: if (MAN_TP == n->tok) {
523: nn = n->child;
524: while (NULL != nn && 0 == (MAN_LINE & nn->flags))
525: nn = nn->next;
526: while (NULL != nn) {
527: print_man_node(man, nn, mh, h);
528: nn = nn->next;
529: }
530: }
1.1 schwarze 531:
532: return(0);
533: }
534:
535: static int
536: man_HP_pre(MAN_ARGS)
537: {
1.56 schwarze 538: struct htmlpair tag[2];
1.26 schwarze 539: struct roffsu su;
540: const struct man_node *np;
1.1 schwarze 541:
1.40 schwarze 542: if (MAN_HEAD == n->type)
543: return(0);
544: else if (MAN_BLOCK != n->type)
545: return(1);
1.38 schwarze 546:
1.40 schwarze 547: np = n->head->child;
1.1 schwarze 548:
1.26 schwarze 549: if (NULL == np || ! a2width(np, &su))
550: SCALE_HS_INIT(&su, INDENT);
1.1 schwarze 551:
1.40 schwarze 552: bufinit(h);
1.1 schwarze 553:
1.40 schwarze 554: print_bvspace(h, n);
555: bufcat_su(h, "margin-left", &su);
1.26 schwarze 556: su.scale = -su.scale;
1.1 schwarze 557: bufcat_su(h, "text-indent", &su);
1.56 schwarze 558: PAIR_STYLE_INIT(&tag[0], h);
559: PAIR_CLASS_INIT(&tag[1], "spacer");
560: print_otag(h, TAG_DIV, 2, tag);
1.1 schwarze 561: return(1);
562: }
1.46 schwarze 563:
564: static int
565: man_OP_pre(MAN_ARGS)
566: {
567: struct tag *tt;
568: struct htmlpair tag;
569:
570: print_text(h, "[");
571: h->flags |= HTML_NOSPACE;
572: PAIR_CLASS_INIT(&tag, "opt");
573: tt = print_otag(h, TAG_SPAN, 1, &tag);
574:
575: if (NULL != (n = n->child)) {
576: print_otag(h, TAG_B, 0, NULL);
577: print_text(h, n->string);
578: }
579:
580: print_stagq(h, tt);
581:
582: if (NULL != n && NULL != n->next) {
583: print_otag(h, TAG_I, 0, NULL);
584: print_text(h, n->next->string);
585: }
586:
587: print_stagq(h, tt);
588: h->flags |= HTML_NOSPACE;
589: print_text(h, "]");
590: return(0);
591: }
592:
1.1 schwarze 593: static int
594: man_B_pre(MAN_ARGS)
595: {
596:
1.27 schwarze 597: print_otag(h, TAG_B, 0, NULL);
1.1 schwarze 598: return(1);
599: }
600:
601: static int
602: man_I_pre(MAN_ARGS)
603: {
1.52 schwarze 604:
1.27 schwarze 605: print_otag(h, TAG_I, 0, NULL);
1.1 schwarze 606: return(1);
1.18 schwarze 607: }
608:
609: static int
610: man_literal_pre(MAN_ARGS)
611: {
612:
1.47 schwarze 613: if (MAN_fi == n->tok || MAN_EE == n->tok) {
1.18 schwarze 614: print_otag(h, TAG_BR, 0, NULL);
1.40 schwarze 615: mh->fl &= ~MANH_LITERAL;
616: } else
1.18 schwarze 617: mh->fl |= MANH_LITERAL;
618:
1.34 schwarze 619: return(0);
1.18 schwarze 620: }
621:
622: static int
623: man_in_pre(MAN_ARGS)
624: {
625:
626: print_otag(h, TAG_BR, 0, NULL);
627: return(0);
1.1 schwarze 628: }
629:
630: static int
631: man_ign_pre(MAN_ARGS)
632: {
633:
634: return(0);
635: }
636:
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.26 schwarze 649: if (n->head->child)
1.1 schwarze 650: a2width(n->head->child, &su);
651:
1.38 schwarze 652: bufinit(h);
1.26 schwarze 653: bufcat_su(h, "margin-left", &su);
1.1 schwarze 654: PAIR_STYLE_INIT(&tag, h);
655: print_otag(h, TAG_DIV, 1, &tag);
656: return(1);
1.49 schwarze 657: }
658:
659: static int
660: man_UR_pre(MAN_ARGS)
661: {
662: struct htmlpair tag[2];
663:
664: n = n->child;
665: assert(MAN_HEAD == n->type);
666: if (n->nchild) {
667: assert(MAN_TEXT == n->child->type);
668: PAIR_CLASS_INIT(&tag[0], "link-ext");
669: PAIR_HREF_INIT(&tag[1], n->child->string);
670: print_otag(h, TAG_A, 2, tag);
671: }
672:
673: assert(MAN_BODY == n->next->type);
674: if (n->next->nchild)
675: n = n->next;
676:
677: print_man_nodelist(man, n->child, mh, h);
678:
679: return(0);
1.1 schwarze 680: }