Annotation of mandoc/man_html.c, Revision 1.125
1.125 ! schwarze 1: /* $Id: man_html.c,v 1.124 2017/01/18 19:22:22 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);
169: }
170:
171: static void
172: print_man_head(MAN_ARGS)
173: {
1.123 schwarze 174: char *cp;
1.3 kristaps 175:
176: print_gen_head(h);
1.123 schwarze 177: mandoc_asprintf(&cp, "%s(%s)", man->title, man->msec);
1.122 schwarze 178: print_otag(h, TAG_TITLE, "");
1.123 schwarze 179: print_text(h, cp);
180: free(cp);
1.1 kristaps 181: }
1.4 kristaps 182:
183: static void
184: print_man_nodelist(MAN_ARGS)
185: {
186:
1.110 schwarze 187: while (n != NULL) {
188: print_man_node(man, n, mh, h);
189: n = n->next;
190: }
1.4 kristaps 191: }
192:
193: static void
194: print_man_node(MAN_ARGS)
195: {
196: int child;
197: struct tag *t;
198:
199: child = 1;
1.14 kristaps 200: t = h->tags.head;
1.4 kristaps 201:
202: switch (n->type) {
1.113 schwarze 203: case ROFFT_ROOT:
1.89 schwarze 204: man_root_pre(man, n, mh, h);
1.4 kristaps 205: break;
1.113 schwarze 206: case ROFFT_TEXT:
1.63 kristaps 207: if ('\0' == *n->string) {
1.103 kristaps 208: print_paragraph(h);
1.63 kristaps 209: return;
1.78 kristaps 210: }
1.121 schwarze 211: if (n->flags & NODE_LINE && (*n->string == ' ' ||
1.106 schwarze 212: (n->prev != NULL && mh->fl & MANH_LITERAL &&
213: ! (h->flags & HTML_NONEWLINE))))
1.122 schwarze 214: print_otag(h, TAG_BR, "");
1.4 kristaps 215: print_text(h, n->string);
1.68 kristaps 216: return;
1.113 schwarze 217: case ROFFT_EQN:
1.80 kristaps 218: print_eqn(h, n->eqn);
1.69 kristaps 219: break;
1.113 schwarze 220: case ROFFT_TBL:
1.66 kristaps 221: /*
222: * This will take care of initialising all of the table
223: * state data for the first table, then tearing it down
224: * for the last one.
225: */
1.60 kristaps 226: print_tbl(h, n->span);
1.64 kristaps 227: return;
1.4 kristaps 228: default:
1.93 schwarze 229: /*
1.21 kristaps 230: * Close out scope of font prior to opening a macro
1.66 kristaps 231: * scope.
1.21 kristaps 232: */
1.57 kristaps 233: if (HTMLFONT_NONE != h->metac) {
234: h->metal = h->metac;
235: h->metac = HTMLFONT_NONE;
1.66 kristaps 236: }
237:
238: /*
239: * Close out the current table, if it's open, and unset
240: * the "meta" table state. This will be reopened on the
241: * next table element.
242: */
243: if (h->tblt) {
244: print_tblclose(h);
245: t = h->tags.head;
1.20 kristaps 246: }
1.4 kristaps 247: if (mans[n->tok].pre)
1.89 schwarze 248: child = (*mans[n->tok].pre)(man, n, mh, h);
1.4 kristaps 249: break;
250: }
251:
1.21 kristaps 252: if (child && n->child)
1.89 schwarze 253: print_man_nodelist(man, n->child, mh, h);
1.21 kristaps 254:
1.24 kristaps 255: /* This will automatically close out any font scope. */
1.4 kristaps 256: print_stagq(h, t);
257:
1.61 kristaps 258: switch (n->type) {
1.113 schwarze 259: case ROFFT_ROOT:
1.89 schwarze 260: man_root_post(man, n, mh, h);
1.69 kristaps 261: break;
1.113 schwarze 262: case ROFFT_EQN:
1.61 kristaps 263: break;
264: default:
265: if (mans[n->tok].post)
1.89 schwarze 266: (*mans[n->tok].post)(man, n, mh, h);
1.61 kristaps 267: break;
268: }
1.4 kristaps 269: }
270:
1.5 kristaps 271: static int
1.114 schwarze 272: a2width(const struct roff_node *n, struct roffsu *su)
1.5 kristaps 273: {
274:
1.113 schwarze 275: if (n->type != ROFFT_TEXT)
1.119 schwarze 276: return 0;
1.107 schwarze 277: if (a2roffsu(n->string, su, SCALE_EN))
1.119 schwarze 278: return 1;
1.5 kristaps 279:
1.119 schwarze 280: return 0;
1.5 kristaps 281: }
282:
1.65 kristaps 283: static void
1.4 kristaps 284: man_root_pre(MAN_ARGS)
285: {
286: struct tag *t, *tt;
1.94 schwarze 287: char *title;
1.4 kristaps 288:
1.89 schwarze 289: assert(man->title);
290: assert(man->msec);
1.94 schwarze 291: mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.4 kristaps 292:
1.122 schwarze 293: t = print_otag(h, TAG_TABLE, "c", "head");
294: print_otag(h, TAG_TBODY, "");
295: tt = print_otag(h, TAG_TR, "");
1.4 kristaps 296:
1.122 schwarze 297: print_otag(h, TAG_TD, "c", "head-ltitle");
1.4 kristaps 298: print_text(h, title);
299: print_stagq(h, tt);
300:
1.122 schwarze 301: print_otag(h, TAG_TD, "c", "head-vol");
1.95 schwarze 302: if (NULL != man->vol)
303: print_text(h, man->vol);
1.4 kristaps 304: print_stagq(h, tt);
305:
1.122 schwarze 306: print_otag(h, TAG_TD, "c", "head-rtitle");
1.4 kristaps 307: print_text(h, title);
308: print_tagq(h, t);
1.94 schwarze 309: free(title);
1.4 kristaps 310: }
311:
312: static void
313: man_root_post(MAN_ARGS)
314: {
315: struct tag *t, *tt;
316:
1.122 schwarze 317: t = print_otag(h, TAG_TABLE, "c", "foot");
318: tt = print_otag(h, TAG_TR, "");
1.55 kristaps 319:
1.122 schwarze 320: print_otag(h, TAG_TD, "c", "foot-date");
1.89 schwarze 321: print_text(h, man->date);
1.4 kristaps 322: print_stagq(h, tt);
323:
1.122 schwarze 324: print_otag(h, TAG_TD, "c", "foot-os");
1.115 schwarze 325: if (man->os)
326: print_text(h, man->os);
1.4 kristaps 327: print_tagq(h, t);
328: }
329:
330:
331: static int
332: man_br_pre(MAN_ARGS)
333: {
1.7 kristaps 334: struct roffsu su;
1.4 kristaps 335:
1.7 kristaps 336: SCALE_VS_INIT(&su, 1);
337:
1.49 kristaps 338: if (MAN_sp == n->tok) {
1.75 kristaps 339: if (NULL != (n = n->child))
340: if ( ! a2roffsu(n->string, &su, SCALE_VS))
1.108 schwarze 341: su.scale = 1.0;
1.49 kristaps 342: } else
1.96 schwarze 343: su.scale = 0.0;
1.4 kristaps 344:
1.122 schwarze 345: print_otag(h, TAG_DIV, "suh", &su);
1.24 kristaps 346:
1.16 kristaps 347: /* So the div isn't empty: */
348: print_text(h, "\\~");
349:
1.119 schwarze 350: return 0;
1.4 kristaps 351: }
352:
353: static int
354: man_SH_pre(MAN_ARGS)
355: {
1.113 schwarze 356: if (n->type == ROFFT_BLOCK) {
1.76 kristaps 357: mh->fl &= ~MANH_LITERAL;
1.122 schwarze 358: print_otag(h, TAG_DIV, "c", "section");
1.119 schwarze 359: return 1;
1.113 schwarze 360: } else if (n->type == ROFFT_BODY)
1.119 schwarze 361: return 1;
1.4 kristaps 362:
1.122 schwarze 363: print_otag(h, TAG_H1, "");
1.119 schwarze 364: return 1;
1.4 kristaps 365: }
366:
367: static int
1.8 kristaps 368: man_alt_pre(MAN_ARGS)
369: {
1.114 schwarze 370: const struct roff_node *nn;
1.78 kristaps 371: int i, savelit;
1.57 kristaps 372: enum htmltag fp;
373: struct tag *t;
1.8 kristaps 374:
1.93 schwarze 375: if ((savelit = mh->fl & MANH_LITERAL))
1.122 schwarze 376: print_otag(h, TAG_BR, "");
1.78 kristaps 377:
378: mh->fl &= ~MANH_LITERAL;
379:
1.8 kristaps 380: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.57 kristaps 381: t = NULL;
1.8 kristaps 382: switch (n->tok) {
1.93 schwarze 383: case MAN_BI:
1.57 kristaps 384: fp = i % 2 ? TAG_I : TAG_B;
1.8 kristaps 385: break;
1.93 schwarze 386: case MAN_IB:
1.57 kristaps 387: fp = i % 2 ? TAG_B : TAG_I;
1.8 kristaps 388: break;
1.93 schwarze 389: case MAN_RI:
1.57 kristaps 390: fp = i % 2 ? TAG_I : TAG_MAX;
1.8 kristaps 391: break;
1.93 schwarze 392: case MAN_IR:
1.57 kristaps 393: fp = i % 2 ? TAG_MAX : TAG_I;
1.8 kristaps 394: break;
1.93 schwarze 395: case MAN_BR:
1.57 kristaps 396: fp = i % 2 ? TAG_MAX : TAG_B;
1.8 kristaps 397: break;
1.93 schwarze 398: case MAN_RB:
1.57 kristaps 399: fp = i % 2 ? TAG_B : TAG_MAX;
1.8 kristaps 400: break;
401: default:
402: abort();
403: }
404:
405: if (i)
406: h->flags |= HTML_NOSPACE;
407:
1.57 kristaps 408: if (TAG_MAX != fp)
1.122 schwarze 409: t = print_otag(h, fp, "");
1.57 kristaps 410:
1.89 schwarze 411: print_man_node(man, nn, mh, h);
1.57 kristaps 412:
413: if (t)
414: print_tagq(h, t);
1.8 kristaps 415: }
416:
1.78 kristaps 417: if (savelit)
418: mh->fl |= MANH_LITERAL;
419:
1.119 schwarze 420: return 0;
1.8 kristaps 421: }
422:
423: static int
1.56 kristaps 424: man_SM_pre(MAN_ARGS)
1.8 kristaps 425: {
1.122 schwarze 426: print_otag(h, TAG_SMALL, "");
1.56 kristaps 427: if (MAN_SB == n->tok)
1.122 schwarze 428: print_otag(h, TAG_B, "");
1.119 schwarze 429: return 1;
1.8 kristaps 430: }
431:
432: static int
1.4 kristaps 433: man_SS_pre(MAN_ARGS)
434: {
1.113 schwarze 435: if (n->type == ROFFT_BLOCK) {
1.76 kristaps 436: mh->fl &= ~MANH_LITERAL;
1.122 schwarze 437: print_otag(h, TAG_DIV, "c", "subsection");
1.119 schwarze 438: return 1;
1.113 schwarze 439: } else if (n->type == ROFFT_BODY)
1.119 schwarze 440: return 1;
1.4 kristaps 441:
1.122 schwarze 442: print_otag(h, TAG_H2, "");
1.119 schwarze 443: return 1;
1.4 kristaps 444: }
445:
446: static int
447: man_PP_pre(MAN_ARGS)
448: {
449:
1.113 schwarze 450: if (n->type == ROFFT_HEAD)
1.119 schwarze 451: return 0;
1.113 schwarze 452: else if (n->type == ROFFT_BLOCK)
1.74 kristaps 453: print_bvspace(h, n);
1.47 kristaps 454:
1.119 schwarze 455: return 1;
1.5 kristaps 456: }
457:
458: static int
459: man_IP_pre(MAN_ARGS)
460: {
1.114 schwarze 461: const struct roff_node *nn;
1.5 kristaps 462:
1.113 schwarze 463: if (n->type == ROFFT_BODY) {
1.122 schwarze 464: print_otag(h, TAG_DD, "");
1.119 schwarze 465: return 1;
1.113 schwarze 466: } else if (n->type != ROFFT_HEAD) {
1.122 schwarze 467: print_otag(h, TAG_DL, "");
1.119 schwarze 468: return 1;
1.6 kristaps 469: }
470:
1.78 kristaps 471: /* FIXME: width specification. */
472:
1.122 schwarze 473: print_otag(h, TAG_DT, "");
1.6 kristaps 474:
1.59 schwarze 475: /* For IP, only print the first header element. */
1.7 kristaps 476:
1.59 schwarze 477: if (MAN_IP == n->tok && n->child)
1.89 schwarze 478: print_man_node(man, n->child, mh, h);
1.27 kristaps 479:
1.59 schwarze 480: /* For TP, only print next-line header elements. */
1.6 kristaps 481:
1.91 schwarze 482: if (MAN_TP == n->tok) {
483: nn = n->child;
1.121 schwarze 484: while (NULL != nn && 0 == (NODE_LINE & nn->flags))
1.91 schwarze 485: nn = nn->next;
486: while (NULL != nn) {
487: print_man_node(man, nn, mh, h);
488: nn = nn->next;
489: }
490: }
1.6 kristaps 491:
1.119 schwarze 492: return 0;
1.6 kristaps 493: }
494:
495: static int
496: man_HP_pre(MAN_ARGS)
497: {
1.122 schwarze 498: struct roffsu sum, sui;
1.114 schwarze 499: const struct roff_node *np;
1.6 kristaps 500:
1.113 schwarze 501: if (n->type == ROFFT_HEAD)
1.119 schwarze 502: return 0;
1.113 schwarze 503: else if (n->type != ROFFT_BLOCK)
1.119 schwarze 504: return 1;
1.72 kristaps 505:
1.77 kristaps 506: np = n->head->child;
1.6 kristaps 507:
1.122 schwarze 508: if (np == NULL || !a2width(np, &sum))
509: SCALE_HS_INIT(&sum, INDENT);
1.6 kristaps 510:
1.122 schwarze 511: sui.unit = sum.unit;
512: sui.scale = -sum.scale;
1.5 kristaps 513:
1.77 kristaps 514: print_bvspace(h, n);
1.122 schwarze 515: print_otag(h, TAG_DIV, "csului", "spacer", &sum, &sui);
1.119 schwarze 516: return 1;
1.4 kristaps 517: }
1.86 kristaps 518:
519: static int
520: man_OP_pre(MAN_ARGS)
521: {
522: struct tag *tt;
523:
524: print_text(h, "[");
525: h->flags |= HTML_NOSPACE;
1.122 schwarze 526: tt = print_otag(h, TAG_SPAN, "c", "opt");
1.86 kristaps 527:
528: if (NULL != (n = n->child)) {
1.122 schwarze 529: print_otag(h, TAG_B, "");
1.86 kristaps 530: print_text(h, n->string);
531: }
532:
533: print_stagq(h, tt);
534:
535: if (NULL != n && NULL != n->next) {
1.122 schwarze 536: print_otag(h, TAG_I, "");
1.86 kristaps 537: print_text(h, n->next->string);
538: }
539:
540: print_stagq(h, tt);
541: h->flags |= HTML_NOSPACE;
542: print_text(h, "]");
1.119 schwarze 543: return 0;
1.86 kristaps 544: }
545:
1.8 kristaps 546: static int
547: man_B_pre(MAN_ARGS)
548: {
1.122 schwarze 549: print_otag(h, TAG_B, "");
1.119 schwarze 550: return 1;
1.8 kristaps 551: }
552:
553: static int
554: man_I_pre(MAN_ARGS)
555: {
1.122 schwarze 556: print_otag(h, TAG_I, "");
1.119 schwarze 557: return 1;
1.45 kristaps 558: }
559:
560: static int
561: man_literal_pre(MAN_ARGS)
562: {
563:
1.88 schwarze 564: if (MAN_fi == n->tok || MAN_EE == n->tok) {
1.122 schwarze 565: print_otag(h, TAG_BR, "");
1.78 kristaps 566: mh->fl &= ~MANH_LITERAL;
567: } else
1.45 kristaps 568: mh->fl |= MANH_LITERAL;
569:
1.119 schwarze 570: return 0;
1.45 kristaps 571: }
572:
573: static int
574: man_in_pre(MAN_ARGS)
575: {
1.122 schwarze 576: print_otag(h, TAG_BR, "");
1.119 schwarze 577: return 0;
1.8 kristaps 578: }
579:
580: static int
581: man_ign_pre(MAN_ARGS)
582: {
583:
1.119 schwarze 584: return 0;
1.8 kristaps 585: }
1.9 kristaps 586:
587: static int
588: man_RS_pre(MAN_ARGS)
589: {
590: struct roffsu su;
591:
1.113 schwarze 592: if (n->type == ROFFT_HEAD)
1.119 schwarze 593: return 0;
1.113 schwarze 594: else if (n->type == ROFFT_BODY)
1.119 schwarze 595: return 1;
1.9 kristaps 596:
597: SCALE_HS_INIT(&su, INDENT);
1.56 kristaps 598: if (n->head->child)
1.9 kristaps 599: a2width(n->head->child, &su);
600:
1.122 schwarze 601: print_otag(h, TAG_DIV, "sul", &su);
1.119 schwarze 602: return 1;
1.90 schwarze 603: }
604:
605: static int
606: man_UR_pre(MAN_ARGS)
607: {
608: n = n->child;
1.113 schwarze 609: assert(n->type == ROFFT_HEAD);
1.120 schwarze 610: if (n->child != NULL) {
1.113 schwarze 611: assert(n->child->type == ROFFT_TEXT);
1.122 schwarze 612: print_otag(h, TAG_A, "ch", "link-ext", n->child->string);
1.90 schwarze 613: }
614:
1.113 schwarze 615: assert(n->next->type == ROFFT_BODY);
1.120 schwarze 616: if (n->next->child != NULL)
1.90 schwarze 617: n = n->next;
618:
619: print_man_nodelist(man, n->child, mh, h);
620:
1.119 schwarze 621: return 0;
1.9 kristaps 622: }
CVSweb