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