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