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