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