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