Annotation of mandoc/man_html.c, Revision 1.145
1.145 ! schwarze 1: /* $Id: man_html.c,v 1.144 2017/06/24 14:38:32 schwarze Exp $ */
1.1 kristaps 2: /*
1.104 kristaps 3: * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
1.122 schwarze 4: * Copyright (c) 2013, 2014, 2015, 2017 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.6 kristaps 37:
38: #define INDENT 5
1.4 kristaps 39:
1.115 schwarze 40: #define MAN_ARGS const struct roff_meta *man, \
1.114 schwarze 41: const struct roff_node *n, \
1.3 kristaps 42: struct html *h
43:
44: struct htmlman {
45: int (*pre)(MAN_ARGS);
46: int (*post)(MAN_ARGS);
47: };
48:
1.93 schwarze 49: static void print_bvspace(struct html *,
1.114 schwarze 50: const struct roff_node *);
1.3 kristaps 51: static void print_man_head(MAN_ARGS);
1.4 kristaps 52: static void print_man_nodelist(MAN_ARGS);
53: static void print_man_node(MAN_ARGS);
1.132 schwarze 54: static int fillmode(struct html *, int);
1.114 schwarze 55: static int a2width(const struct roff_node *,
1.7 kristaps 56: struct roffsu *);
1.8 kristaps 57: static int man_B_pre(MAN_ARGS);
1.6 kristaps 58: static int man_HP_pre(MAN_ARGS);
1.86 kristaps 59: static int man_IP_pre(MAN_ARGS);
1.8 kristaps 60: static int man_I_pre(MAN_ARGS);
1.86 kristaps 61: static int man_OP_pre(MAN_ARGS);
1.4 kristaps 62: static int man_PP_pre(MAN_ARGS);
1.9 kristaps 63: static int man_RS_pre(MAN_ARGS);
1.4 kristaps 64: static int man_SH_pre(MAN_ARGS);
1.8 kristaps 65: static int man_SM_pre(MAN_ARGS);
1.4 kristaps 66: static int man_SS_pre(MAN_ARGS);
1.90 schwarze 67: static int man_UR_pre(MAN_ARGS);
1.86 kristaps 68: static int man_alt_pre(MAN_ARGS);
69: static int man_ign_pre(MAN_ARGS);
70: static int man_in_pre(MAN_ARGS);
71: static void man_root_post(MAN_ARGS);
72: static void man_root_pre(MAN_ARGS);
1.4 kristaps 73:
1.136 schwarze 74: static const struct htmlman __mans[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.4 kristaps 79: { man_PP_pre, NULL }, /* LP */
80: { man_PP_pre, NULL }, /* PP */
81: { man_PP_pre, NULL }, /* P */
1.5 kristaps 82: { man_IP_pre, NULL }, /* IP */
1.93 schwarze 83: { man_HP_pre, NULL }, /* HP */
1.8 kristaps 84: { man_SM_pre, NULL }, /* SM */
1.56 kristaps 85: { man_SM_pre, NULL }, /* SB */
1.8 kristaps 86: { man_alt_pre, NULL }, /* BI */
87: { man_alt_pre, NULL }, /* IB */
88: { man_alt_pre, NULL }, /* BR */
89: { man_alt_pre, NULL }, /* RB */
1.3 kristaps 90: { NULL, NULL }, /* R */
1.8 kristaps 91: { man_B_pre, NULL }, /* B */
92: { man_I_pre, NULL }, /* I */
93: { man_alt_pre, NULL }, /* IR */
94: { man_alt_pre, NULL }, /* RI */
1.132 schwarze 95: { NULL, NULL }, /* nf */
96: { NULL, NULL }, /* fi */
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.86 kristaps 104: { man_OP_pre, NULL }, /* OP */
1.132 schwarze 105: { NULL, NULL }, /* EX */
106: { NULL, NULL }, /* EE */
1.90 schwarze 107: { man_UR_pre, NULL }, /* UR */
108: { NULL, NULL }, /* UE */
1.145 ! schwarze 109: { man_UR_pre, NULL }, /* MT */
! 110: { NULL, NULL }, /* ME */
1.3 kristaps 111: };
1.136 schwarze 112: static const struct htmlman *const mans = __mans - MAN_TH;
1.3 kristaps 113:
1.93 schwarze 114:
1.74 kristaps 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.114 schwarze 124: print_bvspace(struct html *h, const struct roff_node *n)
1.74 kristaps 125: {
126:
127: if (n->body && n->body->child)
1.113 schwarze 128: if (n->body->child->type == ROFFT_TBL)
1.74 kristaps 129: return;
130:
1.113 schwarze 131: if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS)
1.74 kristaps 132: if (NULL == n->prev)
133: return;
134:
1.103 kristaps 135: print_paragraph(h);
1.74 kristaps 136: }
1.1 kristaps 137:
138: void
1.116 schwarze 139: html_man(void *arg, const struct roff_man *man)
1.1 kristaps 140: {
1.117 schwarze 141: struct html *h;
1.126 schwarze 142: struct tag *t;
1.82 kristaps 143:
1.117 schwarze 144: h = (struct html *)arg;
1.3 kristaps 145:
1.126 schwarze 146: if ((h->oflags & HTML_FRAGMENT) == 0) {
1.82 kristaps 147: print_gen_decls(h);
1.126 schwarze 148: print_otag(h, TAG_HTML, "");
149: t = print_otag(h, TAG_HEAD, "");
1.132 schwarze 150: print_man_head(&man->meta, man->first, h);
1.126 schwarze 151: print_tagq(h, t);
1.122 schwarze 152: print_otag(h, TAG_BODY, "");
1.126 schwarze 153: }
1.53 kristaps 154:
1.132 schwarze 155: man_root_pre(&man->meta, man->first, h);
1.127 schwarze 156: t = print_otag(h, TAG_DIV, "c", "manual-text");
1.132 schwarze 157: print_man_nodelist(&man->meta, man->first->child, h);
1.127 schwarze 158: print_tagq(h, t);
1.132 schwarze 159: man_root_post(&man->meta, man->first, h);
1.126 schwarze 160: print_tagq(h, NULL);
1.3 kristaps 161: }
162:
163: static void
164: print_man_head(MAN_ARGS)
165: {
1.123 schwarze 166: char *cp;
1.3 kristaps 167:
168: print_gen_head(h);
1.123 schwarze 169: mandoc_asprintf(&cp, "%s(%s)", man->title, man->msec);
1.122 schwarze 170: print_otag(h, TAG_TITLE, "");
1.123 schwarze 171: print_text(h, cp);
172: free(cp);
1.1 kristaps 173: }
1.4 kristaps 174:
175: static void
176: print_man_nodelist(MAN_ARGS)
177: {
178:
1.110 schwarze 179: while (n != NULL) {
1.132 schwarze 180: print_man_node(man, n, h);
1.110 schwarze 181: n = n->next;
182: }
1.4 kristaps 183: }
184:
185: static void
186: print_man_node(MAN_ARGS)
187: {
1.132 schwarze 188: static int want_fillmode = MAN_fi;
189: static int save_fillmode;
190:
191: struct tag *t;
1.4 kristaps 192: int child;
193:
1.132 schwarze 194: /*
195: * Handle fill mode switch requests up front,
196: * they would just cause trouble in the subsequent code.
197: */
198:
199: switch (n->tok) {
200: case MAN_nf:
201: case MAN_EX:
202: want_fillmode = MAN_nf;
203: return;
204: case MAN_fi:
205: case MAN_EE:
206: want_fillmode = MAN_fi;
207: if (fillmode(h, 0) == MAN_fi)
208: print_otag(h, TAG_BR, "");
209: return;
210: default:
211: break;
212: }
213:
214: /* Set up fill mode for the upcoming node. */
1.4 kristaps 215:
216: switch (n->type) {
1.132 schwarze 217: case ROFFT_BLOCK:
218: save_fillmode = 0;
219: /* Some block macros suspend or cancel .nf. */
220: switch (n->tok) {
221: case MAN_TP: /* Tagged paragraphs */
222: case MAN_IP: /* temporarily disable .nf */
223: case MAN_HP: /* for the head. */
224: save_fillmode = want_fillmode;
225: /* FALLTHROUGH */
226: case MAN_SH: /* Section headers */
227: case MAN_SS: /* permanently cancel .nf. */
228: want_fillmode = MAN_fi;
229: /* FALLTHROUGH */
230: case MAN_PP: /* These have no head. */
231: case MAN_LP: /* They will simply */
232: case MAN_P: /* reopen .nf in the body. */
233: case MAN_RS:
234: case MAN_UR:
1.145 ! schwarze 235: case MAN_MT:
1.132 schwarze 236: fillmode(h, MAN_fi);
237: break;
238: default:
239: break;
240: }
241: break;
242: case ROFFT_TBL:
243: fillmode(h, MAN_fi);
244: break;
245: case ROFFT_ELEM:
246: /*
247: * Some in-line macros produce tags and/or text
248: * in the handler, so they require fill mode to be
249: * configured up front just like for text nodes.
250: * For the others, keep the traditional approach
251: * of doing the same, for now.
252: */
253: fillmode(h, want_fillmode);
254: break;
1.113 schwarze 255: case ROFFT_TEXT:
1.132 schwarze 256: if (fillmode(h, want_fillmode) == MAN_fi &&
257: want_fillmode == MAN_fi &&
1.142 schwarze 258: n->flags & NODE_LINE && *n->string == ' ' &&
259: (h->flags & HTML_NONEWLINE) == 0)
1.122 schwarze 260: print_otag(h, TAG_BR, "");
1.132 schwarze 261: if (*n->string != '\0')
262: break;
263: print_paragraph(h);
264: return;
265: default:
266: break;
267: }
268:
269: /* Produce output for this node. */
270:
271: child = 1;
272: switch (n->type) {
273: case ROFFT_TEXT:
274: t = h->tag;
1.4 kristaps 275: print_text(h, n->string);
1.130 schwarze 276: break;
1.113 schwarze 277: case ROFFT_EQN:
1.132 schwarze 278: t = h->tag;
1.80 kristaps 279: print_eqn(h, n->eqn);
1.69 kristaps 280: break;
1.113 schwarze 281: case ROFFT_TBL:
1.66 kristaps 282: /*
283: * This will take care of initialising all of the table
284: * state data for the first table, then tearing it down
285: * for the last one.
286: */
1.60 kristaps 287: print_tbl(h, n->span);
1.64 kristaps 288: return;
1.4 kristaps 289: default:
1.93 schwarze 290: /*
1.21 kristaps 291: * Close out scope of font prior to opening a macro
1.66 kristaps 292: * scope.
1.21 kristaps 293: */
1.57 kristaps 294: if (HTMLFONT_NONE != h->metac) {
295: h->metal = h->metac;
296: h->metac = HTMLFONT_NONE;
1.66 kristaps 297: }
298:
299: /*
300: * Close out the current table, if it's open, and unset
301: * the "meta" table state. This will be reopened on the
302: * next table element.
303: */
1.132 schwarze 304: if (h->tblt)
1.66 kristaps 305: print_tblclose(h);
1.132 schwarze 306:
307: t = h->tag;
1.137 schwarze 308: if (n->tok < ROFF_MAX) {
1.138 schwarze 309: roff_html_pre(h, n);
1.141 schwarze 310: child = 0;
1.137 schwarze 311: break;
312: }
313:
314: assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
1.4 kristaps 315: if (mans[n->tok].pre)
1.132 schwarze 316: child = (*mans[n->tok].pre)(man, n, h);
317:
318: /* Some block macros resume .nf in the body. */
319: if (save_fillmode && n->type == ROFFT_BODY)
320: want_fillmode = save_fillmode;
321:
1.4 kristaps 322: break;
323: }
324:
1.21 kristaps 325: if (child && n->child)
1.132 schwarze 326: print_man_nodelist(man, n->child, h);
1.21 kristaps 327:
1.24 kristaps 328: /* This will automatically close out any font scope. */
1.132 schwarze 329: print_stagq(h, t);
330:
331: if (fillmode(h, 0) == MAN_nf &&
332: n->next != NULL && n->next->flags & NODE_LINE)
333: print_endline(h);
334: }
335:
336: /*
337: * MAN_nf switches to no-fill mode, MAN_fi to fill mode.
338: * Other arguments do not switch.
339: * The old mode is returned.
340: */
341: static int
342: fillmode(struct html *h, int want)
343: {
344: struct tag *pre;
345: int had;
1.4 kristaps 346:
1.132 schwarze 347: for (pre = h->tag; pre != NULL; pre = pre->next)
348: if (pre->tag == TAG_PRE)
349: break;
350:
351: had = pre == NULL ? MAN_fi : MAN_nf;
1.130 schwarze 352:
1.132 schwarze 353: if (want && want != had) {
354: if (want == MAN_nf)
355: print_otag(h, TAG_PRE, "");
356: else
357: print_tagq(h, pre);
358: }
359: return had;
1.4 kristaps 360: }
361:
1.5 kristaps 362: static int
1.114 schwarze 363: a2width(const struct roff_node *n, struct roffsu *su)
1.5 kristaps 364: {
1.113 schwarze 365: if (n->type != ROFFT_TEXT)
1.119 schwarze 366: return 0;
1.143 schwarze 367: return a2roffsu(n->string, su, SCALE_EN) != NULL;
1.5 kristaps 368: }
369:
1.65 kristaps 370: static void
1.4 kristaps 371: man_root_pre(MAN_ARGS)
372: {
373: struct tag *t, *tt;
1.94 schwarze 374: char *title;
1.4 kristaps 375:
1.89 schwarze 376: assert(man->title);
377: assert(man->msec);
1.94 schwarze 378: mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.4 kristaps 379:
1.122 schwarze 380: t = print_otag(h, TAG_TABLE, "c", "head");
381: tt = print_otag(h, TAG_TR, "");
1.4 kristaps 382:
1.122 schwarze 383: print_otag(h, TAG_TD, "c", "head-ltitle");
1.4 kristaps 384: print_text(h, title);
385: print_stagq(h, tt);
386:
1.122 schwarze 387: print_otag(h, TAG_TD, "c", "head-vol");
1.95 schwarze 388: if (NULL != man->vol)
389: print_text(h, man->vol);
1.4 kristaps 390: print_stagq(h, tt);
391:
1.122 schwarze 392: print_otag(h, TAG_TD, "c", "head-rtitle");
1.4 kristaps 393: print_text(h, title);
394: print_tagq(h, t);
1.94 schwarze 395: free(title);
1.4 kristaps 396: }
397:
398: static void
399: man_root_post(MAN_ARGS)
400: {
401: struct tag *t, *tt;
402:
1.122 schwarze 403: t = print_otag(h, TAG_TABLE, "c", "foot");
404: tt = print_otag(h, TAG_TR, "");
1.55 kristaps 405:
1.122 schwarze 406: print_otag(h, TAG_TD, "c", "foot-date");
1.89 schwarze 407: print_text(h, man->date);
1.4 kristaps 408: print_stagq(h, tt);
409:
1.122 schwarze 410: print_otag(h, TAG_TD, "c", "foot-os");
1.115 schwarze 411: if (man->os)
412: print_text(h, man->os);
1.4 kristaps 413: print_tagq(h, t);
414: }
415:
416: static int
417: man_SH_pre(MAN_ARGS)
418: {
1.134 schwarze 419: char *id;
420:
421: if (n->type == ROFFT_HEAD) {
422: id = html_make_id(n);
423: print_otag(h, TAG_H1, "cTi", "Sh", id);
1.135 schwarze 424: if (id != NULL)
425: print_otag(h, TAG_A, "chR", "selflink", id);
1.134 schwarze 426: free(id);
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) {
492: id = html_make_id(n);
493: print_otag(h, TAG_H2, "cTi", "Ss", id);
1.135 schwarze 494: if (id != NULL)
495: print_otag(h, TAG_A, "chR", "selflink", id);
1.134 schwarze 496: free(id);
497: }
1.119 schwarze 498: return 1;
1.4 kristaps 499: }
500:
501: static int
502: man_PP_pre(MAN_ARGS)
503: {
504:
1.113 schwarze 505: if (n->type == ROFFT_HEAD)
1.119 schwarze 506: return 0;
1.113 schwarze 507: else if (n->type == ROFFT_BLOCK)
1.74 kristaps 508: print_bvspace(h, n);
1.47 kristaps 509:
1.119 schwarze 510: return 1;
1.5 kristaps 511: }
512:
513: static int
514: man_IP_pre(MAN_ARGS)
515: {
1.114 schwarze 516: const struct roff_node *nn;
1.5 kristaps 517:
1.113 schwarze 518: if (n->type == ROFFT_BODY) {
1.129 schwarze 519: print_otag(h, TAG_DD, "c", "It-tag");
1.119 schwarze 520: return 1;
1.113 schwarze 521: } else if (n->type != ROFFT_HEAD) {
1.129 schwarze 522: print_otag(h, TAG_DL, "c", "Bl-tag");
1.119 schwarze 523: return 1;
1.6 kristaps 524: }
525:
1.78 kristaps 526: /* FIXME: width specification. */
527:
1.129 schwarze 528: print_otag(h, TAG_DT, "c", "It-tag");
1.6 kristaps 529:
1.59 schwarze 530: /* For IP, only print the first header element. */
1.7 kristaps 531:
1.59 schwarze 532: if (MAN_IP == n->tok && n->child)
1.132 schwarze 533: print_man_node(man, n->child, h);
1.27 kristaps 534:
1.59 schwarze 535: /* For TP, only print next-line header elements. */
1.6 kristaps 536:
1.91 schwarze 537: if (MAN_TP == n->tok) {
538: nn = n->child;
1.121 schwarze 539: while (NULL != nn && 0 == (NODE_LINE & nn->flags))
1.91 schwarze 540: nn = nn->next;
541: while (NULL != nn) {
1.132 schwarze 542: print_man_node(man, nn, h);
1.91 schwarze 543: nn = nn->next;
544: }
545: }
1.6 kristaps 546:
1.119 schwarze 547: return 0;
1.6 kristaps 548: }
549:
550: static int
551: man_HP_pre(MAN_ARGS)
552: {
1.122 schwarze 553: struct roffsu sum, sui;
1.114 schwarze 554: const struct roff_node *np;
1.6 kristaps 555:
1.113 schwarze 556: if (n->type == ROFFT_HEAD)
1.119 schwarze 557: return 0;
1.113 schwarze 558: else if (n->type != ROFFT_BLOCK)
1.119 schwarze 559: return 1;
1.72 kristaps 560:
1.77 kristaps 561: np = n->head->child;
1.6 kristaps 562:
1.122 schwarze 563: if (np == NULL || !a2width(np, &sum))
564: SCALE_HS_INIT(&sum, INDENT);
1.6 kristaps 565:
1.122 schwarze 566: sui.unit = sum.unit;
567: sui.scale = -sum.scale;
1.5 kristaps 568:
1.77 kristaps 569: print_bvspace(h, n);
1.127 schwarze 570: print_otag(h, TAG_DIV, "csului", "Pp", &sum, &sui);
1.119 schwarze 571: return 1;
1.4 kristaps 572: }
1.86 kristaps 573:
574: static int
575: man_OP_pre(MAN_ARGS)
576: {
577: struct tag *tt;
578:
579: print_text(h, "[");
580: h->flags |= HTML_NOSPACE;
1.128 schwarze 581: tt = print_otag(h, TAG_SPAN, "c", "Op");
1.86 kristaps 582:
583: if (NULL != (n = n->child)) {
1.122 schwarze 584: print_otag(h, TAG_B, "");
1.86 kristaps 585: print_text(h, n->string);
586: }
587:
588: print_stagq(h, tt);
589:
590: if (NULL != n && NULL != n->next) {
1.122 schwarze 591: print_otag(h, TAG_I, "");
1.86 kristaps 592: print_text(h, n->next->string);
593: }
594:
595: print_stagq(h, tt);
596: h->flags |= HTML_NOSPACE;
597: print_text(h, "]");
1.119 schwarze 598: return 0;
1.86 kristaps 599: }
600:
1.8 kristaps 601: static int
602: man_B_pre(MAN_ARGS)
603: {
1.122 schwarze 604: print_otag(h, TAG_B, "");
1.119 schwarze 605: return 1;
1.8 kristaps 606: }
607:
608: static int
609: man_I_pre(MAN_ARGS)
610: {
1.122 schwarze 611: print_otag(h, TAG_I, "");
1.119 schwarze 612: return 1;
1.45 kristaps 613: }
614:
615: static int
616: man_in_pre(MAN_ARGS)
617: {
1.122 schwarze 618: print_otag(h, TAG_BR, "");
1.119 schwarze 619: return 0;
1.8 kristaps 620: }
621:
622: static int
623: man_ign_pre(MAN_ARGS)
624: {
625:
1.119 schwarze 626: return 0;
1.8 kristaps 627: }
1.9 kristaps 628:
629: static int
630: man_RS_pre(MAN_ARGS)
631: {
632: struct roffsu su;
633:
1.113 schwarze 634: if (n->type == ROFFT_HEAD)
1.119 schwarze 635: return 0;
1.113 schwarze 636: else if (n->type == ROFFT_BODY)
1.119 schwarze 637: return 1;
1.9 kristaps 638:
639: SCALE_HS_INIT(&su, INDENT);
1.56 kristaps 640: if (n->head->child)
1.9 kristaps 641: a2width(n->head->child, &su);
642:
1.122 schwarze 643: print_otag(h, TAG_DIV, "sul", &su);
1.119 schwarze 644: return 1;
1.90 schwarze 645: }
646:
647: static int
648: man_UR_pre(MAN_ARGS)
649: {
1.145 ! schwarze 650: char *cp;
1.90 schwarze 651: n = n->child;
1.113 schwarze 652: assert(n->type == ROFFT_HEAD);
1.120 schwarze 653: if (n->child != NULL) {
1.113 schwarze 654: assert(n->child->type == ROFFT_TEXT);
1.145 ! schwarze 655: if (n->tok == MAN_MT) {
! 656: mandoc_asprintf(&cp, "mailto:%s", n->child->string);
! 657: print_otag(h, TAG_A, "cTh", "Mt", cp);
! 658: free(cp);
! 659: } else
! 660: print_otag(h, TAG_A, "cTh", "Lk", n->child->string);
1.90 schwarze 661: }
662:
1.113 schwarze 663: assert(n->next->type == ROFFT_BODY);
1.120 schwarze 664: if (n->next->child != NULL)
1.90 schwarze 665: n = n->next;
666:
1.132 schwarze 667: print_man_nodelist(man, n->child, h);
1.90 schwarze 668:
1.119 schwarze 669: return 0;
1.9 kristaps 670: }
CVSweb