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