Annotation of src/usr.bin/mandoc/man_html.c, Revision 1.109
1.109 ! schwarze 1: /* $OpenBSD: man_html.c,v 1.108 2018/08/17 20:31:52 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.109 ! schwarze 62: static int man_SY_pre(MAN_ARGS);
1.49 schwarze 63: static int man_UR_pre(MAN_ARGS);
1.46 schwarze 64: static int man_alt_pre(MAN_ARGS);
65: static int man_ign_pre(MAN_ARGS);
66: static int man_in_pre(MAN_ARGS);
1.100 schwarze 67: static void man_root_post(const struct roff_meta *,
68: struct html *);
69: static void man_root_pre(const struct roff_meta *,
70: struct html *);
1.1 schwarze 71:
1.108 schwarze 72: static const struct man_html_act man_html_acts[MAN_MAX - MAN_TH] = {
1.1 schwarze 73: { NULL, NULL }, /* TH */
74: { man_SH_pre, NULL }, /* SH */
75: { man_SS_pre, NULL }, /* SS */
76: { man_IP_pre, NULL }, /* TP */
1.107 schwarze 77: { man_IP_pre, NULL }, /* TQ */
1.1 schwarze 78: { man_PP_pre, NULL }, /* LP */
79: { man_PP_pre, NULL }, /* PP */
80: { man_PP_pre, NULL }, /* P */
81: { man_IP_pre, NULL }, /* IP */
1.52 schwarze 82: { man_HP_pre, NULL }, /* HP */
1.1 schwarze 83: { man_SM_pre, NULL }, /* SM */
1.26 schwarze 84: { man_SM_pre, NULL }, /* SB */
1.1 schwarze 85: { man_alt_pre, NULL }, /* BI */
86: { man_alt_pre, NULL }, /* IB */
87: { man_alt_pre, NULL }, /* BR */
88: { man_alt_pre, NULL }, /* RB */
89: { NULL, NULL }, /* R */
90: { man_B_pre, NULL }, /* B */
91: { man_I_pre, NULL }, /* I */
92: { man_alt_pre, NULL }, /* IR */
93: { man_alt_pre, NULL }, /* RI */
1.85 schwarze 94: { NULL, NULL }, /* nf */
95: { NULL, NULL }, /* fi */
1.1 schwarze 96: { NULL, NULL }, /* RE */
97: { man_RS_pre, NULL }, /* RS */
98: { man_ign_pre, NULL }, /* DT */
99: { man_ign_pre, NULL }, /* UC */
1.2 schwarze 100: { man_ign_pre, NULL }, /* PD */
1.13 schwarze 101: { man_ign_pre, NULL }, /* AT */
1.18 schwarze 102: { man_in_pre, NULL }, /* in */
1.109 ! schwarze 103: { man_SY_pre, NULL }, /* SY */
! 104: { NULL, NULL }, /* YS */
1.46 schwarze 105: { man_OP_pre, NULL }, /* OP */
1.85 schwarze 106: { NULL, NULL }, /* EX */
107: { NULL, NULL }, /* EE */
1.49 schwarze 108: { man_UR_pre, NULL }, /* UR */
109: { NULL, NULL }, /* UE */
1.98 bentley 110: { man_UR_pre, NULL }, /* MT */
111: { NULL, NULL }, /* ME */
1.1 schwarze 112: };
113:
1.52 schwarze 114:
1.39 schwarze 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.67 schwarze 124: print_bvspace(struct html *h, const struct roff_node *n)
1.39 schwarze 125: {
126:
127: if (n->body && n->body->child)
1.66 schwarze 128: if (n->body->child->type == ROFFT_TBL)
1.39 schwarze 129: return;
130:
1.66 schwarze 131: if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS)
1.39 schwarze 132: if (NULL == n->prev)
133: return;
134:
1.56 schwarze 135: print_paragraph(h);
1.39 schwarze 136: }
1.1 schwarze 137:
138: void
1.69 schwarze 139: html_man(void *arg, const struct roff_man *man)
1.1 schwarze 140: {
1.100 schwarze 141: struct html *h;
142: struct roff_node *n;
143: struct tag *t;
1.43 schwarze 144:
1.70 schwarze 145: h = (struct html *)arg;
1.100 schwarze 146: n = man->first->child;
1.1 schwarze 147:
1.79 schwarze 148: if ((h->oflags & HTML_FRAGMENT) == 0) {
1.43 schwarze 149: print_gen_decls(h);
1.79 schwarze 150: print_otag(h, TAG_HTML, "");
1.100 schwarze 151: if (n->type == ROFFT_COMMENT)
152: print_gen_comment(h, n);
1.79 schwarze 153: t = print_otag(h, TAG_HEAD, "");
1.100 schwarze 154: print_man_head(&man->meta, h);
1.79 schwarze 155: print_tagq(h, t);
1.75 schwarze 156: print_otag(h, TAG_BODY, "");
1.79 schwarze 157: }
1.25 schwarze 158:
1.100 schwarze 159: man_root_pre(&man->meta, h);
1.80 schwarze 160: t = print_otag(h, TAG_DIV, "c", "manual-text");
1.100 schwarze 161: print_man_nodelist(&man->meta, n, h);
1.80 schwarze 162: print_tagq(h, t);
1.100 schwarze 163: man_root_post(&man->meta, h);
1.79 schwarze 164: print_tagq(h, NULL);
1.1 schwarze 165: }
166:
167: static void
1.100 schwarze 168: print_man_head(const struct roff_meta *man, struct html *h)
1.1 schwarze 169: {
1.76 schwarze 170: char *cp;
1.1 schwarze 171:
172: print_gen_head(h);
1.76 schwarze 173: mandoc_asprintf(&cp, "%s(%s)", man->title, man->msec);
1.75 schwarze 174: print_otag(h, TAG_TITLE, "");
1.76 schwarze 175: print_text(h, cp);
176: free(cp);
1.1 schwarze 177: }
178:
179: static void
180: print_man_nodelist(MAN_ARGS)
181: {
182:
1.63 schwarze 183: while (n != NULL) {
1.85 schwarze 184: print_man_node(man, n, h);
1.63 schwarze 185: n = n->next;
186: }
1.1 schwarze 187: }
188:
189: static void
190: print_man_node(MAN_ARGS)
191: {
1.85 schwarze 192: static int want_fillmode = MAN_fi;
193: static int save_fillmode;
194:
195: struct tag *t;
1.1 schwarze 196: int child;
197:
1.85 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.1 schwarze 219:
220: switch (n->type) {
1.85 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.98 bentley 239: case MAN_MT:
1.85 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.66 schwarze 259: case ROFFT_TEXT:
1.85 schwarze 260: if (fillmode(h, want_fillmode) == MAN_fi &&
261: want_fillmode == MAN_fi &&
1.95 schwarze 262: n->flags & NODE_LINE && *n->string == ' ' &&
263: (h->flags & HTML_NONEWLINE) == 0)
1.75 schwarze 264: print_otag(h, TAG_BR, "");
1.85 schwarze 265: if (*n->string != '\0')
266: break;
267: print_paragraph(h);
1.99 schwarze 268: return;
269: case ROFFT_COMMENT:
1.85 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.1 schwarze 281: print_text(h, n->string);
1.83 schwarze 282: break;
1.66 schwarze 283: case ROFFT_EQN:
1.85 schwarze 284: t = h->tag;
1.41 schwarze 285: print_eqn(h, n->eqn);
1.37 schwarze 286: break;
1.66 schwarze 287: case ROFFT_TBL:
1.33 schwarze 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.29 schwarze 293: print_tbl(h, n->span);
1.32 schwarze 294: return;
1.1 schwarze 295: default:
1.52 schwarze 296: /*
1.4 schwarze 297: * Close out scope of font prior to opening a macro
1.33 schwarze 298: * scope.
1.4 schwarze 299: */
1.27 schwarze 300: if (HTMLFONT_NONE != h->metac) {
301: h->metal = h->metac;
302: h->metac = HTMLFONT_NONE;
1.33 schwarze 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.85 schwarze 310: if (h->tblt)
1.33 schwarze 311: print_tblclose(h);
1.85 schwarze 312:
313: t = h->tag;
1.90 schwarze 314: if (n->tok < ROFF_MAX) {
1.91 schwarze 315: roff_html_pre(h, n);
1.94 schwarze 316: child = 0;
1.90 schwarze 317: break;
318: }
319:
320: assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
1.108 schwarze 321: if (man_html_acts[n->tok - MAN_TH].pre != NULL)
322: child = (*man_html_acts[n->tok - MAN_TH].pre)(man,
323: n, h);
1.85 schwarze 324:
325: /* Some block macros resume .nf in the body. */
326: if (save_fillmode && n->type == ROFFT_BODY)
327: want_fillmode = save_fillmode;
328:
1.1 schwarze 329: break;
330: }
331:
332: if (child && n->child)
1.85 schwarze 333: print_man_nodelist(man, n->child, h);
1.1 schwarze 334:
1.4 schwarze 335: /* This will automatically close out any font scope. */
1.85 schwarze 336: print_stagq(h, t);
337:
338: if (fillmode(h, 0) == MAN_nf &&
339: n->next != NULL && n->next->flags & NODE_LINE)
340: print_endline(h);
341: }
342:
343: /*
344: * MAN_nf switches to no-fill mode, MAN_fi to fill mode.
345: * Other arguments do not switch.
346: * The old mode is returned.
347: */
348: static int
349: fillmode(struct html *h, int want)
350: {
351: struct tag *pre;
352: int had;
1.1 schwarze 353:
1.85 schwarze 354: for (pre = h->tag; pre != NULL; pre = pre->next)
355: if (pre->tag == TAG_PRE)
356: break;
357:
358: had = pre == NULL ? MAN_fi : MAN_nf;
1.83 schwarze 359:
1.85 schwarze 360: if (want && want != had) {
361: if (want == MAN_nf)
362: print_otag(h, TAG_PRE, "");
363: else
364: print_tagq(h, pre);
365: }
366: return had;
1.1 schwarze 367: }
368:
1.38 schwarze 369: static void
1.100 schwarze 370: man_root_pre(const struct roff_meta *man, struct html *h)
1.1 schwarze 371: {
372: struct tag *t, *tt;
1.53 schwarze 373: char *title;
1.1 schwarze 374:
1.48 schwarze 375: assert(man->title);
376: assert(man->msec);
1.53 schwarze 377: mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.1 schwarze 378:
1.75 schwarze 379: t = print_otag(h, TAG_TABLE, "c", "head");
380: tt = print_otag(h, TAG_TR, "");
1.1 schwarze 381:
1.75 schwarze 382: print_otag(h, TAG_TD, "c", "head-ltitle");
1.1 schwarze 383: print_text(h, title);
384: print_stagq(h, tt);
385:
1.75 schwarze 386: print_otag(h, TAG_TD, "c", "head-vol");
1.54 schwarze 387: if (NULL != man->vol)
388: print_text(h, man->vol);
1.1 schwarze 389: print_stagq(h, tt);
390:
1.75 schwarze 391: print_otag(h, TAG_TD, "c", "head-rtitle");
1.1 schwarze 392: print_text(h, title);
393: print_tagq(h, t);
1.53 schwarze 394: free(title);
1.1 schwarze 395: }
396:
397: static void
1.100 schwarze 398: man_root_post(const struct roff_meta *man, struct html *h)
1.1 schwarze 399: {
400: struct tag *t, *tt;
401:
1.75 schwarze 402: t = print_otag(h, TAG_TABLE, "c", "foot");
403: tt = print_otag(h, TAG_TR, "");
1.25 schwarze 404:
1.75 schwarze 405: print_otag(h, TAG_TD, "c", "foot-date");
1.48 schwarze 406: print_text(h, man->date);
1.1 schwarze 407: print_stagq(h, tt);
408:
1.75 schwarze 409: print_otag(h, TAG_TD, "c", "foot-os");
1.68 schwarze 410: if (man->os)
411: print_text(h, man->os);
1.1 schwarze 412: print_tagq(h, t);
413: }
414:
415: static int
416: man_SH_pre(MAN_ARGS)
417: {
1.87 schwarze 418: char *id;
419:
420: if (n->type == ROFFT_HEAD) {
1.103 schwarze 421: id = html_make_id(n, 1);
1.87 schwarze 422: print_otag(h, TAG_H1, "cTi", "Sh", id);
1.88 schwarze 423: if (id != NULL)
1.101 schwarze 424: print_otag(h, TAG_A, "chR", "permalink", id);
1.87 schwarze 425: }
1.72 schwarze 426: return 1;
1.1 schwarze 427: }
428:
429: static int
430: man_alt_pre(MAN_ARGS)
431: {
1.67 schwarze 432: const struct roff_node *nn;
1.83 schwarze 433: int i;
1.27 schwarze 434: enum htmltag fp;
435: struct tag *t;
1.1 schwarze 436:
437: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
438: switch (n->tok) {
1.52 schwarze 439: case MAN_BI:
1.27 schwarze 440: fp = i % 2 ? TAG_I : TAG_B;
1.1 schwarze 441: break;
1.52 schwarze 442: case MAN_IB:
1.27 schwarze 443: fp = i % 2 ? TAG_B : TAG_I;
1.1 schwarze 444: break;
1.52 schwarze 445: case MAN_RI:
1.27 schwarze 446: fp = i % 2 ? TAG_I : TAG_MAX;
1.1 schwarze 447: break;
1.52 schwarze 448: case MAN_IR:
1.27 schwarze 449: fp = i % 2 ? TAG_MAX : TAG_I;
1.1 schwarze 450: break;
1.52 schwarze 451: case MAN_BR:
1.27 schwarze 452: fp = i % 2 ? TAG_MAX : TAG_B;
1.1 schwarze 453: break;
1.52 schwarze 454: case MAN_RB:
1.27 schwarze 455: fp = i % 2 ? TAG_B : TAG_MAX;
1.1 schwarze 456: break;
457: default:
458: abort();
459: }
460:
461: if (i)
462: h->flags |= HTML_NOSPACE;
463:
1.83 schwarze 464: if (fp != TAG_MAX)
1.75 schwarze 465: t = print_otag(h, fp, "");
1.27 schwarze 466:
1.83 schwarze 467: print_text(h, nn->string);
1.27 schwarze 468:
1.83 schwarze 469: if (fp != TAG_MAX)
1.27 schwarze 470: print_tagq(h, t);
1.1 schwarze 471: }
1.72 schwarze 472: return 0;
1.1 schwarze 473: }
474:
475: static int
1.26 schwarze 476: man_SM_pre(MAN_ARGS)
1.1 schwarze 477: {
1.75 schwarze 478: print_otag(h, TAG_SMALL, "");
1.26 schwarze 479: if (MAN_SB == n->tok)
1.75 schwarze 480: print_otag(h, TAG_B, "");
1.72 schwarze 481: return 1;
1.1 schwarze 482: }
483:
484: static int
485: man_SS_pre(MAN_ARGS)
486: {
1.87 schwarze 487: char *id;
488:
489: if (n->type == ROFFT_HEAD) {
1.103 schwarze 490: id = html_make_id(n, 1);
1.87 schwarze 491: print_otag(h, TAG_H2, "cTi", "Ss", id);
1.88 schwarze 492: if (id != NULL)
1.101 schwarze 493: print_otag(h, TAG_A, "chR", "permalink", id);
1.87 schwarze 494: }
1.72 schwarze 495: return 1;
1.1 schwarze 496: }
497:
498: static int
499: man_PP_pre(MAN_ARGS)
500: {
501:
1.66 schwarze 502: if (n->type == ROFFT_HEAD)
1.72 schwarze 503: return 0;
1.66 schwarze 504: else if (n->type == ROFFT_BLOCK)
1.39 schwarze 505: print_bvspace(h, n);
1.22 schwarze 506:
1.72 schwarze 507: return 1;
1.1 schwarze 508: }
509:
510: static int
511: man_IP_pre(MAN_ARGS)
512: {
1.67 schwarze 513: const struct roff_node *nn;
1.1 schwarze 514:
1.66 schwarze 515: if (n->type == ROFFT_BODY) {
1.102 schwarze 516: print_otag(h, TAG_DD, "");
1.72 schwarze 517: return 1;
1.66 schwarze 518: } else if (n->type != ROFFT_HEAD) {
1.82 schwarze 519: print_otag(h, TAG_DL, "c", "Bl-tag");
1.72 schwarze 520: return 1;
1.1 schwarze 521: }
522:
1.102 schwarze 523: print_otag(h, TAG_DT, "");
1.1 schwarze 524:
1.107 schwarze 525: switch(n->tok) {
526: case MAN_IP: /* Only print the first header element. */
527: if (n->child != NULL)
528: print_man_node(man, n->child, h);
529: break;
530: case MAN_TP: /* Only print next-line header elements. */
531: case MAN_TQ:
1.50 schwarze 532: nn = n->child;
1.107 schwarze 533: while (nn != NULL && (NODE_LINE & nn->flags) == 0)
1.50 schwarze 534: nn = nn->next;
1.107 schwarze 535: while (nn != NULL) {
1.85 schwarze 536: print_man_node(man, nn, h);
1.50 schwarze 537: nn = nn->next;
538: }
1.107 schwarze 539: break;
540: default:
541: abort();
1.50 schwarze 542: }
1.1 schwarze 543:
1.72 schwarze 544: return 0;
1.1 schwarze 545: }
546:
547: static int
548: man_HP_pre(MAN_ARGS)
549: {
1.66 schwarze 550: if (n->type == ROFFT_HEAD)
1.72 schwarze 551: return 0;
1.38 schwarze 552:
1.104 schwarze 553: if (n->type == ROFFT_BLOCK) {
554: print_bvspace(h, n);
555: print_otag(h, TAG_DIV, "c", "HP");
556: }
1.72 schwarze 557: return 1;
1.1 schwarze 558: }
1.46 schwarze 559:
560: static int
561: man_OP_pre(MAN_ARGS)
562: {
563: struct tag *tt;
564:
565: print_text(h, "[");
566: h->flags |= HTML_NOSPACE;
1.81 schwarze 567: tt = print_otag(h, TAG_SPAN, "c", "Op");
1.46 schwarze 568:
569: if (NULL != (n = n->child)) {
1.75 schwarze 570: print_otag(h, TAG_B, "");
1.46 schwarze 571: print_text(h, n->string);
572: }
573:
574: print_stagq(h, tt);
575:
576: if (NULL != n && NULL != n->next) {
1.75 schwarze 577: print_otag(h, TAG_I, "");
1.46 schwarze 578: print_text(h, n->next->string);
579: }
580:
581: print_stagq(h, tt);
582: h->flags |= HTML_NOSPACE;
583: print_text(h, "]");
1.72 schwarze 584: return 0;
1.46 schwarze 585: }
586:
1.1 schwarze 587: static int
588: man_B_pre(MAN_ARGS)
589: {
1.75 schwarze 590: print_otag(h, TAG_B, "");
1.72 schwarze 591: return 1;
1.1 schwarze 592: }
593:
594: static int
595: man_I_pre(MAN_ARGS)
596: {
1.75 schwarze 597: print_otag(h, TAG_I, "");
1.72 schwarze 598: return 1;
1.18 schwarze 599: }
600:
601: static int
602: man_in_pre(MAN_ARGS)
603: {
1.75 schwarze 604: print_otag(h, TAG_BR, "");
1.72 schwarze 605: return 0;
1.1 schwarze 606: }
607:
608: static int
609: man_ign_pre(MAN_ARGS)
610: {
611:
1.72 schwarze 612: return 0;
1.1 schwarze 613: }
614:
615: static int
616: man_RS_pre(MAN_ARGS)
617: {
1.66 schwarze 618: if (n->type == ROFFT_HEAD)
1.72 schwarze 619: return 0;
1.105 schwarze 620: if (n->type == ROFFT_BLOCK)
621: print_otag(h, TAG_DIV, "c", "Bd-indent");
1.109 ! schwarze 622: return 1;
! 623: }
! 624:
! 625: static int
! 626: man_SY_pre(MAN_ARGS)
! 627: {
! 628: switch (n->type) {
! 629: case ROFFT_BLOCK:
! 630: print_otag(h, TAG_TABLE, "c", "Nm");
! 631: print_otag(h, TAG_TR, "");
! 632: break;
! 633: case ROFFT_HEAD:
! 634: print_otag(h, TAG_TD, "");
! 635: print_otag(h, TAG_CODE, "cT", "Nm");
! 636: break;
! 637: case ROFFT_BODY:
! 638: print_otag(h, TAG_TD, "");
! 639: break;
! 640: default:
! 641: abort();
! 642: }
1.72 schwarze 643: return 1;
1.49 schwarze 644: }
645:
646: static int
647: man_UR_pre(MAN_ARGS)
648: {
1.98 bentley 649: char *cp;
1.49 schwarze 650: n = n->child;
1.66 schwarze 651: assert(n->type == ROFFT_HEAD);
1.73 schwarze 652: if (n->child != NULL) {
1.66 schwarze 653: assert(n->child->type == ROFFT_TEXT);
1.98 bentley 654: if (n->tok == MAN_MT) {
655: mandoc_asprintf(&cp, "mailto:%s", n->child->string);
656: print_otag(h, TAG_A, "cTh", "Mt", cp);
657: free(cp);
658: } else
659: print_otag(h, TAG_A, "cTh", "Lk", n->child->string);
1.49 schwarze 660: }
661:
1.66 schwarze 662: assert(n->next->type == ROFFT_BODY);
1.73 schwarze 663: if (n->next->child != NULL)
1.49 schwarze 664: n = n->next;
665:
1.85 schwarze 666: print_man_nodelist(man, n->child, h);
1.49 schwarze 667:
1.72 schwarze 668: return 0;
1.1 schwarze 669: }