Annotation of mandoc/man_html.c, Revision 1.139
1.139 ! schwarze 1: /* $Id: man_html.c,v 1.138 2017/05/04 22:16:09 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.113 schwarze 29: #include "roff.h"
1.105 schwarze 30: #include "man.h"
1.7 kristaps 31: #include "out.h"
1.1 kristaps 32: #include "html.h"
1.10 kristaps 33: #include "main.h"
1.1 kristaps 34:
1.13 kristaps 35: /* FIXME: have PD set the default vspace width. */
1.6 kristaps 36:
37: #define INDENT 5
1.4 kristaps 38:
1.115 schwarze 39: #define MAN_ARGS const struct roff_meta *man, \
1.114 schwarze 40: const struct roff_node *n, \
1.3 kristaps 41: struct html *h
42:
43: struct htmlman {
44: int (*pre)(MAN_ARGS);
45: int (*post)(MAN_ARGS);
46: };
47:
1.93 schwarze 48: static void print_bvspace(struct html *,
1.114 schwarze 49: const struct roff_node *);
1.3 kristaps 50: static void print_man_head(MAN_ARGS);
1.4 kristaps 51: static void print_man_nodelist(MAN_ARGS);
52: static void print_man_node(MAN_ARGS);
1.132 schwarze 53: static int fillmode(struct html *, int);
1.114 schwarze 54: static int a2width(const struct roff_node *,
1.7 kristaps 55: struct roffsu *);
1.8 kristaps 56: static int man_B_pre(MAN_ARGS);
1.6 kristaps 57: static int man_HP_pre(MAN_ARGS);
1.86 kristaps 58: static int man_IP_pre(MAN_ARGS);
1.8 kristaps 59: static int man_I_pre(MAN_ARGS);
1.86 kristaps 60: static int man_OP_pre(MAN_ARGS);
1.4 kristaps 61: static int man_PP_pre(MAN_ARGS);
1.9 kristaps 62: static int man_RS_pre(MAN_ARGS);
1.4 kristaps 63: static int man_SH_pre(MAN_ARGS);
1.8 kristaps 64: static int man_SM_pre(MAN_ARGS);
1.4 kristaps 65: static int man_SS_pre(MAN_ARGS);
1.90 schwarze 66: static int man_UR_pre(MAN_ARGS);
1.86 kristaps 67: static int man_alt_pre(MAN_ARGS);
68: static int man_ign_pre(MAN_ARGS);
69: static int man_in_pre(MAN_ARGS);
70: static void man_root_post(MAN_ARGS);
71: static void man_root_pre(MAN_ARGS);
1.138 schwarze 72: static int man_sp_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.138 schwarze 95: { man_sp_pre, NULL }, /* sp */
1.132 schwarze 96: { NULL, NULL }, /* nf */
97: { NULL, NULL }, /* fi */
1.3 kristaps 98: { NULL, NULL }, /* RE */
1.9 kristaps 99: { man_RS_pre, NULL }, /* RS */
1.8 kristaps 100: { man_ign_pre, NULL }, /* DT */
101: { man_ign_pre, NULL }, /* UC */
1.13 kristaps 102: { man_ign_pre, NULL }, /* PD */
1.34 joerg 103: { man_ign_pre, NULL }, /* AT */
1.45 kristaps 104: { man_in_pre, NULL }, /* in */
1.86 kristaps 105: { man_OP_pre, NULL }, /* OP */
1.132 schwarze 106: { NULL, NULL }, /* EX */
107: { NULL, NULL }, /* EE */
1.90 schwarze 108: { man_UR_pre, NULL }, /* UR */
109: { NULL, NULL }, /* UE */
1.92 schwarze 110: { man_ign_pre, NULL }, /* ll */
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:
235: fillmode(h, MAN_fi);
236: break;
237: default:
238: break;
239: }
240: break;
241: case ROFFT_TBL:
242: fillmode(h, MAN_fi);
243: break;
244: case ROFFT_ELEM:
245: /*
246: * Some in-line macros produce tags and/or text
247: * in the handler, so they require fill mode to be
248: * configured up front just like for text nodes.
249: * For the others, keep the traditional approach
250: * of doing the same, for now.
251: */
252: fillmode(h, want_fillmode);
253: break;
1.113 schwarze 254: case ROFFT_TEXT:
1.132 schwarze 255: if (fillmode(h, want_fillmode) == MAN_fi &&
256: want_fillmode == MAN_fi &&
1.130 schwarze 257: n->flags & NODE_LINE && *n->string == ' ')
1.122 schwarze 258: print_otag(h, TAG_BR, "");
1.132 schwarze 259: if (*n->string != '\0')
260: break;
261: print_paragraph(h);
262: return;
263: default:
264: break;
265: }
266:
267: /* Produce output for this node. */
268:
269: child = 1;
270: switch (n->type) {
271: case ROFFT_TEXT:
272: t = h->tag;
1.4 kristaps 273: print_text(h, n->string);
1.130 schwarze 274: break;
1.113 schwarze 275: case ROFFT_EQN:
1.132 schwarze 276: t = h->tag;
1.80 kristaps 277: print_eqn(h, n->eqn);
1.69 kristaps 278: break;
1.113 schwarze 279: case ROFFT_TBL:
1.66 kristaps 280: /*
281: * This will take care of initialising all of the table
282: * state data for the first table, then tearing it down
283: * for the last one.
284: */
1.60 kristaps 285: print_tbl(h, n->span);
1.64 kristaps 286: return;
1.4 kristaps 287: default:
1.93 schwarze 288: /*
1.21 kristaps 289: * Close out scope of font prior to opening a macro
1.66 kristaps 290: * scope.
1.21 kristaps 291: */
1.57 kristaps 292: if (HTMLFONT_NONE != h->metac) {
293: h->metal = h->metac;
294: h->metac = HTMLFONT_NONE;
1.66 kristaps 295: }
296:
297: /*
298: * Close out the current table, if it's open, and unset
299: * the "meta" table state. This will be reopened on the
300: * next table element.
301: */
1.132 schwarze 302: if (h->tblt)
1.66 kristaps 303: print_tblclose(h);
1.132 schwarze 304:
305: t = h->tag;
1.137 schwarze 306: if (n->tok < ROFF_MAX) {
1.138 schwarze 307: roff_html_pre(h, n);
1.137 schwarze 308: break;
309: }
310:
311: assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
1.4 kristaps 312: if (mans[n->tok].pre)
1.132 schwarze 313: child = (*mans[n->tok].pre)(man, n, h);
314:
315: /* Some block macros resume .nf in the body. */
316: if (save_fillmode && n->type == ROFFT_BODY)
317: want_fillmode = save_fillmode;
318:
1.4 kristaps 319: break;
320: }
321:
1.21 kristaps 322: if (child && n->child)
1.132 schwarze 323: print_man_nodelist(man, n->child, h);
1.21 kristaps 324:
1.24 kristaps 325: /* This will automatically close out any font scope. */
1.132 schwarze 326: print_stagq(h, t);
327:
328: if (fillmode(h, 0) == MAN_nf &&
329: n->next != NULL && n->next->flags & NODE_LINE)
330: print_endline(h);
331: }
332:
333: /*
334: * MAN_nf switches to no-fill mode, MAN_fi to fill mode.
335: * Other arguments do not switch.
336: * The old mode is returned.
337: */
338: static int
339: fillmode(struct html *h, int want)
340: {
341: struct tag *pre;
342: int had;
1.4 kristaps 343:
1.132 schwarze 344: for (pre = h->tag; pre != NULL; pre = pre->next)
345: if (pre->tag == TAG_PRE)
346: break;
347:
348: had = pre == NULL ? MAN_fi : MAN_nf;
1.130 schwarze 349:
1.132 schwarze 350: if (want && want != had) {
351: if (want == MAN_nf)
352: print_otag(h, TAG_PRE, "");
353: else
354: print_tagq(h, pre);
355: }
356: return had;
1.4 kristaps 357: }
358:
1.5 kristaps 359: static int
1.114 schwarze 360: a2width(const struct roff_node *n, struct roffsu *su)
1.5 kristaps 361: {
362:
1.113 schwarze 363: if (n->type != ROFFT_TEXT)
1.119 schwarze 364: return 0;
1.107 schwarze 365: if (a2roffsu(n->string, su, SCALE_EN))
1.119 schwarze 366: return 1;
1.5 kristaps 367:
1.119 schwarze 368: return 0;
1.5 kristaps 369: }
370:
1.65 kristaps 371: static void
1.4 kristaps 372: man_root_pre(MAN_ARGS)
373: {
374: struct tag *t, *tt;
1.94 schwarze 375: char *title;
1.4 kristaps 376:
1.89 schwarze 377: assert(man->title);
378: assert(man->msec);
1.94 schwarze 379: mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.4 kristaps 380:
1.122 schwarze 381: t = print_otag(h, TAG_TABLE, "c", "head");
382: tt = print_otag(h, TAG_TR, "");
1.4 kristaps 383:
1.122 schwarze 384: print_otag(h, TAG_TD, "c", "head-ltitle");
1.4 kristaps 385: print_text(h, title);
386: print_stagq(h, tt);
387:
1.122 schwarze 388: print_otag(h, TAG_TD, "c", "head-vol");
1.95 schwarze 389: if (NULL != man->vol)
390: print_text(h, man->vol);
1.4 kristaps 391: print_stagq(h, tt);
392:
1.122 schwarze 393: print_otag(h, TAG_TD, "c", "head-rtitle");
1.4 kristaps 394: print_text(h, title);
395: print_tagq(h, t);
1.94 schwarze 396: free(title);
1.4 kristaps 397: }
398:
399: static void
400: man_root_post(MAN_ARGS)
401: {
402: struct tag *t, *tt;
403:
1.122 schwarze 404: t = print_otag(h, TAG_TABLE, "c", "foot");
405: tt = print_otag(h, TAG_TR, "");
1.55 kristaps 406:
1.122 schwarze 407: print_otag(h, TAG_TD, "c", "foot-date");
1.89 schwarze 408: print_text(h, man->date);
1.4 kristaps 409: print_stagq(h, tt);
410:
1.122 schwarze 411: print_otag(h, TAG_TD, "c", "foot-os");
1.115 schwarze 412: if (man->os)
413: print_text(h, man->os);
1.4 kristaps 414: print_tagq(h, t);
415: }
416:
417:
418: static int
1.138 schwarze 419: man_sp_pre(MAN_ARGS)
1.4 kristaps 420: {
1.7 kristaps 421: struct roffsu su;
1.4 kristaps 422:
1.7 kristaps 423: SCALE_VS_INIT(&su, 1);
1.138 schwarze 424: if (NULL != (n = n->child))
425: if ( ! a2roffsu(n->string, &su, SCALE_VS))
426: su.scale = 1.0;
1.4 kristaps 427:
1.122 schwarze 428: print_otag(h, TAG_DIV, "suh", &su);
1.24 kristaps 429:
1.16 kristaps 430: /* So the div isn't empty: */
431: print_text(h, "\\~");
432:
1.119 schwarze 433: return 0;
1.4 kristaps 434: }
435:
436: static int
437: man_SH_pre(MAN_ARGS)
438: {
1.134 schwarze 439: char *id;
440:
441: if (n->type == ROFFT_HEAD) {
442: id = html_make_id(n);
443: print_otag(h, TAG_H1, "cTi", "Sh", id);
1.135 schwarze 444: if (id != NULL)
445: print_otag(h, TAG_A, "chR", "selflink", id);
1.134 schwarze 446: free(id);
447: }
1.119 schwarze 448: return 1;
1.4 kristaps 449: }
450:
451: static int
1.8 kristaps 452: man_alt_pre(MAN_ARGS)
453: {
1.114 schwarze 454: const struct roff_node *nn;
1.130 schwarze 455: int i;
1.57 kristaps 456: enum htmltag fp;
457: struct tag *t;
1.8 kristaps 458:
459: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
460: switch (n->tok) {
1.93 schwarze 461: case MAN_BI:
1.57 kristaps 462: fp = i % 2 ? TAG_I : TAG_B;
1.8 kristaps 463: break;
1.93 schwarze 464: case MAN_IB:
1.57 kristaps 465: fp = i % 2 ? TAG_B : TAG_I;
1.8 kristaps 466: break;
1.93 schwarze 467: case MAN_RI:
1.57 kristaps 468: fp = i % 2 ? TAG_I : TAG_MAX;
1.8 kristaps 469: break;
1.93 schwarze 470: case MAN_IR:
1.57 kristaps 471: fp = i % 2 ? TAG_MAX : TAG_I;
1.8 kristaps 472: break;
1.93 schwarze 473: case MAN_BR:
1.57 kristaps 474: fp = i % 2 ? TAG_MAX : TAG_B;
1.8 kristaps 475: break;
1.93 schwarze 476: case MAN_RB:
1.57 kristaps 477: fp = i % 2 ? TAG_B : TAG_MAX;
1.8 kristaps 478: break;
479: default:
480: abort();
481: }
482:
483: if (i)
484: h->flags |= HTML_NOSPACE;
485:
1.130 schwarze 486: if (fp != TAG_MAX)
1.122 schwarze 487: t = print_otag(h, fp, "");
1.57 kristaps 488:
1.130 schwarze 489: print_text(h, nn->string);
1.57 kristaps 490:
1.130 schwarze 491: if (fp != TAG_MAX)
1.57 kristaps 492: print_tagq(h, t);
1.8 kristaps 493: }
1.119 schwarze 494: return 0;
1.8 kristaps 495: }
496:
497: static int
1.56 kristaps 498: man_SM_pre(MAN_ARGS)
1.8 kristaps 499: {
1.122 schwarze 500: print_otag(h, TAG_SMALL, "");
1.56 kristaps 501: if (MAN_SB == n->tok)
1.122 schwarze 502: print_otag(h, TAG_B, "");
1.119 schwarze 503: return 1;
1.8 kristaps 504: }
505:
506: static int
1.4 kristaps 507: man_SS_pre(MAN_ARGS)
508: {
1.134 schwarze 509: char *id;
510:
511: if (n->type == ROFFT_HEAD) {
512: id = html_make_id(n);
513: print_otag(h, TAG_H2, "cTi", "Ss", id);
1.135 schwarze 514: if (id != NULL)
515: print_otag(h, TAG_A, "chR", "selflink", id);
1.134 schwarze 516: free(id);
517: }
1.119 schwarze 518: return 1;
1.4 kristaps 519: }
520:
521: static int
522: man_PP_pre(MAN_ARGS)
523: {
524:
1.113 schwarze 525: if (n->type == ROFFT_HEAD)
1.119 schwarze 526: return 0;
1.113 schwarze 527: else if (n->type == ROFFT_BLOCK)
1.74 kristaps 528: print_bvspace(h, n);
1.47 kristaps 529:
1.119 schwarze 530: return 1;
1.5 kristaps 531: }
532:
533: static int
534: man_IP_pre(MAN_ARGS)
535: {
1.114 schwarze 536: const struct roff_node *nn;
1.5 kristaps 537:
1.113 schwarze 538: if (n->type == ROFFT_BODY) {
1.129 schwarze 539: print_otag(h, TAG_DD, "c", "It-tag");
1.119 schwarze 540: return 1;
1.113 schwarze 541: } else if (n->type != ROFFT_HEAD) {
1.129 schwarze 542: print_otag(h, TAG_DL, "c", "Bl-tag");
1.119 schwarze 543: return 1;
1.6 kristaps 544: }
545:
1.78 kristaps 546: /* FIXME: width specification. */
547:
1.129 schwarze 548: print_otag(h, TAG_DT, "c", "It-tag");
1.6 kristaps 549:
1.59 schwarze 550: /* For IP, only print the first header element. */
1.7 kristaps 551:
1.59 schwarze 552: if (MAN_IP == n->tok && n->child)
1.132 schwarze 553: print_man_node(man, n->child, h);
1.27 kristaps 554:
1.59 schwarze 555: /* For TP, only print next-line header elements. */
1.6 kristaps 556:
1.91 schwarze 557: if (MAN_TP == n->tok) {
558: nn = n->child;
1.121 schwarze 559: while (NULL != nn && 0 == (NODE_LINE & nn->flags))
1.91 schwarze 560: nn = nn->next;
561: while (NULL != nn) {
1.132 schwarze 562: print_man_node(man, nn, h);
1.91 schwarze 563: nn = nn->next;
564: }
565: }
1.6 kristaps 566:
1.119 schwarze 567: return 0;
1.6 kristaps 568: }
569:
570: static int
571: man_HP_pre(MAN_ARGS)
572: {
1.122 schwarze 573: struct roffsu sum, sui;
1.114 schwarze 574: const struct roff_node *np;
1.6 kristaps 575:
1.113 schwarze 576: if (n->type == ROFFT_HEAD)
1.119 schwarze 577: return 0;
1.113 schwarze 578: else if (n->type != ROFFT_BLOCK)
1.119 schwarze 579: return 1;
1.72 kristaps 580:
1.77 kristaps 581: np = n->head->child;
1.6 kristaps 582:
1.122 schwarze 583: if (np == NULL || !a2width(np, &sum))
584: SCALE_HS_INIT(&sum, INDENT);
1.6 kristaps 585:
1.122 schwarze 586: sui.unit = sum.unit;
587: sui.scale = -sum.scale;
1.5 kristaps 588:
1.77 kristaps 589: print_bvspace(h, n);
1.127 schwarze 590: print_otag(h, TAG_DIV, "csului", "Pp", &sum, &sui);
1.119 schwarze 591: return 1;
1.4 kristaps 592: }
1.86 kristaps 593:
594: static int
595: man_OP_pre(MAN_ARGS)
596: {
597: struct tag *tt;
598:
599: print_text(h, "[");
600: h->flags |= HTML_NOSPACE;
1.128 schwarze 601: tt = print_otag(h, TAG_SPAN, "c", "Op");
1.86 kristaps 602:
603: if (NULL != (n = n->child)) {
1.122 schwarze 604: print_otag(h, TAG_B, "");
1.86 kristaps 605: print_text(h, n->string);
606: }
607:
608: print_stagq(h, tt);
609:
610: if (NULL != n && NULL != n->next) {
1.122 schwarze 611: print_otag(h, TAG_I, "");
1.86 kristaps 612: print_text(h, n->next->string);
613: }
614:
615: print_stagq(h, tt);
616: h->flags |= HTML_NOSPACE;
617: print_text(h, "]");
1.119 schwarze 618: return 0;
1.86 kristaps 619: }
620:
1.8 kristaps 621: static int
622: man_B_pre(MAN_ARGS)
623: {
1.122 schwarze 624: print_otag(h, TAG_B, "");
1.119 schwarze 625: return 1;
1.8 kristaps 626: }
627:
628: static int
629: man_I_pre(MAN_ARGS)
630: {
1.122 schwarze 631: print_otag(h, TAG_I, "");
1.119 schwarze 632: return 1;
1.45 kristaps 633: }
634:
635: static int
636: man_in_pre(MAN_ARGS)
637: {
1.122 schwarze 638: print_otag(h, TAG_BR, "");
1.119 schwarze 639: return 0;
1.8 kristaps 640: }
641:
642: static int
643: man_ign_pre(MAN_ARGS)
644: {
645:
1.119 schwarze 646: return 0;
1.8 kristaps 647: }
1.9 kristaps 648:
649: static int
650: man_RS_pre(MAN_ARGS)
651: {
652: struct roffsu su;
653:
1.113 schwarze 654: if (n->type == ROFFT_HEAD)
1.119 schwarze 655: return 0;
1.113 schwarze 656: else if (n->type == ROFFT_BODY)
1.119 schwarze 657: return 1;
1.9 kristaps 658:
659: SCALE_HS_INIT(&su, INDENT);
1.56 kristaps 660: if (n->head->child)
1.9 kristaps 661: a2width(n->head->child, &su);
662:
1.122 schwarze 663: print_otag(h, TAG_DIV, "sul", &su);
1.119 schwarze 664: return 1;
1.90 schwarze 665: }
666:
667: static int
668: man_UR_pre(MAN_ARGS)
669: {
670: n = n->child;
1.113 schwarze 671: assert(n->type == ROFFT_HEAD);
1.120 schwarze 672: if (n->child != NULL) {
1.113 schwarze 673: assert(n->child->type == ROFFT_TEXT);
1.134 schwarze 674: print_otag(h, TAG_A, "cTh", "Lk", n->child->string);
1.90 schwarze 675: }
676:
1.113 schwarze 677: assert(n->next->type == ROFFT_BODY);
1.120 schwarze 678: if (n->next->child != NULL)
1.90 schwarze 679: n = n->next;
680:
1.132 schwarze 681: print_man_nodelist(man, n->child, h);
1.90 schwarze 682:
1.119 schwarze 683: return 0;
1.9 kristaps 684: }
CVSweb