Annotation of src/usr.bin/mandoc/man_html.c, Revision 1.108
1.108 ! schwarze 1: /* $OpenBSD: man_html.c,v 1.107 2018/08/16 23:40:19 schwarze Exp $ */
1.1 schwarze 2: /*
1.56 schwarze 3: * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
1.100 schwarze 4: * Copyright (c) 2013,2014,2015,2017,2018 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: *
1.66 schwarze 10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1.1 schwarze 11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1.66 schwarze 12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1.1 schwarze 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.97 schwarze 27: #include "mandoc.h"
1.66 schwarze 28: #include "roff.h"
1.58 schwarze 29: #include "man.h"
1.1 schwarze 30: #include "out.h"
31: #include "html.h"
32: #include "main.h"
33:
1.2 schwarze 34: /* FIXME: have PD set the default vspace width. */
1.1 schwarze 35:
1.68 schwarze 36: #define MAN_ARGS const struct roff_meta *man, \
1.67 schwarze 37: const struct roff_node *n, \
1.1 schwarze 38: struct html *h
39:
1.108 ! schwarze 40: struct man_html_act {
1.1 schwarze 41: int (*pre)(MAN_ARGS);
42: int (*post)(MAN_ARGS);
43: };
44:
1.52 schwarze 45: static void print_bvspace(struct html *,
1.67 schwarze 46: const struct roff_node *);
1.100 schwarze 47: static void print_man_head(const struct roff_meta *,
48: struct html *);
1.1 schwarze 49: static void print_man_nodelist(MAN_ARGS);
50: static void print_man_node(MAN_ARGS);
1.85 schwarze 51: static int fillmode(struct html *, int);
1.1 schwarze 52: static int man_B_pre(MAN_ARGS);
53: static int man_HP_pre(MAN_ARGS);
1.46 schwarze 54: static int man_IP_pre(MAN_ARGS);
1.1 schwarze 55: static int man_I_pre(MAN_ARGS);
1.46 schwarze 56: static int man_OP_pre(MAN_ARGS);
1.1 schwarze 57: static int man_PP_pre(MAN_ARGS);
58: static int man_RS_pre(MAN_ARGS);
59: static int man_SH_pre(MAN_ARGS);
60: static int man_SM_pre(MAN_ARGS);
61: static int man_SS_pre(MAN_ARGS);
1.49 schwarze 62: static int man_UR_pre(MAN_ARGS);
1.46 schwarze 63: static int man_alt_pre(MAN_ARGS);
64: static int man_ign_pre(MAN_ARGS);
65: static int man_in_pre(MAN_ARGS);
1.100 schwarze 66: static void man_root_post(const struct roff_meta *,
67: struct html *);
68: static void man_root_pre(const struct roff_meta *,
69: struct html *);
1.1 schwarze 70:
1.108 ! schwarze 71: static const struct man_html_act man_html_acts[MAN_MAX - MAN_TH] = {
1.1 schwarze 72: { NULL, NULL }, /* TH */
73: { man_SH_pre, NULL }, /* SH */
74: { man_SS_pre, NULL }, /* SS */
75: { man_IP_pre, NULL }, /* TP */
1.107 schwarze 76: { man_IP_pre, NULL }, /* TQ */
1.1 schwarze 77: { man_PP_pre, NULL }, /* LP */
78: { man_PP_pre, NULL }, /* PP */
79: { man_PP_pre, NULL }, /* P */
80: { man_IP_pre, NULL }, /* IP */
1.52 schwarze 81: { man_HP_pre, NULL }, /* HP */
1.1 schwarze 82: { man_SM_pre, NULL }, /* SM */
1.26 schwarze 83: { man_SM_pre, NULL }, /* SB */
1.1 schwarze 84: { man_alt_pre, NULL }, /* BI */
85: { man_alt_pre, NULL }, /* IB */
86: { man_alt_pre, NULL }, /* BR */
87: { man_alt_pre, NULL }, /* RB */
88: { NULL, NULL }, /* R */
89: { man_B_pre, NULL }, /* B */
90: { man_I_pre, NULL }, /* I */
91: { man_alt_pre, NULL }, /* IR */
92: { man_alt_pre, NULL }, /* RI */
1.85 schwarze 93: { NULL, NULL }, /* nf */
94: { NULL, NULL }, /* fi */
1.1 schwarze 95: { NULL, NULL }, /* RE */
96: { man_RS_pre, NULL }, /* RS */
97: { man_ign_pre, NULL }, /* DT */
98: { man_ign_pre, NULL }, /* UC */
1.2 schwarze 99: { man_ign_pre, NULL }, /* PD */
1.13 schwarze 100: { man_ign_pre, NULL }, /* AT */
1.18 schwarze 101: { man_in_pre, NULL }, /* in */
1.46 schwarze 102: { man_OP_pre, NULL }, /* OP */
1.85 schwarze 103: { NULL, NULL }, /* EX */
104: { NULL, NULL }, /* EE */
1.49 schwarze 105: { man_UR_pre, NULL }, /* UR */
106: { NULL, NULL }, /* UE */
1.98 bentley 107: { man_UR_pre, NULL }, /* MT */
108: { NULL, NULL }, /* ME */
1.1 schwarze 109: };
110:
1.52 schwarze 111:
1.39 schwarze 112: /*
113: * Printing leading vertical space before a block.
114: * This is used for the paragraph macros.
115: * The rules are pretty simple, since there's very little nesting going
116: * on here. Basically, if we're the first within another block (SS/SH),
117: * then don't emit vertical space. If we are (RS), then do. If not the
118: * first, print it.
119: */
120: static void
1.67 schwarze 121: print_bvspace(struct html *h, const struct roff_node *n)
1.39 schwarze 122: {
123:
124: if (n->body && n->body->child)
1.66 schwarze 125: if (n->body->child->type == ROFFT_TBL)
1.39 schwarze 126: return;
127:
1.66 schwarze 128: if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS)
1.39 schwarze 129: if (NULL == n->prev)
130: return;
131:
1.56 schwarze 132: print_paragraph(h);
1.39 schwarze 133: }
1.1 schwarze 134:
135: void
1.69 schwarze 136: html_man(void *arg, const struct roff_man *man)
1.1 schwarze 137: {
1.100 schwarze 138: struct html *h;
139: struct roff_node *n;
140: struct tag *t;
1.43 schwarze 141:
1.70 schwarze 142: h = (struct html *)arg;
1.100 schwarze 143: n = man->first->child;
1.1 schwarze 144:
1.79 schwarze 145: if ((h->oflags & HTML_FRAGMENT) == 0) {
1.43 schwarze 146: print_gen_decls(h);
1.79 schwarze 147: print_otag(h, TAG_HTML, "");
1.100 schwarze 148: if (n->type == ROFFT_COMMENT)
149: print_gen_comment(h, n);
1.79 schwarze 150: t = print_otag(h, TAG_HEAD, "");
1.100 schwarze 151: print_man_head(&man->meta, h);
1.79 schwarze 152: print_tagq(h, t);
1.75 schwarze 153: print_otag(h, TAG_BODY, "");
1.79 schwarze 154: }
1.25 schwarze 155:
1.100 schwarze 156: man_root_pre(&man->meta, h);
1.80 schwarze 157: t = print_otag(h, TAG_DIV, "c", "manual-text");
1.100 schwarze 158: print_man_nodelist(&man->meta, n, h);
1.80 schwarze 159: print_tagq(h, t);
1.100 schwarze 160: man_root_post(&man->meta, h);
1.79 schwarze 161: print_tagq(h, NULL);
1.1 schwarze 162: }
163:
164: static void
1.100 schwarze 165: print_man_head(const struct roff_meta *man, struct html *h)
1.1 schwarze 166: {
1.76 schwarze 167: char *cp;
1.1 schwarze 168:
169: print_gen_head(h);
1.76 schwarze 170: mandoc_asprintf(&cp, "%s(%s)", man->title, man->msec);
1.75 schwarze 171: print_otag(h, TAG_TITLE, "");
1.76 schwarze 172: print_text(h, cp);
173: free(cp);
1.1 schwarze 174: }
175:
176: static void
177: print_man_nodelist(MAN_ARGS)
178: {
179:
1.63 schwarze 180: while (n != NULL) {
1.85 schwarze 181: print_man_node(man, n, h);
1.63 schwarze 182: n = n->next;
183: }
1.1 schwarze 184: }
185:
186: static void
187: print_man_node(MAN_ARGS)
188: {
1.85 schwarze 189: static int want_fillmode = MAN_fi;
190: static int save_fillmode;
191:
192: struct tag *t;
1.1 schwarze 193: int child;
194:
1.85 schwarze 195: /*
196: * Handle fill mode switch requests up front,
197: * they would just cause trouble in the subsequent code.
198: */
199:
200: switch (n->tok) {
201: case MAN_nf:
202: case MAN_EX:
203: want_fillmode = MAN_nf;
204: return;
205: case MAN_fi:
206: case MAN_EE:
207: want_fillmode = MAN_fi;
208: if (fillmode(h, 0) == MAN_fi)
209: print_otag(h, TAG_BR, "");
210: return;
211: default:
212: break;
213: }
214:
215: /* Set up fill mode for the upcoming node. */
1.1 schwarze 216:
217: switch (n->type) {
1.85 schwarze 218: case ROFFT_BLOCK:
219: save_fillmode = 0;
220: /* Some block macros suspend or cancel .nf. */
221: switch (n->tok) {
222: case MAN_TP: /* Tagged paragraphs */
223: case MAN_IP: /* temporarily disable .nf */
224: case MAN_HP: /* for the head. */
225: save_fillmode = want_fillmode;
226: /* FALLTHROUGH */
227: case MAN_SH: /* Section headers */
228: case MAN_SS: /* permanently cancel .nf. */
229: want_fillmode = MAN_fi;
230: /* FALLTHROUGH */
231: case MAN_PP: /* These have no head. */
232: case MAN_LP: /* They will simply */
233: case MAN_P: /* reopen .nf in the body. */
234: case MAN_RS:
235: case MAN_UR:
1.98 bentley 236: case MAN_MT:
1.85 schwarze 237: fillmode(h, MAN_fi);
238: break;
239: default:
240: break;
241: }
242: break;
243: case ROFFT_TBL:
244: fillmode(h, MAN_fi);
245: break;
246: case ROFFT_ELEM:
247: /*
248: * Some in-line macros produce tags and/or text
249: * in the handler, so they require fill mode to be
250: * configured up front just like for text nodes.
251: * For the others, keep the traditional approach
252: * of doing the same, for now.
253: */
254: fillmode(h, want_fillmode);
255: break;
1.66 schwarze 256: case ROFFT_TEXT:
1.85 schwarze 257: if (fillmode(h, want_fillmode) == MAN_fi &&
258: want_fillmode == MAN_fi &&
1.95 schwarze 259: n->flags & NODE_LINE && *n->string == ' ' &&
260: (h->flags & HTML_NONEWLINE) == 0)
1.75 schwarze 261: print_otag(h, TAG_BR, "");
1.85 schwarze 262: if (*n->string != '\0')
263: break;
264: print_paragraph(h);
1.99 schwarze 265: return;
266: case ROFFT_COMMENT:
1.85 schwarze 267: return;
268: default:
269: break;
270: }
271:
272: /* Produce output for this node. */
273:
274: child = 1;
275: switch (n->type) {
276: case ROFFT_TEXT:
277: t = h->tag;
1.1 schwarze 278: print_text(h, n->string);
1.83 schwarze 279: break;
1.66 schwarze 280: case ROFFT_EQN:
1.85 schwarze 281: t = h->tag;
1.41 schwarze 282: print_eqn(h, n->eqn);
1.37 schwarze 283: break;
1.66 schwarze 284: case ROFFT_TBL:
1.33 schwarze 285: /*
286: * This will take care of initialising all of the table
287: * state data for the first table, then tearing it down
288: * for the last one.
289: */
1.29 schwarze 290: print_tbl(h, n->span);
1.32 schwarze 291: return;
1.1 schwarze 292: default:
1.52 schwarze 293: /*
1.4 schwarze 294: * Close out scope of font prior to opening a macro
1.33 schwarze 295: * scope.
1.4 schwarze 296: */
1.27 schwarze 297: if (HTMLFONT_NONE != h->metac) {
298: h->metal = h->metac;
299: h->metac = HTMLFONT_NONE;
1.33 schwarze 300: }
301:
302: /*
303: * Close out the current table, if it's open, and unset
304: * the "meta" table state. This will be reopened on the
305: * next table element.
306: */
1.85 schwarze 307: if (h->tblt)
1.33 schwarze 308: print_tblclose(h);
1.85 schwarze 309:
310: t = h->tag;
1.90 schwarze 311: if (n->tok < ROFF_MAX) {
1.91 schwarze 312: roff_html_pre(h, n);
1.94 schwarze 313: child = 0;
1.90 schwarze 314: break;
315: }
316:
317: assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
1.108 ! schwarze 318: if (man_html_acts[n->tok - MAN_TH].pre != NULL)
! 319: child = (*man_html_acts[n->tok - MAN_TH].pre)(man,
! 320: n, h);
1.85 schwarze 321:
322: /* Some block macros resume .nf in the body. */
323: if (save_fillmode && n->type == ROFFT_BODY)
324: want_fillmode = save_fillmode;
325:
1.1 schwarze 326: break;
327: }
328:
329: if (child && n->child)
1.85 schwarze 330: print_man_nodelist(man, n->child, h);
1.1 schwarze 331:
1.4 schwarze 332: /* This will automatically close out any font scope. */
1.85 schwarze 333: print_stagq(h, t);
334:
335: if (fillmode(h, 0) == MAN_nf &&
336: n->next != NULL && n->next->flags & NODE_LINE)
337: print_endline(h);
338: }
339:
340: /*
341: * MAN_nf switches to no-fill mode, MAN_fi to fill mode.
342: * Other arguments do not switch.
343: * The old mode is returned.
344: */
345: static int
346: fillmode(struct html *h, int want)
347: {
348: struct tag *pre;
349: int had;
1.1 schwarze 350:
1.85 schwarze 351: for (pre = h->tag; pre != NULL; pre = pre->next)
352: if (pre->tag == TAG_PRE)
353: break;
354:
355: had = pre == NULL ? MAN_fi : MAN_nf;
1.83 schwarze 356:
1.85 schwarze 357: if (want && want != had) {
358: if (want == MAN_nf)
359: print_otag(h, TAG_PRE, "");
360: else
361: print_tagq(h, pre);
362: }
363: return had;
1.1 schwarze 364: }
365:
1.38 schwarze 366: static void
1.100 schwarze 367: man_root_pre(const struct roff_meta *man, struct html *h)
1.1 schwarze 368: {
369: struct tag *t, *tt;
1.53 schwarze 370: char *title;
1.1 schwarze 371:
1.48 schwarze 372: assert(man->title);
373: assert(man->msec);
1.53 schwarze 374: mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.1 schwarze 375:
1.75 schwarze 376: t = print_otag(h, TAG_TABLE, "c", "head");
377: tt = print_otag(h, TAG_TR, "");
1.1 schwarze 378:
1.75 schwarze 379: print_otag(h, TAG_TD, "c", "head-ltitle");
1.1 schwarze 380: print_text(h, title);
381: print_stagq(h, tt);
382:
1.75 schwarze 383: print_otag(h, TAG_TD, "c", "head-vol");
1.54 schwarze 384: if (NULL != man->vol)
385: print_text(h, man->vol);
1.1 schwarze 386: print_stagq(h, tt);
387:
1.75 schwarze 388: print_otag(h, TAG_TD, "c", "head-rtitle");
1.1 schwarze 389: print_text(h, title);
390: print_tagq(h, t);
1.53 schwarze 391: free(title);
1.1 schwarze 392: }
393:
394: static void
1.100 schwarze 395: man_root_post(const struct roff_meta *man, struct html *h)
1.1 schwarze 396: {
397: struct tag *t, *tt;
398:
1.75 schwarze 399: t = print_otag(h, TAG_TABLE, "c", "foot");
400: tt = print_otag(h, TAG_TR, "");
1.25 schwarze 401:
1.75 schwarze 402: print_otag(h, TAG_TD, "c", "foot-date");
1.48 schwarze 403: print_text(h, man->date);
1.1 schwarze 404: print_stagq(h, tt);
405:
1.75 schwarze 406: print_otag(h, TAG_TD, "c", "foot-os");
1.68 schwarze 407: if (man->os)
408: print_text(h, man->os);
1.1 schwarze 409: print_tagq(h, t);
410: }
411:
412: static int
413: man_SH_pre(MAN_ARGS)
414: {
1.87 schwarze 415: char *id;
416:
417: if (n->type == ROFFT_HEAD) {
1.103 schwarze 418: id = html_make_id(n, 1);
1.87 schwarze 419: print_otag(h, TAG_H1, "cTi", "Sh", id);
1.88 schwarze 420: if (id != NULL)
1.101 schwarze 421: print_otag(h, TAG_A, "chR", "permalink", id);
1.87 schwarze 422: }
1.72 schwarze 423: return 1;
1.1 schwarze 424: }
425:
426: static int
427: man_alt_pre(MAN_ARGS)
428: {
1.67 schwarze 429: const struct roff_node *nn;
1.83 schwarze 430: int i;
1.27 schwarze 431: enum htmltag fp;
432: struct tag *t;
1.1 schwarze 433:
434: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
435: switch (n->tok) {
1.52 schwarze 436: case MAN_BI:
1.27 schwarze 437: fp = i % 2 ? TAG_I : TAG_B;
1.1 schwarze 438: break;
1.52 schwarze 439: case MAN_IB:
1.27 schwarze 440: fp = i % 2 ? TAG_B : TAG_I;
1.1 schwarze 441: break;
1.52 schwarze 442: case MAN_RI:
1.27 schwarze 443: fp = i % 2 ? TAG_I : TAG_MAX;
1.1 schwarze 444: break;
1.52 schwarze 445: case MAN_IR:
1.27 schwarze 446: fp = i % 2 ? TAG_MAX : TAG_I;
1.1 schwarze 447: break;
1.52 schwarze 448: case MAN_BR:
1.27 schwarze 449: fp = i % 2 ? TAG_MAX : TAG_B;
1.1 schwarze 450: break;
1.52 schwarze 451: case MAN_RB:
1.27 schwarze 452: fp = i % 2 ? TAG_B : TAG_MAX;
1.1 schwarze 453: break;
454: default:
455: abort();
456: }
457:
458: if (i)
459: h->flags |= HTML_NOSPACE;
460:
1.83 schwarze 461: if (fp != TAG_MAX)
1.75 schwarze 462: t = print_otag(h, fp, "");
1.27 schwarze 463:
1.83 schwarze 464: print_text(h, nn->string);
1.27 schwarze 465:
1.83 schwarze 466: if (fp != TAG_MAX)
1.27 schwarze 467: print_tagq(h, t);
1.1 schwarze 468: }
1.72 schwarze 469: return 0;
1.1 schwarze 470: }
471:
472: static int
1.26 schwarze 473: man_SM_pre(MAN_ARGS)
1.1 schwarze 474: {
1.75 schwarze 475: print_otag(h, TAG_SMALL, "");
1.26 schwarze 476: if (MAN_SB == n->tok)
1.75 schwarze 477: print_otag(h, TAG_B, "");
1.72 schwarze 478: return 1;
1.1 schwarze 479: }
480:
481: static int
482: man_SS_pre(MAN_ARGS)
483: {
1.87 schwarze 484: char *id;
485:
486: if (n->type == ROFFT_HEAD) {
1.103 schwarze 487: id = html_make_id(n, 1);
1.87 schwarze 488: print_otag(h, TAG_H2, "cTi", "Ss", id);
1.88 schwarze 489: if (id != NULL)
1.101 schwarze 490: print_otag(h, TAG_A, "chR", "permalink", id);
1.87 schwarze 491: }
1.72 schwarze 492: return 1;
1.1 schwarze 493: }
494:
495: static int
496: man_PP_pre(MAN_ARGS)
497: {
498:
1.66 schwarze 499: if (n->type == ROFFT_HEAD)
1.72 schwarze 500: return 0;
1.66 schwarze 501: else if (n->type == ROFFT_BLOCK)
1.39 schwarze 502: print_bvspace(h, n);
1.22 schwarze 503:
1.72 schwarze 504: return 1;
1.1 schwarze 505: }
506:
507: static int
508: man_IP_pre(MAN_ARGS)
509: {
1.67 schwarze 510: const struct roff_node *nn;
1.1 schwarze 511:
1.66 schwarze 512: if (n->type == ROFFT_BODY) {
1.102 schwarze 513: print_otag(h, TAG_DD, "");
1.72 schwarze 514: return 1;
1.66 schwarze 515: } else if (n->type != ROFFT_HEAD) {
1.82 schwarze 516: print_otag(h, TAG_DL, "c", "Bl-tag");
1.72 schwarze 517: return 1;
1.1 schwarze 518: }
519:
1.102 schwarze 520: print_otag(h, TAG_DT, "");
1.1 schwarze 521:
1.107 schwarze 522: switch(n->tok) {
523: case MAN_IP: /* Only print the first header element. */
524: if (n->child != NULL)
525: print_man_node(man, n->child, h);
526: break;
527: case MAN_TP: /* Only print next-line header elements. */
528: case MAN_TQ:
1.50 schwarze 529: nn = n->child;
1.107 schwarze 530: while (nn != NULL && (NODE_LINE & nn->flags) == 0)
1.50 schwarze 531: nn = nn->next;
1.107 schwarze 532: while (nn != NULL) {
1.85 schwarze 533: print_man_node(man, nn, h);
1.50 schwarze 534: nn = nn->next;
535: }
1.107 schwarze 536: break;
537: default:
538: abort();
1.50 schwarze 539: }
1.1 schwarze 540:
1.72 schwarze 541: return 0;
1.1 schwarze 542: }
543:
544: static int
545: man_HP_pre(MAN_ARGS)
546: {
1.66 schwarze 547: if (n->type == ROFFT_HEAD)
1.72 schwarze 548: return 0;
1.38 schwarze 549:
1.104 schwarze 550: if (n->type == ROFFT_BLOCK) {
551: print_bvspace(h, n);
552: print_otag(h, TAG_DIV, "c", "HP");
553: }
1.72 schwarze 554: return 1;
1.1 schwarze 555: }
1.46 schwarze 556:
557: static int
558: man_OP_pre(MAN_ARGS)
559: {
560: struct tag *tt;
561:
562: print_text(h, "[");
563: h->flags |= HTML_NOSPACE;
1.81 schwarze 564: tt = print_otag(h, TAG_SPAN, "c", "Op");
1.46 schwarze 565:
566: if (NULL != (n = n->child)) {
1.75 schwarze 567: print_otag(h, TAG_B, "");
1.46 schwarze 568: print_text(h, n->string);
569: }
570:
571: print_stagq(h, tt);
572:
573: if (NULL != n && NULL != n->next) {
1.75 schwarze 574: print_otag(h, TAG_I, "");
1.46 schwarze 575: print_text(h, n->next->string);
576: }
577:
578: print_stagq(h, tt);
579: h->flags |= HTML_NOSPACE;
580: print_text(h, "]");
1.72 schwarze 581: return 0;
1.46 schwarze 582: }
583:
1.1 schwarze 584: static int
585: man_B_pre(MAN_ARGS)
586: {
1.75 schwarze 587: print_otag(h, TAG_B, "");
1.72 schwarze 588: return 1;
1.1 schwarze 589: }
590:
591: static int
592: man_I_pre(MAN_ARGS)
593: {
1.75 schwarze 594: print_otag(h, TAG_I, "");
1.72 schwarze 595: return 1;
1.18 schwarze 596: }
597:
598: static int
599: man_in_pre(MAN_ARGS)
600: {
1.75 schwarze 601: print_otag(h, TAG_BR, "");
1.72 schwarze 602: return 0;
1.1 schwarze 603: }
604:
605: static int
606: man_ign_pre(MAN_ARGS)
607: {
608:
1.72 schwarze 609: return 0;
1.1 schwarze 610: }
611:
612: static int
613: man_RS_pre(MAN_ARGS)
614: {
1.66 schwarze 615: if (n->type == ROFFT_HEAD)
1.72 schwarze 616: return 0;
1.105 schwarze 617: if (n->type == ROFFT_BLOCK)
618: print_otag(h, TAG_DIV, "c", "Bd-indent");
1.72 schwarze 619: return 1;
1.49 schwarze 620: }
621:
622: static int
623: man_UR_pre(MAN_ARGS)
624: {
1.98 bentley 625: char *cp;
1.49 schwarze 626: n = n->child;
1.66 schwarze 627: assert(n->type == ROFFT_HEAD);
1.73 schwarze 628: if (n->child != NULL) {
1.66 schwarze 629: assert(n->child->type == ROFFT_TEXT);
1.98 bentley 630: if (n->tok == MAN_MT) {
631: mandoc_asprintf(&cp, "mailto:%s", n->child->string);
632: print_otag(h, TAG_A, "cTh", "Mt", cp);
633: free(cp);
634: } else
635: print_otag(h, TAG_A, "cTh", "Lk", n->child->string);
1.49 schwarze 636: }
637:
1.66 schwarze 638: assert(n->next->type == ROFFT_BODY);
1.73 schwarze 639: if (n->next->child != NULL)
1.49 schwarze 640: n = n->next;
641:
1.85 schwarze 642: print_man_nodelist(man, n->child, h);
1.49 schwarze 643:
1.72 schwarze 644: return 0;
1.1 schwarze 645: }