Annotation of mandoc/man_html.c, Revision 1.122
1.122 ! schwarze 1: /* $Id: man_html.c,v 1.121 2017/01/10 13:47:00 schwarze Exp $ */
1.1 kristaps 2: /*
1.104 kristaps 3: * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
1.122 ! schwarze 4: * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
1.1 kristaps 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: *
1.113 schwarze 10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1.1 kristaps 11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1.113 schwarze 12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1.1 kristaps 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: */
1.25 kristaps 18: #include "config.h"
19:
1.1 kristaps 20: #include <sys/types.h>
21:
1.5 kristaps 22: #include <assert.h>
23: #include <ctype.h>
1.2 kristaps 24: #include <stdio.h>
1.1 kristaps 25: #include <stdlib.h>
1.4 kristaps 26: #include <string.h>
1.1 kristaps 27:
1.94 schwarze 28: #include "mandoc_aux.h"
1.113 schwarze 29: #include "roff.h"
1.105 schwarze 30: #include "man.h"
1.7 kristaps 31: #include "out.h"
1.1 kristaps 32: #include "html.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.115 schwarze 40: #define MAN_ARGS const struct roff_meta *man, \
1.114 schwarze 41: const struct roff_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.93 schwarze 55: static void print_bvspace(struct html *,
1.114 schwarze 56: const struct roff_node *);
1.3 kristaps 57: static void print_man_head(MAN_ARGS);
1.4 kristaps 58: static void print_man_nodelist(MAN_ARGS);
59: static void print_man_node(MAN_ARGS);
1.114 schwarze 60: static int a2width(const struct roff_node *,
1.7 kristaps 61: struct roffsu *);
1.8 kristaps 62: static int man_B_pre(MAN_ARGS);
1.6 kristaps 63: static int man_HP_pre(MAN_ARGS);
1.86 kristaps 64: static int man_IP_pre(MAN_ARGS);
1.8 kristaps 65: static int man_I_pre(MAN_ARGS);
1.86 kristaps 66: static int man_OP_pre(MAN_ARGS);
1.4 kristaps 67: static int man_PP_pre(MAN_ARGS);
1.9 kristaps 68: static int man_RS_pre(MAN_ARGS);
1.4 kristaps 69: static int man_SH_pre(MAN_ARGS);
1.8 kristaps 70: static int man_SM_pre(MAN_ARGS);
1.4 kristaps 71: static int man_SS_pre(MAN_ARGS);
1.90 schwarze 72: static int man_UR_pre(MAN_ARGS);
1.86 kristaps 73: static int man_alt_pre(MAN_ARGS);
74: static int man_br_pre(MAN_ARGS);
75: static int man_ign_pre(MAN_ARGS);
76: static int man_in_pre(MAN_ARGS);
77: static int man_literal_pre(MAN_ARGS);
78: static void man_root_post(MAN_ARGS);
79: static void man_root_pre(MAN_ARGS);
1.4 kristaps 80:
1.3 kristaps 81: static const struct htmlman mans[MAN_MAX] = {
1.4 kristaps 82: { man_br_pre, NULL }, /* br */
1.3 kristaps 83: { NULL, NULL }, /* TH */
1.4 kristaps 84: { man_SH_pre, NULL }, /* SH */
85: { man_SS_pre, NULL }, /* SS */
1.6 kristaps 86: { man_IP_pre, NULL }, /* TP */
1.4 kristaps 87: { man_PP_pre, NULL }, /* LP */
88: { man_PP_pre, NULL }, /* PP */
89: { man_PP_pre, NULL }, /* P */
1.5 kristaps 90: { man_IP_pre, NULL }, /* IP */
1.93 schwarze 91: { man_HP_pre, NULL }, /* HP */
1.8 kristaps 92: { man_SM_pre, NULL }, /* SM */
1.56 kristaps 93: { man_SM_pre, NULL }, /* SB */
1.8 kristaps 94: { man_alt_pre, NULL }, /* BI */
95: { man_alt_pre, NULL }, /* IB */
96: { man_alt_pre, NULL }, /* BR */
97: { man_alt_pre, NULL }, /* RB */
1.3 kristaps 98: { NULL, NULL }, /* R */
1.8 kristaps 99: { man_B_pre, NULL }, /* B */
100: { man_I_pre, NULL }, /* I */
101: { man_alt_pre, NULL }, /* IR */
102: { man_alt_pre, NULL }, /* RI */
1.4 kristaps 103: { man_br_pre, NULL }, /* sp */
1.45 kristaps 104: { man_literal_pre, NULL }, /* nf */
105: { man_literal_pre, NULL }, /* fi */
1.3 kristaps 106: { NULL, NULL }, /* RE */
1.9 kristaps 107: { man_RS_pre, NULL }, /* RS */
1.8 kristaps 108: { man_ign_pre, NULL }, /* DT */
109: { man_ign_pre, NULL }, /* UC */
1.13 kristaps 110: { man_ign_pre, NULL }, /* PD */
1.34 joerg 111: { man_ign_pre, NULL }, /* AT */
1.45 kristaps 112: { man_in_pre, NULL }, /* in */
1.51 kristaps 113: { man_ign_pre, NULL }, /* ft */
1.86 kristaps 114: { man_OP_pre, NULL }, /* OP */
1.88 schwarze 115: { man_literal_pre, NULL }, /* EX */
116: { man_literal_pre, NULL }, /* EE */
1.90 schwarze 117: { man_UR_pre, NULL }, /* UR */
118: { NULL, NULL }, /* UE */
1.92 schwarze 119: { man_ign_pre, NULL }, /* ll */
1.3 kristaps 120: };
121:
1.93 schwarze 122:
1.74 kristaps 123: /*
124: * Printing leading vertical space before a block.
125: * This is used for the paragraph macros.
126: * The rules are pretty simple, since there's very little nesting going
127: * on here. Basically, if we're the first within another block (SS/SH),
128: * then don't emit vertical space. If we are (RS), then do. If not the
129: * first, print it.
130: */
131: static void
1.114 schwarze 132: print_bvspace(struct html *h, const struct roff_node *n)
1.74 kristaps 133: {
134:
135: if (n->body && n->body->child)
1.113 schwarze 136: if (n->body->child->type == ROFFT_TBL)
1.74 kristaps 137: return;
138:
1.113 schwarze 139: if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS)
1.74 kristaps 140: if (NULL == n->prev)
141: return;
142:
1.103 kristaps 143: print_paragraph(h);
1.74 kristaps 144: }
1.1 kristaps 145:
146: void
1.116 schwarze 147: html_man(void *arg, const struct roff_man *man)
1.1 kristaps 148: {
1.45 kristaps 149: struct mhtml mh;
1.117 schwarze 150: struct html *h;
1.82 kristaps 151: struct tag *t, *tt;
152:
1.117 schwarze 153: memset(&mh, 0, sizeof(mh));
154: h = (struct html *)arg;
1.3 kristaps 155:
1.82 kristaps 156: if ( ! (HTML_FRAGMENT & h->oflags)) {
157: print_gen_decls(h);
1.122 ! schwarze 158: t = print_otag(h, TAG_HTML, "");
! 159: tt = print_otag(h, TAG_HEAD, "");
1.117 schwarze 160: print_man_head(&man->meta, man->first, &mh, h);
1.82 kristaps 161: print_tagq(h, tt);
1.122 ! schwarze 162: print_otag(h, TAG_BODY, "");
! 163: print_otag(h, TAG_DIV, "c", "mandoc");
1.93 schwarze 164: } else
1.122 ! schwarze 165: t = print_otag(h, TAG_DIV, "c", "mandoc");
1.53 kristaps 166:
1.117 schwarze 167: print_man_nodelist(&man->meta, man->first, &mh, h);
1.3 kristaps 168: print_tagq(h, t);
1.117 schwarze 169: putchar('\n');
1.3 kristaps 170: }
171:
172: static void
173: print_man_head(MAN_ARGS)
174: {
175:
176: print_gen_head(h);
1.89 schwarze 177: assert(man->title);
178: assert(man->msec);
1.122 ! schwarze 179: bufinit(h);
1.89 schwarze 180: bufcat_fmt(h, "%s(%s)", man->title, man->msec);
1.122 ! schwarze 181: print_otag(h, TAG_TITLE, "");
1.3 kristaps 182: print_text(h, h->buf);
1.1 kristaps 183: }
1.4 kristaps 184:
185: static void
186: print_man_nodelist(MAN_ARGS)
187: {
188:
1.110 schwarze 189: while (n != NULL) {
190: print_man_node(man, n, mh, h);
191: n = n->next;
192: }
1.4 kristaps 193: }
194:
195: static void
196: print_man_node(MAN_ARGS)
197: {
198: int child;
199: struct tag *t;
200:
201: child = 1;
1.14 kristaps 202: t = h->tags.head;
1.4 kristaps 203:
204: switch (n->type) {
1.113 schwarze 205: case ROFFT_ROOT:
1.89 schwarze 206: man_root_pre(man, n, mh, h);
1.4 kristaps 207: break;
1.113 schwarze 208: case ROFFT_TEXT:
1.63 kristaps 209: if ('\0' == *n->string) {
1.103 kristaps 210: print_paragraph(h);
1.63 kristaps 211: return;
1.78 kristaps 212: }
1.121 schwarze 213: if (n->flags & NODE_LINE && (*n->string == ' ' ||
1.106 schwarze 214: (n->prev != NULL && mh->fl & MANH_LITERAL &&
215: ! (h->flags & HTML_NONEWLINE))))
1.122 ! schwarze 216: print_otag(h, TAG_BR, "");
1.4 kristaps 217: print_text(h, n->string);
1.68 kristaps 218: return;
1.113 schwarze 219: case ROFFT_EQN:
1.121 schwarze 220: if (n->flags & NODE_LINE)
1.112 schwarze 221: putchar('\n');
1.80 kristaps 222: print_eqn(h, n->eqn);
1.69 kristaps 223: break;
1.113 schwarze 224: case ROFFT_TBL:
1.66 kristaps 225: /*
226: * This will take care of initialising all of the table
227: * state data for the first table, then tearing it down
228: * for the last one.
229: */
1.60 kristaps 230: print_tbl(h, n->span);
1.64 kristaps 231: return;
1.4 kristaps 232: default:
1.93 schwarze 233: /*
1.21 kristaps 234: * Close out scope of font prior to opening a macro
1.66 kristaps 235: * scope.
1.21 kristaps 236: */
1.57 kristaps 237: if (HTMLFONT_NONE != h->metac) {
238: h->metal = h->metac;
239: h->metac = HTMLFONT_NONE;
1.66 kristaps 240: }
241:
242: /*
243: * Close out the current table, if it's open, and unset
244: * the "meta" table state. This will be reopened on the
245: * next table element.
246: */
247: if (h->tblt) {
248: print_tblclose(h);
249: t = h->tags.head;
1.20 kristaps 250: }
1.4 kristaps 251: if (mans[n->tok].pre)
1.89 schwarze 252: child = (*mans[n->tok].pre)(man, n, mh, h);
1.4 kristaps 253: break;
254: }
255:
1.21 kristaps 256: if (child && n->child)
1.89 schwarze 257: print_man_nodelist(man, n->child, mh, h);
1.21 kristaps 258:
1.24 kristaps 259: /* This will automatically close out any font scope. */
1.4 kristaps 260: print_stagq(h, t);
261:
1.61 kristaps 262: switch (n->type) {
1.113 schwarze 263: case ROFFT_ROOT:
1.89 schwarze 264: man_root_post(man, n, mh, h);
1.69 kristaps 265: break;
1.113 schwarze 266: case ROFFT_EQN:
1.61 kristaps 267: break;
268: default:
269: if (mans[n->tok].post)
1.89 schwarze 270: (*mans[n->tok].post)(man, n, mh, h);
1.61 kristaps 271: break;
272: }
1.4 kristaps 273: }
274:
1.5 kristaps 275: static int
1.114 schwarze 276: a2width(const struct roff_node *n, struct roffsu *su)
1.5 kristaps 277: {
278:
1.113 schwarze 279: if (n->type != ROFFT_TEXT)
1.119 schwarze 280: return 0;
1.107 schwarze 281: if (a2roffsu(n->string, su, SCALE_EN))
1.119 schwarze 282: return 1;
1.5 kristaps 283:
1.119 schwarze 284: return 0;
1.5 kristaps 285: }
286:
1.65 kristaps 287: static void
1.4 kristaps 288: man_root_pre(MAN_ARGS)
289: {
290: struct tag *t, *tt;
1.94 schwarze 291: char *title;
1.4 kristaps 292:
1.89 schwarze 293: assert(man->title);
294: assert(man->msec);
1.94 schwarze 295: mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.4 kristaps 296:
1.122 ! schwarze 297: t = print_otag(h, TAG_TABLE, "c", "head");
! 298: print_otag(h, TAG_TBODY, "");
! 299: tt = print_otag(h, TAG_TR, "");
1.4 kristaps 300:
1.122 ! schwarze 301: print_otag(h, TAG_TD, "c", "head-ltitle");
1.4 kristaps 302: print_text(h, title);
303: print_stagq(h, tt);
304:
1.122 ! schwarze 305: print_otag(h, TAG_TD, "c", "head-vol");
1.95 schwarze 306: if (NULL != man->vol)
307: print_text(h, man->vol);
1.4 kristaps 308: print_stagq(h, tt);
309:
1.122 ! schwarze 310: print_otag(h, TAG_TD, "c", "head-rtitle");
1.4 kristaps 311: print_text(h, title);
312: print_tagq(h, t);
1.94 schwarze 313: free(title);
1.4 kristaps 314: }
315:
316: static void
317: man_root_post(MAN_ARGS)
318: {
319: struct tag *t, *tt;
320:
1.122 ! schwarze 321: t = print_otag(h, TAG_TABLE, "c", "foot");
! 322: tt = print_otag(h, TAG_TR, "");
1.55 kristaps 323:
1.122 ! schwarze 324: print_otag(h, TAG_TD, "c", "foot-date");
1.89 schwarze 325: print_text(h, man->date);
1.4 kristaps 326: print_stagq(h, tt);
327:
1.122 ! schwarze 328: print_otag(h, TAG_TD, "c", "foot-os");
1.115 schwarze 329: if (man->os)
330: print_text(h, man->os);
1.4 kristaps 331: print_tagq(h, t);
332: }
333:
334:
335: static int
336: man_br_pre(MAN_ARGS)
337: {
1.7 kristaps 338: struct roffsu su;
1.4 kristaps 339:
1.7 kristaps 340: SCALE_VS_INIT(&su, 1);
341:
1.49 kristaps 342: if (MAN_sp == n->tok) {
1.75 kristaps 343: if (NULL != (n = n->child))
344: if ( ! a2roffsu(n->string, &su, SCALE_VS))
1.108 schwarze 345: su.scale = 1.0;
1.49 kristaps 346: } else
1.96 schwarze 347: su.scale = 0.0;
1.4 kristaps 348:
1.122 ! schwarze 349: print_otag(h, TAG_DIV, "suh", &su);
1.24 kristaps 350:
1.16 kristaps 351: /* So the div isn't empty: */
352: print_text(h, "\\~");
353:
1.119 schwarze 354: return 0;
1.4 kristaps 355: }
356:
357: static int
358: man_SH_pre(MAN_ARGS)
359: {
1.113 schwarze 360: if (n->type == ROFFT_BLOCK) {
1.76 kristaps 361: mh->fl &= ~MANH_LITERAL;
1.122 ! schwarze 362: print_otag(h, TAG_DIV, "c", "section");
1.119 schwarze 363: return 1;
1.113 schwarze 364: } else if (n->type == ROFFT_BODY)
1.119 schwarze 365: return 1;
1.4 kristaps 366:
1.122 ! schwarze 367: print_otag(h, TAG_H1, "");
1.119 schwarze 368: return 1;
1.4 kristaps 369: }
370:
371: static int
1.8 kristaps 372: man_alt_pre(MAN_ARGS)
373: {
1.114 schwarze 374: const struct roff_node *nn;
1.78 kristaps 375: int i, savelit;
1.57 kristaps 376: enum htmltag fp;
377: struct tag *t;
1.8 kristaps 378:
1.93 schwarze 379: if ((savelit = mh->fl & MANH_LITERAL))
1.122 ! schwarze 380: print_otag(h, TAG_BR, "");
1.78 kristaps 381:
382: mh->fl &= ~MANH_LITERAL;
383:
1.8 kristaps 384: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.57 kristaps 385: t = NULL;
1.8 kristaps 386: switch (n->tok) {
1.93 schwarze 387: case MAN_BI:
1.57 kristaps 388: fp = i % 2 ? TAG_I : TAG_B;
1.8 kristaps 389: break;
1.93 schwarze 390: case MAN_IB:
1.57 kristaps 391: fp = i % 2 ? TAG_B : TAG_I;
1.8 kristaps 392: break;
1.93 schwarze 393: case MAN_RI:
1.57 kristaps 394: fp = i % 2 ? TAG_I : TAG_MAX;
1.8 kristaps 395: break;
1.93 schwarze 396: case MAN_IR:
1.57 kristaps 397: fp = i % 2 ? TAG_MAX : TAG_I;
1.8 kristaps 398: break;
1.93 schwarze 399: case MAN_BR:
1.57 kristaps 400: fp = i % 2 ? TAG_MAX : TAG_B;
1.8 kristaps 401: break;
1.93 schwarze 402: case MAN_RB:
1.57 kristaps 403: fp = i % 2 ? TAG_B : TAG_MAX;
1.8 kristaps 404: break;
405: default:
406: abort();
407: }
408:
409: if (i)
410: h->flags |= HTML_NOSPACE;
411:
1.57 kristaps 412: if (TAG_MAX != fp)
1.122 ! schwarze 413: t = print_otag(h, fp, "");
1.57 kristaps 414:
1.89 schwarze 415: print_man_node(man, nn, mh, h);
1.57 kristaps 416:
417: if (t)
418: print_tagq(h, t);
1.8 kristaps 419: }
420:
1.78 kristaps 421: if (savelit)
422: mh->fl |= MANH_LITERAL;
423:
1.119 schwarze 424: return 0;
1.8 kristaps 425: }
426:
427: static int
1.56 kristaps 428: man_SM_pre(MAN_ARGS)
1.8 kristaps 429: {
1.122 ! schwarze 430: print_otag(h, TAG_SMALL, "");
1.56 kristaps 431: if (MAN_SB == n->tok)
1.122 ! schwarze 432: print_otag(h, TAG_B, "");
1.119 schwarze 433: return 1;
1.8 kristaps 434: }
435:
436: static int
1.4 kristaps 437: man_SS_pre(MAN_ARGS)
438: {
1.113 schwarze 439: if (n->type == ROFFT_BLOCK) {
1.76 kristaps 440: mh->fl &= ~MANH_LITERAL;
1.122 ! schwarze 441: print_otag(h, TAG_DIV, "c", "subsection");
1.119 schwarze 442: return 1;
1.113 schwarze 443: } else if (n->type == ROFFT_BODY)
1.119 schwarze 444: return 1;
1.4 kristaps 445:
1.122 ! schwarze 446: print_otag(h, TAG_H2, "");
1.119 schwarze 447: return 1;
1.4 kristaps 448: }
449:
450: static int
451: man_PP_pre(MAN_ARGS)
452: {
453:
1.113 schwarze 454: if (n->type == ROFFT_HEAD)
1.119 schwarze 455: return 0;
1.113 schwarze 456: else if (n->type == ROFFT_BLOCK)
1.74 kristaps 457: print_bvspace(h, n);
1.47 kristaps 458:
1.119 schwarze 459: return 1;
1.5 kristaps 460: }
461:
462: static int
463: man_IP_pre(MAN_ARGS)
464: {
1.114 schwarze 465: const struct roff_node *nn;
1.5 kristaps 466:
1.113 schwarze 467: if (n->type == ROFFT_BODY) {
1.122 ! schwarze 468: print_otag(h, TAG_DD, "");
1.119 schwarze 469: return 1;
1.113 schwarze 470: } else if (n->type != ROFFT_HEAD) {
1.122 ! schwarze 471: print_otag(h, TAG_DL, "");
1.119 schwarze 472: return 1;
1.6 kristaps 473: }
474:
1.78 kristaps 475: /* FIXME: width specification. */
476:
1.122 ! schwarze 477: print_otag(h, TAG_DT, "");
1.6 kristaps 478:
1.59 schwarze 479: /* For IP, only print the first header element. */
1.7 kristaps 480:
1.59 schwarze 481: if (MAN_IP == n->tok && n->child)
1.89 schwarze 482: print_man_node(man, n->child, mh, h);
1.27 kristaps 483:
1.59 schwarze 484: /* For TP, only print next-line header elements. */
1.6 kristaps 485:
1.91 schwarze 486: if (MAN_TP == n->tok) {
487: nn = n->child;
1.121 schwarze 488: while (NULL != nn && 0 == (NODE_LINE & nn->flags))
1.91 schwarze 489: nn = nn->next;
490: while (NULL != nn) {
491: print_man_node(man, nn, mh, h);
492: nn = nn->next;
493: }
494: }
1.6 kristaps 495:
1.119 schwarze 496: return 0;
1.6 kristaps 497: }
498:
499: static int
500: man_HP_pre(MAN_ARGS)
501: {
1.122 ! schwarze 502: struct roffsu sum, sui;
1.114 schwarze 503: const struct roff_node *np;
1.6 kristaps 504:
1.113 schwarze 505: if (n->type == ROFFT_HEAD)
1.119 schwarze 506: return 0;
1.113 schwarze 507: else if (n->type != ROFFT_BLOCK)
1.119 schwarze 508: return 1;
1.72 kristaps 509:
1.77 kristaps 510: np = n->head->child;
1.6 kristaps 511:
1.122 ! schwarze 512: if (np == NULL || !a2width(np, &sum))
! 513: SCALE_HS_INIT(&sum, INDENT);
1.6 kristaps 514:
1.122 ! schwarze 515: sui.unit = sum.unit;
! 516: sui.scale = -sum.scale;
1.5 kristaps 517:
1.77 kristaps 518: print_bvspace(h, n);
1.122 ! schwarze 519: print_otag(h, TAG_DIV, "csului", "spacer", &sum, &sui);
1.119 schwarze 520: return 1;
1.4 kristaps 521: }
1.86 kristaps 522:
523: static int
524: man_OP_pre(MAN_ARGS)
525: {
526: struct tag *tt;
527:
528: print_text(h, "[");
529: h->flags |= HTML_NOSPACE;
1.122 ! schwarze 530: tt = print_otag(h, TAG_SPAN, "c", "opt");
1.86 kristaps 531:
532: if (NULL != (n = n->child)) {
1.122 ! schwarze 533: print_otag(h, TAG_B, "");
1.86 kristaps 534: print_text(h, n->string);
535: }
536:
537: print_stagq(h, tt);
538:
539: if (NULL != n && NULL != n->next) {
1.122 ! schwarze 540: print_otag(h, TAG_I, "");
1.86 kristaps 541: print_text(h, n->next->string);
542: }
543:
544: print_stagq(h, tt);
545: h->flags |= HTML_NOSPACE;
546: print_text(h, "]");
1.119 schwarze 547: return 0;
1.86 kristaps 548: }
549:
1.8 kristaps 550: static int
551: man_B_pre(MAN_ARGS)
552: {
1.122 ! schwarze 553: print_otag(h, TAG_B, "");
1.119 schwarze 554: return 1;
1.8 kristaps 555: }
556:
557: static int
558: man_I_pre(MAN_ARGS)
559: {
1.122 ! schwarze 560: print_otag(h, TAG_I, "");
1.119 schwarze 561: return 1;
1.45 kristaps 562: }
563:
564: static int
565: man_literal_pre(MAN_ARGS)
566: {
567:
1.88 schwarze 568: if (MAN_fi == n->tok || MAN_EE == n->tok) {
1.122 ! schwarze 569: print_otag(h, TAG_BR, "");
1.78 kristaps 570: mh->fl &= ~MANH_LITERAL;
571: } else
1.45 kristaps 572: mh->fl |= MANH_LITERAL;
573:
1.119 schwarze 574: return 0;
1.45 kristaps 575: }
576:
577: static int
578: man_in_pre(MAN_ARGS)
579: {
1.122 ! schwarze 580: print_otag(h, TAG_BR, "");
1.119 schwarze 581: return 0;
1.8 kristaps 582: }
583:
584: static int
585: man_ign_pre(MAN_ARGS)
586: {
587:
1.119 schwarze 588: return 0;
1.8 kristaps 589: }
1.9 kristaps 590:
591: static int
592: man_RS_pre(MAN_ARGS)
593: {
594: struct roffsu su;
595:
1.113 schwarze 596: if (n->type == ROFFT_HEAD)
1.119 schwarze 597: return 0;
1.113 schwarze 598: else if (n->type == ROFFT_BODY)
1.119 schwarze 599: return 1;
1.9 kristaps 600:
601: SCALE_HS_INIT(&su, INDENT);
1.56 kristaps 602: if (n->head->child)
1.9 kristaps 603: a2width(n->head->child, &su);
604:
1.122 ! schwarze 605: print_otag(h, TAG_DIV, "sul", &su);
1.119 schwarze 606: return 1;
1.90 schwarze 607: }
608:
609: static int
610: man_UR_pre(MAN_ARGS)
611: {
612: n = n->child;
1.113 schwarze 613: assert(n->type == ROFFT_HEAD);
1.120 schwarze 614: if (n->child != NULL) {
1.113 schwarze 615: assert(n->child->type == ROFFT_TEXT);
1.122 ! schwarze 616: print_otag(h, TAG_A, "ch", "link-ext", n->child->string);
1.90 schwarze 617: }
618:
1.113 schwarze 619: assert(n->next->type == ROFFT_BODY);
1.120 schwarze 620: if (n->next->child != NULL)
1.90 schwarze 621: n = n->next;
622:
623: print_man_nodelist(man, n->child, mh, h);
624:
1.119 schwarze 625: return 0;
1.9 kristaps 626: }
CVSweb