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