Annotation of mandoc/man_html.c, Revision 1.183
1.183 ! schwarze 1: /* $Id: man_html.c,v 1.182 2022/07/05 21:25:29 schwarze Exp $ */
1.1 kristaps 2: /*
1.182 schwarze 3: * Copyright (c) 2013-2015,2017-2020,2022 Ingo Schwarze <schwarze@openbsd.org>
1.104 kristaps 4: * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
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.
1.177 schwarze 17: *
18: * HTML formatter for man(7) used by mandoc(1).
1.1 kristaps 19: */
1.25 kristaps 20: #include "config.h"
21:
1.1 kristaps 22: #include <sys/types.h>
23:
1.5 kristaps 24: #include <assert.h>
25: #include <ctype.h>
1.2 kristaps 26: #include <stdio.h>
1.1 kristaps 27: #include <stdlib.h>
1.4 kristaps 28: #include <string.h>
1.1 kristaps 29:
1.94 schwarze 30: #include "mandoc_aux.h"
1.160 schwarze 31: #include "mandoc.h"
1.113 schwarze 32: #include "roff.h"
1.105 schwarze 33: #include "man.h"
1.7 kristaps 34: #include "out.h"
1.1 kristaps 35: #include "html.h"
1.10 kristaps 36: #include "main.h"
1.1 kristaps 37:
1.115 schwarze 38: #define MAN_ARGS const struct roff_meta *man, \
1.176 schwarze 39: 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.147 schwarze 47: static void print_man_head(const struct roff_meta *,
48: struct html *);
1.4 kristaps 49: static void print_man_nodelist(MAN_ARGS);
50: static void print_man_node(MAN_ARGS);
1.173 schwarze 51: static char list_continues(const struct roff_node *,
52: const struct roff_node *);
1.8 kristaps 53: static int man_B_pre(MAN_ARGS);
1.86 kristaps 54: static int man_IP_pre(MAN_ARGS);
1.8 kristaps 55: static int man_I_pre(MAN_ARGS);
1.86 kristaps 56: static int man_OP_pre(MAN_ARGS);
1.4 kristaps 57: static int man_PP_pre(MAN_ARGS);
1.9 kristaps 58: static int man_RS_pre(MAN_ARGS);
1.4 kristaps 59: static int man_SH_pre(MAN_ARGS);
1.8 kristaps 60: static int man_SM_pre(MAN_ARGS);
1.156 schwarze 61: static int man_SY_pre(MAN_ARGS);
1.90 schwarze 62: static int man_UR_pre(MAN_ARGS);
1.158 schwarze 63: static int man_abort_pre(MAN_ARGS);
1.86 kristaps 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.147 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.4 kristaps 71:
1.155 schwarze 72: static const struct man_html_act man_html_acts[MAN_MAX - MAN_TH] = {
1.3 kristaps 73: { NULL, NULL }, /* TH */
1.4 kristaps 74: { man_SH_pre, NULL }, /* SH */
1.166 schwarze 75: { man_SH_pre, NULL }, /* SS */
1.6 kristaps 76: { man_IP_pre, NULL }, /* TP */
1.154 schwarze 77: { man_IP_pre, NULL }, /* TQ */
1.158 schwarze 78: { man_abort_pre, NULL }, /* LP */
1.4 kristaps 79: { man_PP_pre, NULL }, /* PP */
1.158 schwarze 80: { man_abort_pre, NULL }, /* P */
1.5 kristaps 81: { man_IP_pre, NULL }, /* IP */
1.166 schwarze 82: { man_PP_pre, NULL }, /* HP */
1.8 kristaps 83: { man_SM_pre, NULL }, /* SM */
1.56 kristaps 84: { man_SM_pre, NULL }, /* SB */
1.8 kristaps 85: { man_alt_pre, NULL }, /* BI */
86: { man_alt_pre, NULL }, /* IB */
87: { man_alt_pre, NULL }, /* BR */
88: { man_alt_pre, NULL }, /* RB */
1.3 kristaps 89: { NULL, NULL }, /* R */
1.8 kristaps 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.3 kristaps 94: { NULL, NULL }, /* RE */
1.9 kristaps 95: { man_RS_pre, NULL }, /* RS */
1.8 kristaps 96: { man_ign_pre, NULL }, /* DT */
97: { man_ign_pre, NULL }, /* UC */
1.13 kristaps 98: { man_ign_pre, NULL }, /* PD */
1.34 joerg 99: { man_ign_pre, NULL }, /* AT */
1.45 kristaps 100: { man_in_pre, NULL }, /* in */
1.156 schwarze 101: { man_SY_pre, NULL }, /* SY */
102: { NULL, NULL }, /* YS */
1.86 kristaps 103: { man_OP_pre, NULL }, /* OP */
1.132 schwarze 104: { NULL, NULL }, /* EX */
105: { NULL, NULL }, /* EE */
1.90 schwarze 106: { man_UR_pre, NULL }, /* UR */
107: { NULL, NULL }, /* UE */
1.145 schwarze 108: { man_UR_pre, NULL }, /* MT */
109: { NULL, NULL }, /* ME */
1.3 kristaps 110: };
111:
1.93 schwarze 112:
1.1 kristaps 113: void
1.161 schwarze 114: html_man(void *arg, const struct roff_meta *man)
1.1 kristaps 115: {
1.147 schwarze 116: struct html *h;
117: struct roff_node *n;
118: struct tag *t;
1.82 kristaps 119:
1.117 schwarze 120: h = (struct html *)arg;
1.147 schwarze 121: n = man->first->child;
1.3 kristaps 122:
1.126 schwarze 123: if ((h->oflags & HTML_FRAGMENT) == 0) {
1.82 kristaps 124: print_gen_decls(h);
1.126 schwarze 125: print_otag(h, TAG_HTML, "");
126: t = print_otag(h, TAG_HEAD, "");
1.161 schwarze 127: print_man_head(man, h);
1.126 schwarze 128: print_tagq(h, t);
1.181 schwarze 129: if (n != NULL && n->type == ROFFT_COMMENT)
130: print_gen_comment(h, n);
1.122 schwarze 131: print_otag(h, TAG_BODY, "");
1.126 schwarze 132: }
1.53 kristaps 133:
1.161 schwarze 134: man_root_pre(man, h);
1.180 schwarze 135: t = print_otag(h, TAG_MAIN, "c", "manual-text");
1.161 schwarze 136: print_man_nodelist(man, n, h);
1.127 schwarze 137: print_tagq(h, t);
1.161 schwarze 138: man_root_post(man, h);
1.126 schwarze 139: print_tagq(h, NULL);
1.3 kristaps 140: }
141:
142: static void
1.147 schwarze 143: print_man_head(const struct roff_meta *man, struct html *h)
1.3 kristaps 144: {
1.123 schwarze 145: char *cp;
1.3 kristaps 146:
147: print_gen_head(h);
1.123 schwarze 148: mandoc_asprintf(&cp, "%s(%s)", man->title, man->msec);
1.122 schwarze 149: print_otag(h, TAG_TITLE, "");
1.123 schwarze 150: print_text(h, cp);
151: free(cp);
1.1 kristaps 152: }
1.4 kristaps 153:
154: static void
155: print_man_nodelist(MAN_ARGS)
156: {
1.110 schwarze 157: while (n != NULL) {
1.132 schwarze 158: print_man_node(man, n, h);
1.110 schwarze 159: n = n->next;
160: }
1.4 kristaps 161: }
162:
163: static void
164: print_man_node(MAN_ARGS)
165: {
1.132 schwarze 166: struct tag *t;
1.4 kristaps 167: int child;
168:
1.167 schwarze 169: if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
170: return;
171:
1.179 schwarze 172: if ((n->flags & NODE_NOFILL) == 0)
173: html_fillmode(h, ROFF_fi);
174: else if (html_fillmode(h, ROFF_nf) == ROFF_nf &&
175: n->tok != ROFF_fi && n->flags & NODE_LINE &&
176: (n->prev == NULL || n->prev->tok != MAN_YS))
177: print_endline(h);
1.132 schwarze 178:
179: child = 1;
180: switch (n->type) {
181: case ROFFT_TEXT:
1.163 schwarze 182: if (*n->string == '\0') {
183: print_endline(h);
184: return;
185: }
186: if (*n->string == ' ' && n->flags & NODE_LINE &&
187: (h->flags & HTML_NONEWLINE) == 0)
1.175 schwarze 188: print_otag(h, TAG_BR, "");
1.163 schwarze 189: else if (n->flags & NODE_DELIMC)
190: h->flags |= HTML_NOSPACE;
1.170 schwarze 191: t = h->tag;
192: t->refcnt++;
1.4 kristaps 193: print_text(h, n->string);
1.130 schwarze 194: break;
1.113 schwarze 195: case ROFFT_EQN:
1.170 schwarze 196: t = h->tag;
197: t->refcnt++;
1.80 kristaps 198: print_eqn(h, n->eqn);
1.69 kristaps 199: break;
1.113 schwarze 200: case ROFFT_TBL:
1.66 kristaps 201: /*
202: * This will take care of initialising all of the table
203: * state data for the first table, then tearing it down
204: * for the last one.
205: */
1.60 kristaps 206: print_tbl(h, n->span);
1.64 kristaps 207: return;
1.4 kristaps 208: default:
1.93 schwarze 209: /*
1.21 kristaps 210: * Close out scope of font prior to opening a macro
1.66 kristaps 211: * scope.
1.21 kristaps 212: */
1.174 schwarze 213: if (h->metac != ESCAPE_FONTROMAN) {
1.57 kristaps 214: h->metal = h->metac;
1.174 schwarze 215: h->metac = ESCAPE_FONTROMAN;
1.66 kristaps 216: }
217:
218: /*
219: * Close out the current table, if it's open, and unset
220: * the "meta" table state. This will be reopened on the
221: * next table element.
222: */
1.170 schwarze 223: if (h->tblt != NULL)
1.66 kristaps 224: print_tblclose(h);
1.170 schwarze 225: t = h->tag;
226: t->refcnt++;
1.137 schwarze 227: if (n->tok < ROFF_MAX) {
1.138 schwarze 228: roff_html_pre(h, n);
1.170 schwarze 229: t->refcnt--;
1.167 schwarze 230: print_stagq(h, t);
1.163 schwarze 231: return;
1.137 schwarze 232: }
233: assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
1.155 schwarze 234: if (man_html_acts[n->tok - MAN_TH].pre != NULL)
235: child = (*man_html_acts[n->tok - MAN_TH].pre)(man,
236: n, h);
1.4 kristaps 237: break;
238: }
239:
1.164 schwarze 240: if (child && n->child != NULL)
1.132 schwarze 241: print_man_nodelist(man, n->child, h);
1.21 kristaps 242:
1.24 kristaps 243: /* This will automatically close out any font scope. */
1.170 schwarze 244: t->refcnt--;
1.171 schwarze 245: if (n->type == ROFFT_BLOCK &&
246: (n->tok == MAN_IP || n->tok == MAN_TP || n->tok == MAN_TQ)) {
247: t = h->tag;
1.173 schwarze 248: while (t->tag != TAG_DL && t->tag != TAG_UL)
1.171 schwarze 249: t = t->next;
250: /*
251: * Close the list if no further item of the same type
252: * follows; otherwise, close the item only.
253: */
1.176 schwarze 254: if (list_continues(n, roff_node_next(n)) == '\0') {
1.171 schwarze 255: print_tagq(h, t);
256: t = NULL;
257: }
258: }
259: if (t != NULL)
260: print_stagq(h, t);
1.4 kristaps 261: }
262:
1.65 kristaps 263: static void
1.147 schwarze 264: man_root_pre(const struct roff_meta *man, struct html *h)
1.4 kristaps 265: {
1.182 schwarze 266: struct tag *t;
1.94 schwarze 267: char *title;
1.4 kristaps 268:
1.89 schwarze 269: assert(man->title);
270: assert(man->msec);
1.94 schwarze 271: mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.4 kristaps 272:
1.182 schwarze 273: t = print_otag(h, TAG_DIV, "cr?", "head", "doc-pageheader",
274: "aria-label", "manual header line");
1.4 kristaps 275:
1.182 schwarze 276: print_otag(h, TAG_SPAN, "c", "head-ltitle");
1.4 kristaps 277: print_text(h, title);
1.182 schwarze 278: print_stagq(h, t);
1.4 kristaps 279:
1.182 schwarze 280: print_otag(h, TAG_SPAN, "c", "head-vol");
1.164 schwarze 281: if (man->vol != NULL)
1.95 schwarze 282: print_text(h, man->vol);
1.182 schwarze 283: print_stagq(h, t);
1.4 kristaps 284:
1.182 schwarze 285: print_otag(h, TAG_SPAN, "c", "head-rtitle");
1.4 kristaps 286: print_text(h, title);
287: print_tagq(h, t);
1.94 schwarze 288: free(title);
1.4 kristaps 289: }
290:
291: static void
1.147 schwarze 292: man_root_post(const struct roff_meta *man, struct html *h)
1.4 kristaps 293: {
1.182 schwarze 294: struct tag *t;
295:
296: t = print_otag(h, TAG_DIV, "cr?", "foot", "doc-pagefooter",
297: "aria-label", "manual footer line");
1.4 kristaps 298:
1.182 schwarze 299: print_otag(h, TAG_SPAN, "c", "foot-left");
300: print_stagq(h, t);
1.55 kristaps 301:
1.182 schwarze 302: print_otag(h, TAG_SPAN, "c", "foot-date");
1.89 schwarze 303: print_text(h, man->date);
1.182 schwarze 304: print_stagq(h, t);
1.4 kristaps 305:
1.182 schwarze 306: print_otag(h, TAG_SPAN, "c", "foot-os");
1.164 schwarze 307: if (man->os != NULL)
1.115 schwarze 308: print_text(h, man->os);
1.4 kristaps 309: print_tagq(h, t);
310: }
311:
312: static int
313: man_SH_pre(MAN_ARGS)
314: {
1.172 schwarze 315: const char *class;
316: enum htmltag tag;
317:
318: if (n->tok == MAN_SH) {
1.183 ! schwarze 319: tag = TAG_H2;
1.172 schwarze 320: class = "Sh";
321: } else {
1.183 ! schwarze 322: tag = TAG_H3;
1.172 schwarze 323: class = "Ss";
324: }
1.166 schwarze 325: switch (n->type) {
326: case ROFFT_BLOCK:
327: html_close_paragraph(h);
1.172 schwarze 328: print_otag(h, TAG_SECTION, "c", class);
1.166 schwarze 329: break;
330: case ROFFT_HEAD:
1.177 schwarze 331: print_otag_id(h, tag, class, n);
1.166 schwarze 332: break;
333: case ROFFT_BODY:
334: break;
335: default:
336: abort();
1.134 schwarze 337: }
1.119 schwarze 338: return 1;
1.4 kristaps 339: }
340:
341: static int
1.8 kristaps 342: man_alt_pre(MAN_ARGS)
343: {
1.114 schwarze 344: const struct roff_node *nn;
1.164 schwarze 345: struct tag *t;
1.130 schwarze 346: int i;
1.57 kristaps 347: enum htmltag fp;
1.8 kristaps 348:
1.164 schwarze 349: for (i = 0, nn = n->child; nn != NULL; nn = nn->next, i++) {
1.8 kristaps 350: switch (n->tok) {
1.93 schwarze 351: case MAN_BI:
1.57 kristaps 352: fp = i % 2 ? TAG_I : TAG_B;
1.8 kristaps 353: break;
1.93 schwarze 354: case MAN_IB:
1.57 kristaps 355: fp = i % 2 ? TAG_B : TAG_I;
1.8 kristaps 356: break;
1.93 schwarze 357: case MAN_RI:
1.57 kristaps 358: fp = i % 2 ? TAG_I : TAG_MAX;
1.8 kristaps 359: break;
1.93 schwarze 360: case MAN_IR:
1.57 kristaps 361: fp = i % 2 ? TAG_MAX : TAG_I;
1.8 kristaps 362: break;
1.93 schwarze 363: case MAN_BR:
1.57 kristaps 364: fp = i % 2 ? TAG_MAX : TAG_B;
1.8 kristaps 365: break;
1.93 schwarze 366: case MAN_RB:
1.57 kristaps 367: fp = i % 2 ? TAG_B : TAG_MAX;
1.8 kristaps 368: break;
369: default:
370: abort();
371: }
372:
373: if (i)
374: h->flags |= HTML_NOSPACE;
375:
1.130 schwarze 376: if (fp != TAG_MAX)
1.122 schwarze 377: t = print_otag(h, fp, "");
1.57 kristaps 378:
1.130 schwarze 379: print_text(h, nn->string);
1.57 kristaps 380:
1.130 schwarze 381: if (fp != TAG_MAX)
1.57 kristaps 382: print_tagq(h, t);
1.8 kristaps 383: }
1.119 schwarze 384: return 0;
1.8 kristaps 385: }
386:
387: static int
1.56 kristaps 388: man_SM_pre(MAN_ARGS)
1.8 kristaps 389: {
1.122 schwarze 390: print_otag(h, TAG_SMALL, "");
1.164 schwarze 391: if (n->tok == MAN_SB)
1.122 schwarze 392: print_otag(h, TAG_B, "");
1.119 schwarze 393: return 1;
1.8 kristaps 394: }
395:
396: static int
1.4 kristaps 397: man_PP_pre(MAN_ARGS)
398: {
1.166 schwarze 399: switch (n->type) {
400: case ROFFT_BLOCK:
401: html_close_paragraph(h);
402: break;
403: case ROFFT_HEAD:
1.119 schwarze 404: return 0;
1.166 schwarze 405: case ROFFT_BODY:
406: if (n->child != NULL &&
407: (n->child->flags & NODE_NOFILL) == 0)
408: print_otag(h, TAG_P, "c",
409: n->tok == MAN_PP ? "Pp" : "Pp HP");
410: break;
411: default:
412: abort();
413: }
1.119 schwarze 414: return 1;
1.5 kristaps 415: }
416:
1.173 schwarze 417: static char
418: list_continues(const struct roff_node *n1, const struct roff_node *n2)
419: {
420: const char *s1, *s2;
421: char c1, c2;
422:
423: if (n1 == NULL || n1->type != ROFFT_BLOCK ||
424: n2 == NULL || n2->type != ROFFT_BLOCK)
425: return '\0';
426: if ((n1->tok == MAN_TP || n1->tok == MAN_TQ) &&
427: (n2->tok == MAN_TP || n2->tok == MAN_TQ))
428: return ' ';
429: if (n1->tok != MAN_IP || n2->tok != MAN_IP)
430: return '\0';
431: n1 = n1->head->child;
432: n2 = n2->head->child;
433: s1 = n1 == NULL ? "" : n1->string;
434: s2 = n2 == NULL ? "" : n2->string;
435: c1 = strcmp(s1, "*") == 0 ? '*' :
436: strcmp(s1, "\\-") == 0 ? '-' :
437: strcmp(s1, "\\(bu") == 0 ? 'b' : ' ';
438: c2 = strcmp(s2, "*") == 0 ? '*' :
439: strcmp(s2, "\\-") == 0 ? '-' :
440: strcmp(s2, "\\(bu") == 0 ? 'b' : ' ';
441: return c1 != c2 ? '\0' : c1 == 'b' ? '*' : c1;
442: }
443:
1.5 kristaps 444: static int
445: man_IP_pre(MAN_ARGS)
446: {
1.176 schwarze 447: struct roff_node *nn;
1.173 schwarze 448: const char *list_class;
449: enum htmltag list_elem, body_elem;
450: char list_type;
451:
452: nn = n->type == ROFFT_BLOCK ? n : n->parent;
1.176 schwarze 453: list_type = list_continues(roff_node_prev(nn), nn);
454: if (list_type == '\0') {
1.173 schwarze 455: /* Start a new list. */
1.176 schwarze 456: list_type = list_continues(nn, roff_node_next(nn));
457: if (list_type == '\0')
1.173 schwarze 458: list_type = ' ';
459: switch (list_type) {
460: case ' ':
461: list_class = "Bl-tag";
462: list_elem = TAG_DL;
463: break;
464: case '*':
465: list_class = "Bl-bullet";
466: list_elem = TAG_UL;
467: break;
468: case '-':
469: list_class = "Bl-dash";
470: list_elem = TAG_UL;
471: break;
472: default:
473: abort();
474: }
475: } else {
476: /* Continue a list that was started earlier. */
477: list_class = NULL;
478: list_elem = TAG_MAX;
479: }
480: body_elem = list_type == ' ' ? TAG_DD : TAG_LI;
1.5 kristaps 481:
1.166 schwarze 482: switch (n->type) {
483: case ROFFT_BLOCK:
484: html_close_paragraph(h);
1.173 schwarze 485: if (list_elem != TAG_MAX)
486: print_otag(h, list_elem, "c", list_class);
1.166 schwarze 487: return 1;
488: case ROFFT_HEAD:
1.173 schwarze 489: if (body_elem == TAG_LI)
490: return 0;
1.177 schwarze 491: print_otag_id(h, TAG_DT, NULL, n);
1.166 schwarze 492: break;
493: case ROFFT_BODY:
1.173 schwarze 494: print_otag(h, body_elem, "");
1.119 schwarze 495: return 1;
1.166 schwarze 496: default:
497: abort();
1.6 kristaps 498: }
1.154 schwarze 499: switch(n->tok) {
500: case MAN_IP: /* Only print the first header element. */
501: if (n->child != NULL)
502: print_man_node(man, n->child, h);
503: break;
504: case MAN_TP: /* Only print next-line header elements. */
505: case MAN_TQ:
1.91 schwarze 506: nn = n->child;
1.154 schwarze 507: while (nn != NULL && (NODE_LINE & nn->flags) == 0)
1.91 schwarze 508: nn = nn->next;
1.154 schwarze 509: while (nn != NULL) {
1.132 schwarze 510: print_man_node(man, nn, h);
1.91 schwarze 511: nn = nn->next;
512: }
1.154 schwarze 513: break;
514: default:
515: abort();
1.91 schwarze 516: }
1.119 schwarze 517: return 0;
1.6 kristaps 518: }
519:
520: static int
1.86 kristaps 521: man_OP_pre(MAN_ARGS)
522: {
523: struct tag *tt;
524:
525: print_text(h, "[");
526: h->flags |= HTML_NOSPACE;
1.128 schwarze 527: tt = print_otag(h, TAG_SPAN, "c", "Op");
1.86 kristaps 528:
1.164 schwarze 529: if ((n = n->child) != NULL) {
1.122 schwarze 530: print_otag(h, TAG_B, "");
1.86 kristaps 531: print_text(h, n->string);
532: }
533:
534: print_stagq(h, tt);
535:
1.164 schwarze 536: if (n != NULL && n->next != NULL) {
1.122 schwarze 537: print_otag(h, TAG_I, "");
1.86 kristaps 538: print_text(h, n->next->string);
539: }
540:
541: print_stagq(h, tt);
542: h->flags |= HTML_NOSPACE;
543: print_text(h, "]");
1.119 schwarze 544: return 0;
1.86 kristaps 545: }
546:
1.8 kristaps 547: static int
548: man_B_pre(MAN_ARGS)
549: {
1.122 schwarze 550: print_otag(h, TAG_B, "");
1.119 schwarze 551: return 1;
1.8 kristaps 552: }
553:
554: static int
555: man_I_pre(MAN_ARGS)
556: {
1.122 schwarze 557: print_otag(h, TAG_I, "");
1.119 schwarze 558: return 1;
1.45 kristaps 559: }
560:
561: static int
562: man_in_pre(MAN_ARGS)
563: {
1.122 schwarze 564: print_otag(h, TAG_BR, "");
1.119 schwarze 565: return 0;
1.8 kristaps 566: }
567:
568: static int
569: man_ign_pre(MAN_ARGS)
570: {
1.119 schwarze 571: return 0;
1.8 kristaps 572: }
1.9 kristaps 573:
574: static int
575: man_RS_pre(MAN_ARGS)
576: {
1.166 schwarze 577: switch (n->type) {
578: case ROFFT_BLOCK:
579: html_close_paragraph(h);
580: break;
581: case ROFFT_HEAD:
1.119 schwarze 582: return 0;
1.166 schwarze 583: case ROFFT_BODY:
1.152 schwarze 584: print_otag(h, TAG_DIV, "c", "Bd-indent");
1.166 schwarze 585: break;
586: default:
587: abort();
588: }
1.156 schwarze 589: return 1;
590: }
591:
592: static int
593: man_SY_pre(MAN_ARGS)
594: {
595: switch (n->type) {
596: case ROFFT_BLOCK:
1.166 schwarze 597: html_close_paragraph(h);
1.156 schwarze 598: print_otag(h, TAG_TABLE, "c", "Nm");
599: print_otag(h, TAG_TR, "");
600: break;
601: case ROFFT_HEAD:
602: print_otag(h, TAG_TD, "");
1.168 schwarze 603: print_otag(h, TAG_CODE, "c", "Nm");
1.156 schwarze 604: break;
605: case ROFFT_BODY:
606: print_otag(h, TAG_TD, "");
607: break;
608: default:
609: abort();
610: }
1.119 schwarze 611: return 1;
1.90 schwarze 612: }
613:
614: static int
615: man_UR_pre(MAN_ARGS)
616: {
1.145 schwarze 617: char *cp;
1.164 schwarze 618:
1.90 schwarze 619: n = n->child;
1.113 schwarze 620: assert(n->type == ROFFT_HEAD);
1.120 schwarze 621: if (n->child != NULL) {
1.113 schwarze 622: assert(n->child->type == ROFFT_TEXT);
1.145 schwarze 623: if (n->tok == MAN_MT) {
624: mandoc_asprintf(&cp, "mailto:%s", n->child->string);
1.168 schwarze 625: print_otag(h, TAG_A, "ch", "Mt", cp);
1.145 schwarze 626: free(cp);
627: } else
1.168 schwarze 628: print_otag(h, TAG_A, "ch", "Lk", n->child->string);
1.90 schwarze 629: }
630:
1.113 schwarze 631: assert(n->next->type == ROFFT_BODY);
1.120 schwarze 632: if (n->next->child != NULL)
1.90 schwarze 633: n = n->next;
634:
1.132 schwarze 635: print_man_nodelist(man, n->child, h);
1.119 schwarze 636: return 0;
1.158 schwarze 637: }
638:
639: static int
640: man_abort_pre(MAN_ARGS)
641: {
642: abort();
1.9 kristaps 643: }
CVSweb