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