Annotation of src/usr.bin/mandoc/man_html.c, Revision 1.100
1.100 ! schwarze 1: /* $OpenBSD: man_html.c,v 1.99 2018/04/11 17:10:35 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:
36: #define INDENT 5
37:
1.68 schwarze 38: #define MAN_ARGS const struct roff_meta *man, \
1.67 schwarze 39: const struct roff_node *n, \
1.1 schwarze 40: struct html *h
41:
42: struct htmlman {
43: int (*pre)(MAN_ARGS);
44: int (*post)(MAN_ARGS);
45: };
46:
1.52 schwarze 47: static void print_bvspace(struct html *,
1.67 schwarze 48: const struct roff_node *);
1.100 ! schwarze 49: static void print_man_head(const struct roff_meta *,
! 50: struct html *);
1.1 schwarze 51: static void print_man_nodelist(MAN_ARGS);
52: static void print_man_node(MAN_ARGS);
1.85 schwarze 53: static int fillmode(struct html *, int);
1.67 schwarze 54: static int a2width(const struct roff_node *,
1.1 schwarze 55: struct roffsu *);
56: static int man_B_pre(MAN_ARGS);
57: static int man_HP_pre(MAN_ARGS);
1.46 schwarze 58: static int man_IP_pre(MAN_ARGS);
1.1 schwarze 59: static int man_I_pre(MAN_ARGS);
1.46 schwarze 60: static int man_OP_pre(MAN_ARGS);
1.1 schwarze 61: static int man_PP_pre(MAN_ARGS);
62: static int man_RS_pre(MAN_ARGS);
63: static int man_SH_pre(MAN_ARGS);
64: static int man_SM_pre(MAN_ARGS);
65: static int man_SS_pre(MAN_ARGS);
1.49 schwarze 66: static int man_UR_pre(MAN_ARGS);
1.46 schwarze 67: static int man_alt_pre(MAN_ARGS);
68: static int man_ign_pre(MAN_ARGS);
69: static int man_in_pre(MAN_ARGS);
1.100 ! schwarze 70: static void man_root_post(const struct roff_meta *,
! 71: struct html *);
! 72: static void man_root_pre(const struct roff_meta *,
! 73: struct html *);
1.1 schwarze 74:
1.89 schwarze 75: static const struct htmlman __mans[MAN_MAX - MAN_TH] = {
1.1 schwarze 76: { NULL, NULL }, /* TH */
77: { man_SH_pre, NULL }, /* SH */
78: { man_SS_pre, NULL }, /* SS */
79: { man_IP_pre, NULL }, /* TP */
80: { man_PP_pre, NULL }, /* LP */
81: { man_PP_pre, NULL }, /* PP */
82: { man_PP_pre, NULL }, /* P */
83: { man_IP_pre, NULL }, /* IP */
1.52 schwarze 84: { man_HP_pre, NULL }, /* HP */
1.1 schwarze 85: { man_SM_pre, NULL }, /* SM */
1.26 schwarze 86: { man_SM_pre, NULL }, /* SB */
1.1 schwarze 87: { man_alt_pre, NULL }, /* BI */
88: { man_alt_pre, NULL }, /* IB */
89: { man_alt_pre, NULL }, /* BR */
90: { man_alt_pre, NULL }, /* RB */
91: { NULL, NULL }, /* R */
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.85 schwarze 96: { NULL, NULL }, /* nf */
97: { NULL, NULL }, /* fi */
1.1 schwarze 98: { NULL, NULL }, /* RE */
99: { man_RS_pre, NULL }, /* RS */
100: { man_ign_pre, NULL }, /* DT */
101: { man_ign_pre, NULL }, /* UC */
1.2 schwarze 102: { man_ign_pre, NULL }, /* PD */
1.13 schwarze 103: { man_ign_pre, NULL }, /* AT */
1.18 schwarze 104: { man_in_pre, NULL }, /* in */
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: };
1.89 schwarze 113: static const struct htmlman *const mans = __mans - MAN_TH;
1.1 schwarze 114:
1.52 schwarze 115:
1.39 schwarze 116: /*
117: * Printing leading vertical space before a block.
118: * This is used for the paragraph macros.
119: * The rules are pretty simple, since there's very little nesting going
120: * on here. Basically, if we're the first within another block (SS/SH),
121: * then don't emit vertical space. If we are (RS), then do. If not the
122: * first, print it.
123: */
124: static void
1.67 schwarze 125: print_bvspace(struct html *h, const struct roff_node *n)
1.39 schwarze 126: {
127:
128: if (n->body && n->body->child)
1.66 schwarze 129: if (n->body->child->type == ROFFT_TBL)
1.39 schwarze 130: return;
131:
1.66 schwarze 132: if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS)
1.39 schwarze 133: if (NULL == n->prev)
134: return;
135:
1.56 schwarze 136: print_paragraph(h);
1.39 schwarze 137: }
1.1 schwarze 138:
139: void
1.69 schwarze 140: html_man(void *arg, const struct roff_man *man)
1.1 schwarze 141: {
1.100 ! schwarze 142: struct html *h;
! 143: struct roff_node *n;
! 144: struct tag *t;
1.43 schwarze 145:
1.70 schwarze 146: h = (struct html *)arg;
1.100 ! schwarze 147: n = man->first->child;
1.1 schwarze 148:
1.79 schwarze 149: if ((h->oflags & HTML_FRAGMENT) == 0) {
1.43 schwarze 150: print_gen_decls(h);
1.79 schwarze 151: print_otag(h, TAG_HTML, "");
1.100 ! schwarze 152: if (n->type == ROFFT_COMMENT)
! 153: print_gen_comment(h, n);
1.79 schwarze 154: t = print_otag(h, TAG_HEAD, "");
1.100 ! schwarze 155: print_man_head(&man->meta, h);
1.79 schwarze 156: print_tagq(h, t);
1.75 schwarze 157: print_otag(h, TAG_BODY, "");
1.79 schwarze 158: }
1.25 schwarze 159:
1.100 ! schwarze 160: man_root_pre(&man->meta, h);
1.80 schwarze 161: t = print_otag(h, TAG_DIV, "c", "manual-text");
1.100 ! schwarze 162: print_man_nodelist(&man->meta, n, h);
1.80 schwarze 163: print_tagq(h, t);
1.100 ! schwarze 164: man_root_post(&man->meta, h);
1.79 schwarze 165: print_tagq(h, NULL);
1.1 schwarze 166: }
167:
168: static void
1.100 ! schwarze 169: print_man_head(const struct roff_meta *man, struct html *h)
1.1 schwarze 170: {
1.76 schwarze 171: char *cp;
1.1 schwarze 172:
173: print_gen_head(h);
1.76 schwarze 174: mandoc_asprintf(&cp, "%s(%s)", man->title, man->msec);
1.75 schwarze 175: print_otag(h, TAG_TITLE, "");
1.76 schwarze 176: print_text(h, cp);
177: free(cp);
1.1 schwarze 178: }
179:
180: static void
181: print_man_nodelist(MAN_ARGS)
182: {
183:
1.63 schwarze 184: while (n != NULL) {
1.85 schwarze 185: print_man_node(man, n, h);
1.63 schwarze 186: n = n->next;
187: }
1.1 schwarze 188: }
189:
190: static void
191: print_man_node(MAN_ARGS)
192: {
1.85 schwarze 193: static int want_fillmode = MAN_fi;
194: static int save_fillmode;
195:
196: struct tag *t;
1.1 schwarze 197: int child;
198:
1.85 schwarze 199: /*
200: * Handle fill mode switch requests up front,
201: * they would just cause trouble in the subsequent code.
202: */
203:
204: switch (n->tok) {
205: case MAN_nf:
206: case MAN_EX:
207: want_fillmode = MAN_nf;
208: return;
209: case MAN_fi:
210: case MAN_EE:
211: want_fillmode = MAN_fi;
212: if (fillmode(h, 0) == MAN_fi)
213: print_otag(h, TAG_BR, "");
214: return;
215: default:
216: break;
217: }
218:
219: /* Set up fill mode for the upcoming node. */
1.1 schwarze 220:
221: switch (n->type) {
1.85 schwarze 222: case ROFFT_BLOCK:
223: save_fillmode = 0;
224: /* Some block macros suspend or cancel .nf. */
225: switch (n->tok) {
226: case MAN_TP: /* Tagged paragraphs */
227: case MAN_IP: /* temporarily disable .nf */
228: case MAN_HP: /* for the head. */
229: save_fillmode = want_fillmode;
230: /* FALLTHROUGH */
231: case MAN_SH: /* Section headers */
232: case MAN_SS: /* permanently cancel .nf. */
233: want_fillmode = MAN_fi;
234: /* FALLTHROUGH */
235: case MAN_PP: /* These have no head. */
236: case MAN_LP: /* They will simply */
237: case MAN_P: /* reopen .nf in the body. */
238: case MAN_RS:
239: case MAN_UR:
1.98 bentley 240: case MAN_MT:
1.85 schwarze 241: fillmode(h, MAN_fi);
242: break;
243: default:
244: break;
245: }
246: break;
247: case ROFFT_TBL:
248: fillmode(h, MAN_fi);
249: break;
250: case ROFFT_ELEM:
251: /*
252: * Some in-line macros produce tags and/or text
253: * in the handler, so they require fill mode to be
254: * configured up front just like for text nodes.
255: * For the others, keep the traditional approach
256: * of doing the same, for now.
257: */
258: fillmode(h, want_fillmode);
259: break;
1.66 schwarze 260: case ROFFT_TEXT:
1.85 schwarze 261: if (fillmode(h, want_fillmode) == MAN_fi &&
262: want_fillmode == MAN_fi &&
1.95 schwarze 263: n->flags & NODE_LINE && *n->string == ' ' &&
264: (h->flags & HTML_NONEWLINE) == 0)
1.75 schwarze 265: print_otag(h, TAG_BR, "");
1.85 schwarze 266: if (*n->string != '\0')
267: break;
268: print_paragraph(h);
1.99 schwarze 269: return;
270: case ROFFT_COMMENT:
1.85 schwarze 271: return;
272: default:
273: break;
274: }
275:
276: /* Produce output for this node. */
277:
278: child = 1;
279: switch (n->type) {
280: case ROFFT_TEXT:
281: t = h->tag;
1.1 schwarze 282: print_text(h, n->string);
1.83 schwarze 283: break;
1.66 schwarze 284: case ROFFT_EQN:
1.85 schwarze 285: t = h->tag;
1.41 schwarze 286: print_eqn(h, n->eqn);
1.37 schwarze 287: break;
1.66 schwarze 288: case ROFFT_TBL:
1.33 schwarze 289: /*
290: * This will take care of initialising all of the table
291: * state data for the first table, then tearing it down
292: * for the last one.
293: */
1.29 schwarze 294: print_tbl(h, n->span);
1.32 schwarze 295: return;
1.1 schwarze 296: default:
1.52 schwarze 297: /*
1.4 schwarze 298: * Close out scope of font prior to opening a macro
1.33 schwarze 299: * scope.
1.4 schwarze 300: */
1.27 schwarze 301: if (HTMLFONT_NONE != h->metac) {
302: h->metal = h->metac;
303: h->metac = HTMLFONT_NONE;
1.33 schwarze 304: }
305:
306: /*
307: * Close out the current table, if it's open, and unset
308: * the "meta" table state. This will be reopened on the
309: * next table element.
310: */
1.85 schwarze 311: if (h->tblt)
1.33 schwarze 312: print_tblclose(h);
1.85 schwarze 313:
314: t = h->tag;
1.90 schwarze 315: if (n->tok < ROFF_MAX) {
1.91 schwarze 316: roff_html_pre(h, n);
1.94 schwarze 317: child = 0;
1.90 schwarze 318: break;
319: }
320:
321: assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
1.1 schwarze 322: if (mans[n->tok].pre)
1.85 schwarze 323: child = (*mans[n->tok].pre)(man, n, h);
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:
369: static int
1.67 schwarze 370: a2width(const struct roff_node *n, struct roffsu *su)
1.1 schwarze 371: {
1.66 schwarze 372: if (n->type != ROFFT_TEXT)
1.72 schwarze 373: return 0;
1.96 schwarze 374: return a2roffsu(n->string, su, SCALE_EN) != NULL;
1.1 schwarze 375: }
376:
1.38 schwarze 377: static void
1.100 ! schwarze 378: man_root_pre(const struct roff_meta *man, struct html *h)
1.1 schwarze 379: {
380: struct tag *t, *tt;
1.53 schwarze 381: char *title;
1.1 schwarze 382:
1.48 schwarze 383: assert(man->title);
384: assert(man->msec);
1.53 schwarze 385: mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.1 schwarze 386:
1.75 schwarze 387: t = print_otag(h, TAG_TABLE, "c", "head");
388: tt = print_otag(h, TAG_TR, "");
1.1 schwarze 389:
1.75 schwarze 390: print_otag(h, TAG_TD, "c", "head-ltitle");
1.1 schwarze 391: print_text(h, title);
392: print_stagq(h, tt);
393:
1.75 schwarze 394: print_otag(h, TAG_TD, "c", "head-vol");
1.54 schwarze 395: if (NULL != man->vol)
396: print_text(h, man->vol);
1.1 schwarze 397: print_stagq(h, tt);
398:
1.75 schwarze 399: print_otag(h, TAG_TD, "c", "head-rtitle");
1.1 schwarze 400: print_text(h, title);
401: print_tagq(h, t);
1.53 schwarze 402: free(title);
1.1 schwarze 403: }
404:
405: static void
1.100 ! schwarze 406: man_root_post(const struct roff_meta *man, struct html *h)
1.1 schwarze 407: {
408: struct tag *t, *tt;
409:
1.75 schwarze 410: t = print_otag(h, TAG_TABLE, "c", "foot");
411: tt = print_otag(h, TAG_TR, "");
1.25 schwarze 412:
1.75 schwarze 413: print_otag(h, TAG_TD, "c", "foot-date");
1.48 schwarze 414: print_text(h, man->date);
1.1 schwarze 415: print_stagq(h, tt);
416:
1.75 schwarze 417: print_otag(h, TAG_TD, "c", "foot-os");
1.68 schwarze 418: if (man->os)
419: print_text(h, man->os);
1.1 schwarze 420: print_tagq(h, t);
421: }
422:
423: static int
424: man_SH_pre(MAN_ARGS)
425: {
1.87 schwarze 426: char *id;
427:
428: if (n->type == ROFFT_HEAD) {
429: id = html_make_id(n);
430: print_otag(h, TAG_H1, "cTi", "Sh", id);
1.88 schwarze 431: if (id != NULL)
432: print_otag(h, TAG_A, "chR", "selflink", id);
1.87 schwarze 433: free(id);
434: }
1.72 schwarze 435: return 1;
1.1 schwarze 436: }
437:
438: static int
439: man_alt_pre(MAN_ARGS)
440: {
1.67 schwarze 441: const struct roff_node *nn;
1.83 schwarze 442: int i;
1.27 schwarze 443: enum htmltag fp;
444: struct tag *t;
1.1 schwarze 445:
446: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
447: switch (n->tok) {
1.52 schwarze 448: case MAN_BI:
1.27 schwarze 449: fp = i % 2 ? TAG_I : TAG_B;
1.1 schwarze 450: break;
1.52 schwarze 451: case MAN_IB:
1.27 schwarze 452: fp = i % 2 ? TAG_B : TAG_I;
1.1 schwarze 453: break;
1.52 schwarze 454: case MAN_RI:
1.27 schwarze 455: fp = i % 2 ? TAG_I : TAG_MAX;
1.1 schwarze 456: break;
1.52 schwarze 457: case MAN_IR:
1.27 schwarze 458: fp = i % 2 ? TAG_MAX : TAG_I;
1.1 schwarze 459: break;
1.52 schwarze 460: case MAN_BR:
1.27 schwarze 461: fp = i % 2 ? TAG_MAX : TAG_B;
1.1 schwarze 462: break;
1.52 schwarze 463: case MAN_RB:
1.27 schwarze 464: fp = i % 2 ? TAG_B : TAG_MAX;
1.1 schwarze 465: break;
466: default:
467: abort();
468: }
469:
470: if (i)
471: h->flags |= HTML_NOSPACE;
472:
1.83 schwarze 473: if (fp != TAG_MAX)
1.75 schwarze 474: t = print_otag(h, fp, "");
1.27 schwarze 475:
1.83 schwarze 476: print_text(h, nn->string);
1.27 schwarze 477:
1.83 schwarze 478: if (fp != TAG_MAX)
1.27 schwarze 479: print_tagq(h, t);
1.1 schwarze 480: }
1.72 schwarze 481: return 0;
1.1 schwarze 482: }
483:
484: static int
1.26 schwarze 485: man_SM_pre(MAN_ARGS)
1.1 schwarze 486: {
1.75 schwarze 487: print_otag(h, TAG_SMALL, "");
1.26 schwarze 488: if (MAN_SB == n->tok)
1.75 schwarze 489: print_otag(h, TAG_B, "");
1.72 schwarze 490: return 1;
1.1 schwarze 491: }
492:
493: static int
494: man_SS_pre(MAN_ARGS)
495: {
1.87 schwarze 496: char *id;
497:
498: if (n->type == ROFFT_HEAD) {
499: id = html_make_id(n);
500: print_otag(h, TAG_H2, "cTi", "Ss", id);
1.88 schwarze 501: if (id != NULL)
502: print_otag(h, TAG_A, "chR", "selflink", id);
1.87 schwarze 503: free(id);
504: }
1.72 schwarze 505: return 1;
1.1 schwarze 506: }
507:
508: static int
509: man_PP_pre(MAN_ARGS)
510: {
511:
1.66 schwarze 512: if (n->type == ROFFT_HEAD)
1.72 schwarze 513: return 0;
1.66 schwarze 514: else if (n->type == ROFFT_BLOCK)
1.39 schwarze 515: print_bvspace(h, n);
1.22 schwarze 516:
1.72 schwarze 517: return 1;
1.1 schwarze 518: }
519:
520: static int
521: man_IP_pre(MAN_ARGS)
522: {
1.67 schwarze 523: const struct roff_node *nn;
1.1 schwarze 524:
1.66 schwarze 525: if (n->type == ROFFT_BODY) {
1.82 schwarze 526: print_otag(h, TAG_DD, "c", "It-tag");
1.72 schwarze 527: return 1;
1.66 schwarze 528: } else if (n->type != ROFFT_HEAD) {
1.82 schwarze 529: print_otag(h, TAG_DL, "c", "Bl-tag");
1.72 schwarze 530: return 1;
1.1 schwarze 531: }
532:
1.40 schwarze 533: /* FIXME: width specification. */
1.7 schwarze 534:
1.82 schwarze 535: print_otag(h, TAG_DT, "c", "It-tag");
1.1 schwarze 536:
1.28 schwarze 537: /* For IP, only print the first header element. */
1.1 schwarze 538:
1.28 schwarze 539: if (MAN_IP == n->tok && n->child)
1.85 schwarze 540: print_man_node(man, n->child, h);
1.7 schwarze 541:
1.28 schwarze 542: /* For TP, only print next-line header elements. */
1.1 schwarze 543:
1.50 schwarze 544: if (MAN_TP == n->tok) {
545: nn = n->child;
1.74 schwarze 546: while (NULL != nn && 0 == (NODE_LINE & nn->flags))
1.50 schwarze 547: nn = nn->next;
548: while (NULL != nn) {
1.85 schwarze 549: print_man_node(man, nn, h);
1.50 schwarze 550: nn = nn->next;
551: }
552: }
1.1 schwarze 553:
1.72 schwarze 554: return 0;
1.1 schwarze 555: }
556:
557: static int
558: man_HP_pre(MAN_ARGS)
559: {
1.75 schwarze 560: struct roffsu sum, sui;
1.67 schwarze 561: const struct roff_node *np;
1.1 schwarze 562:
1.66 schwarze 563: if (n->type == ROFFT_HEAD)
1.72 schwarze 564: return 0;
1.66 schwarze 565: else if (n->type != ROFFT_BLOCK)
1.72 schwarze 566: return 1;
1.38 schwarze 567:
1.40 schwarze 568: np = n->head->child;
1.1 schwarze 569:
1.75 schwarze 570: if (np == NULL || !a2width(np, &sum))
571: SCALE_HS_INIT(&sum, INDENT);
1.1 schwarze 572:
1.75 schwarze 573: sui.unit = sum.unit;
574: sui.scale = -sum.scale;
1.1 schwarze 575:
1.40 schwarze 576: print_bvspace(h, n);
1.80 schwarze 577: print_otag(h, TAG_DIV, "csului", "Pp", &sum, &sui);
1.72 schwarze 578: return 1;
1.1 schwarze 579: }
1.46 schwarze 580:
581: static int
582: man_OP_pre(MAN_ARGS)
583: {
584: struct tag *tt;
585:
586: print_text(h, "[");
587: h->flags |= HTML_NOSPACE;
1.81 schwarze 588: tt = print_otag(h, TAG_SPAN, "c", "Op");
1.46 schwarze 589:
590: if (NULL != (n = n->child)) {
1.75 schwarze 591: print_otag(h, TAG_B, "");
1.46 schwarze 592: print_text(h, n->string);
593: }
594:
595: print_stagq(h, tt);
596:
597: if (NULL != n && NULL != n->next) {
1.75 schwarze 598: print_otag(h, TAG_I, "");
1.46 schwarze 599: print_text(h, n->next->string);
600: }
601:
602: print_stagq(h, tt);
603: h->flags |= HTML_NOSPACE;
604: print_text(h, "]");
1.72 schwarze 605: return 0;
1.46 schwarze 606: }
607:
1.1 schwarze 608: static int
609: man_B_pre(MAN_ARGS)
610: {
1.75 schwarze 611: print_otag(h, TAG_B, "");
1.72 schwarze 612: return 1;
1.1 schwarze 613: }
614:
615: static int
616: man_I_pre(MAN_ARGS)
617: {
1.75 schwarze 618: print_otag(h, TAG_I, "");
1.72 schwarze 619: return 1;
1.18 schwarze 620: }
621:
622: static int
623: man_in_pre(MAN_ARGS)
624: {
1.75 schwarze 625: print_otag(h, TAG_BR, "");
1.72 schwarze 626: return 0;
1.1 schwarze 627: }
628:
629: static int
630: man_ign_pre(MAN_ARGS)
631: {
632:
1.72 schwarze 633: return 0;
1.1 schwarze 634: }
635:
636: static int
637: man_RS_pre(MAN_ARGS)
638: {
639: struct roffsu su;
640:
1.66 schwarze 641: if (n->type == ROFFT_HEAD)
1.72 schwarze 642: return 0;
1.66 schwarze 643: else if (n->type == ROFFT_BODY)
1.72 schwarze 644: return 1;
1.1 schwarze 645:
646: SCALE_HS_INIT(&su, INDENT);
1.26 schwarze 647: if (n->head->child)
1.1 schwarze 648: a2width(n->head->child, &su);
649:
1.75 schwarze 650: print_otag(h, TAG_DIV, "sul", &su);
1.72 schwarze 651: return 1;
1.49 schwarze 652: }
653:
654: static int
655: man_UR_pre(MAN_ARGS)
656: {
1.98 bentley 657: char *cp;
1.49 schwarze 658: n = n->child;
1.66 schwarze 659: assert(n->type == ROFFT_HEAD);
1.73 schwarze 660: if (n->child != NULL) {
1.66 schwarze 661: assert(n->child->type == ROFFT_TEXT);
1.98 bentley 662: if (n->tok == MAN_MT) {
663: mandoc_asprintf(&cp, "mailto:%s", n->child->string);
664: print_otag(h, TAG_A, "cTh", "Mt", cp);
665: free(cp);
666: } else
667: print_otag(h, TAG_A, "cTh", "Lk", n->child->string);
1.49 schwarze 668: }
669:
1.66 schwarze 670: assert(n->next->type == ROFFT_BODY);
1.73 schwarze 671: if (n->next->child != NULL)
1.49 schwarze 672: n = n->next;
673:
1.85 schwarze 674: print_man_nodelist(man, n->child, h);
1.49 schwarze 675:
1.72 schwarze 676: return 0;
1.1 schwarze 677: }