Annotation of mandoc/man_html.c, Revision 1.114
1.114 ! schwarze 1: /* $Id: man_html.c,v 1.113 2015/04/02 21:36:49 schwarze Exp $ */
1.1 kristaps 2: /*
1.104 kristaps 3: * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
1.110 schwarze 4: * Copyright (c) 2013, 2014, 2015 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.6 kristaps 35: /* TODO: preserve ident widths. */
1.13 kristaps 36: /* FIXME: have PD set the default vspace width. */
1.6 kristaps 37:
38: #define INDENT 5
1.4 kristaps 39:
1.89 schwarze 40: #define MAN_ARGS const struct man_meta *man, \
1.114 ! schwarze 41: const struct roff_node *n, \
1.45 kristaps 42: struct mhtml *mh, \
1.3 kristaps 43: struct html *h
44:
1.45 kristaps 45: struct mhtml {
46: int fl;
47: #define MANH_LITERAL (1 << 0) /* literal context */
48: };
49:
1.3 kristaps 50: struct htmlman {
51: int (*pre)(MAN_ARGS);
52: int (*post)(MAN_ARGS);
53: };
54:
1.93 schwarze 55: static void print_bvspace(struct html *,
1.114 ! schwarze 56: const struct roff_node *);
1.3 kristaps 57: static void print_man(MAN_ARGS);
58: static void print_man_head(MAN_ARGS);
1.4 kristaps 59: static void print_man_nodelist(MAN_ARGS);
60: static void print_man_node(MAN_ARGS);
1.114 ! schwarze 61: static int a2width(const struct roff_node *,
1.7 kristaps 62: struct roffsu *);
1.8 kristaps 63: static int man_B_pre(MAN_ARGS);
1.6 kristaps 64: static int man_HP_pre(MAN_ARGS);
1.86 kristaps 65: static int man_IP_pre(MAN_ARGS);
1.8 kristaps 66: static int man_I_pre(MAN_ARGS);
1.86 kristaps 67: static int man_OP_pre(MAN_ARGS);
1.4 kristaps 68: static int man_PP_pre(MAN_ARGS);
1.9 kristaps 69: static int man_RS_pre(MAN_ARGS);
1.4 kristaps 70: static int man_SH_pre(MAN_ARGS);
1.8 kristaps 71: static int man_SM_pre(MAN_ARGS);
1.4 kristaps 72: static int man_SS_pre(MAN_ARGS);
1.90 schwarze 73: static int man_UR_pre(MAN_ARGS);
1.86 kristaps 74: static int man_alt_pre(MAN_ARGS);
75: static int man_br_pre(MAN_ARGS);
76: static int man_ign_pre(MAN_ARGS);
77: static int man_in_pre(MAN_ARGS);
78: static int man_literal_pre(MAN_ARGS);
79: static void man_root_post(MAN_ARGS);
80: static void man_root_pre(MAN_ARGS);
1.4 kristaps 81:
1.3 kristaps 82: static const struct htmlman mans[MAN_MAX] = {
1.4 kristaps 83: { man_br_pre, NULL }, /* br */
1.3 kristaps 84: { NULL, NULL }, /* TH */
1.4 kristaps 85: { man_SH_pre, NULL }, /* SH */
86: { man_SS_pre, NULL }, /* SS */
1.6 kristaps 87: { man_IP_pre, NULL }, /* TP */
1.4 kristaps 88: { man_PP_pre, NULL }, /* LP */
89: { man_PP_pre, NULL }, /* PP */
90: { man_PP_pre, NULL }, /* P */
1.5 kristaps 91: { man_IP_pre, NULL }, /* IP */
1.93 schwarze 92: { man_HP_pre, NULL }, /* HP */
1.8 kristaps 93: { man_SM_pre, NULL }, /* SM */
1.56 kristaps 94: { man_SM_pre, NULL }, /* SB */
1.8 kristaps 95: { man_alt_pre, NULL }, /* BI */
96: { man_alt_pre, NULL }, /* IB */
97: { man_alt_pre, NULL }, /* BR */
98: { man_alt_pre, NULL }, /* RB */
1.3 kristaps 99: { NULL, NULL }, /* R */
1.8 kristaps 100: { man_B_pre, NULL }, /* B */
101: { man_I_pre, NULL }, /* I */
102: { man_alt_pre, NULL }, /* IR */
103: { man_alt_pre, NULL }, /* RI */
1.4 kristaps 104: { man_br_pre, NULL }, /* sp */
1.45 kristaps 105: { man_literal_pre, NULL }, /* nf */
106: { man_literal_pre, NULL }, /* fi */
1.3 kristaps 107: { NULL, NULL }, /* RE */
1.9 kristaps 108: { man_RS_pre, NULL }, /* RS */
1.8 kristaps 109: { man_ign_pre, NULL }, /* DT */
110: { man_ign_pre, NULL }, /* UC */
1.13 kristaps 111: { man_ign_pre, NULL }, /* PD */
1.34 joerg 112: { man_ign_pre, NULL }, /* AT */
1.45 kristaps 113: { man_in_pre, NULL }, /* in */
1.51 kristaps 114: { man_ign_pre, NULL }, /* ft */
1.86 kristaps 115: { man_OP_pre, NULL }, /* OP */
1.88 schwarze 116: { man_literal_pre, NULL }, /* EX */
117: { man_literal_pre, NULL }, /* EE */
1.90 schwarze 118: { man_UR_pre, NULL }, /* UR */
119: { NULL, NULL }, /* UE */
1.92 schwarze 120: { man_ign_pre, NULL }, /* ll */
1.3 kristaps 121: };
122:
1.93 schwarze 123:
1.74 kristaps 124: /*
125: * Printing leading vertical space before a block.
126: * This is used for the paragraph macros.
127: * The rules are pretty simple, since there's very little nesting going
128: * on here. Basically, if we're the first within another block (SS/SH),
129: * then don't emit vertical space. If we are (RS), then do. If not the
130: * first, print it.
131: */
132: static void
1.114 ! schwarze 133: print_bvspace(struct html *h, const struct roff_node *n)
1.74 kristaps 134: {
135:
136: if (n->body && n->body->child)
1.113 schwarze 137: if (n->body->child->type == ROFFT_TBL)
1.74 kristaps 138: return;
139:
1.113 schwarze 140: if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS)
1.74 kristaps 141: if (NULL == n->prev)
142: return;
143:
1.103 kristaps 144: print_paragraph(h);
1.74 kristaps 145: }
1.1 kristaps 146:
147: void
1.89 schwarze 148: html_man(void *arg, const struct man *man)
1.1 kristaps 149: {
1.45 kristaps 150: struct mhtml mh;
1.3 kristaps 151:
1.45 kristaps 152: memset(&mh, 0, sizeof(struct mhtml));
1.89 schwarze 153: print_man(man_meta(man), man_node(man), &mh, (struct html *)arg);
1.82 kristaps 154: putchar('\n');
1.3 kristaps 155: }
156:
157: static void
1.93 schwarze 158: print_man(MAN_ARGS)
1.3 kristaps 159: {
1.82 kristaps 160: struct tag *t, *tt;
161: struct htmlpair tag;
162:
163: PAIR_CLASS_INIT(&tag, "mandoc");
1.3 kristaps 164:
1.82 kristaps 165: if ( ! (HTML_FRAGMENT & h->oflags)) {
166: print_gen_decls(h);
167: t = print_otag(h, TAG_HTML, 0, NULL);
168: tt = print_otag(h, TAG_HEAD, 0, NULL);
1.89 schwarze 169: print_man_head(man, n, mh, h);
1.82 kristaps 170: print_tagq(h, tt);
171: print_otag(h, TAG_BODY, 0, NULL);
172: print_otag(h, TAG_DIV, 1, &tag);
1.93 schwarze 173: } else
1.82 kristaps 174: t = print_otag(h, TAG_DIV, 1, &tag);
1.53 kristaps 175:
1.89 schwarze 176: print_man_nodelist(man, n, mh, h);
1.3 kristaps 177: print_tagq(h, t);
178: }
179:
180: static void
181: print_man_head(MAN_ARGS)
182: {
183:
184: print_gen_head(h);
1.89 schwarze 185: assert(man->title);
186: assert(man->msec);
187: bufcat_fmt(h, "%s(%s)", man->title, man->msec);
1.3 kristaps 188: print_otag(h, TAG_TITLE, 0, NULL);
189: print_text(h, h->buf);
1.1 kristaps 190: }
1.4 kristaps 191:
192: static void
193: print_man_nodelist(MAN_ARGS)
194: {
195:
1.110 schwarze 196: while (n != NULL) {
197: print_man_node(man, n, mh, h);
198: n = n->next;
199: }
1.4 kristaps 200: }
201:
202: static void
203: print_man_node(MAN_ARGS)
204: {
205: int child;
206: struct tag *t;
207:
208: child = 1;
1.14 kristaps 209: t = h->tags.head;
1.4 kristaps 210:
211: switch (n->type) {
1.113 schwarze 212: case ROFFT_ROOT:
1.89 schwarze 213: man_root_pre(man, n, mh, h);
1.4 kristaps 214: break;
1.113 schwarze 215: case ROFFT_TEXT:
1.63 kristaps 216: if ('\0' == *n->string) {
1.103 kristaps 217: print_paragraph(h);
1.63 kristaps 218: return;
1.78 kristaps 219: }
1.111 schwarze 220: if (n->flags & MAN_LINE && (*n->string == ' ' ||
1.106 schwarze 221: (n->prev != NULL && mh->fl & MANH_LITERAL &&
222: ! (h->flags & HTML_NONEWLINE))))
1.63 kristaps 223: print_otag(h, TAG_BR, 0, NULL);
1.4 kristaps 224: print_text(h, n->string);
1.68 kristaps 225: return;
1.113 schwarze 226: case ROFFT_EQN:
1.112 schwarze 227: if (n->flags & MAN_LINE)
228: putchar('\n');
1.80 kristaps 229: print_eqn(h, n->eqn);
1.69 kristaps 230: break;
1.113 schwarze 231: case ROFFT_TBL:
1.66 kristaps 232: /*
233: * This will take care of initialising all of the table
234: * state data for the first table, then tearing it down
235: * for the last one.
236: */
1.60 kristaps 237: print_tbl(h, n->span);
1.64 kristaps 238: return;
1.4 kristaps 239: default:
1.93 schwarze 240: /*
1.21 kristaps 241: * Close out scope of font prior to opening a macro
1.66 kristaps 242: * scope.
1.21 kristaps 243: */
1.57 kristaps 244: if (HTMLFONT_NONE != h->metac) {
245: h->metal = h->metac;
246: h->metac = HTMLFONT_NONE;
1.66 kristaps 247: }
248:
249: /*
250: * Close out the current table, if it's open, and unset
251: * the "meta" table state. This will be reopened on the
252: * next table element.
253: */
254: if (h->tblt) {
255: print_tblclose(h);
256: t = h->tags.head;
1.20 kristaps 257: }
1.4 kristaps 258: if (mans[n->tok].pre)
1.89 schwarze 259: child = (*mans[n->tok].pre)(man, n, mh, h);
1.4 kristaps 260: break;
261: }
262:
1.21 kristaps 263: if (child && n->child)
1.89 schwarze 264: print_man_nodelist(man, n->child, mh, h);
1.21 kristaps 265:
1.24 kristaps 266: /* This will automatically close out any font scope. */
1.4 kristaps 267: print_stagq(h, t);
268:
1.61 kristaps 269: switch (n->type) {
1.113 schwarze 270: case ROFFT_ROOT:
1.89 schwarze 271: man_root_post(man, n, mh, h);
1.69 kristaps 272: break;
1.113 schwarze 273: case ROFFT_EQN:
1.61 kristaps 274: break;
275: default:
276: if (mans[n->tok].post)
1.89 schwarze 277: (*mans[n->tok].post)(man, n, mh, h);
1.61 kristaps 278: break;
279: }
1.4 kristaps 280: }
281:
1.5 kristaps 282: static int
1.114 ! schwarze 283: a2width(const struct roff_node *n, struct roffsu *su)
1.5 kristaps 284: {
285:
1.113 schwarze 286: if (n->type != ROFFT_TEXT)
1.7 kristaps 287: return(0);
1.107 schwarze 288: if (a2roffsu(n->string, su, SCALE_EN))
1.7 kristaps 289: return(1);
1.5 kristaps 290:
1.7 kristaps 291: return(0);
1.5 kristaps 292: }
293:
1.65 kristaps 294: static void
1.4 kristaps 295: man_root_pre(MAN_ARGS)
296: {
1.101 kristaps 297: struct htmlpair tag;
1.4 kristaps 298: struct tag *t, *tt;
1.94 schwarze 299: char *title;
1.4 kristaps 300:
1.89 schwarze 301: assert(man->title);
302: assert(man->msec);
1.94 schwarze 303: mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.4 kristaps 304:
1.101 kristaps 305: PAIR_CLASS_INIT(&tag, "head");
306: t = print_otag(h, TAG_TABLE, 1, &tag);
1.56 kristaps 307:
308: print_otag(h, TAG_TBODY, 0, NULL);
1.15 kristaps 309:
1.4 kristaps 310: tt = print_otag(h, TAG_TR, 0, NULL);
311:
1.101 kristaps 312: PAIR_CLASS_INIT(&tag, "head-ltitle");
313: print_otag(h, TAG_TD, 1, &tag);
1.4 kristaps 314: print_text(h, title);
315: print_stagq(h, tt);
316:
1.101 kristaps 317: PAIR_CLASS_INIT(&tag, "head-vol");
318: print_otag(h, TAG_TD, 1, &tag);
1.95 schwarze 319: if (NULL != man->vol)
320: print_text(h, man->vol);
1.4 kristaps 321: print_stagq(h, tt);
322:
1.101 kristaps 323: PAIR_CLASS_INIT(&tag, "head-rtitle");
324: print_otag(h, TAG_TD, 1, &tag);
1.4 kristaps 325: print_text(h, title);
326: print_tagq(h, t);
1.94 schwarze 327: free(title);
1.4 kristaps 328: }
329:
330: static void
331: man_root_post(MAN_ARGS)
332: {
1.101 kristaps 333: struct htmlpair tag;
1.4 kristaps 334: struct tag *t, *tt;
335:
1.101 kristaps 336: PAIR_CLASS_INIT(&tag, "foot");
337: t = print_otag(h, TAG_TABLE, 1, &tag);
1.15 kristaps 338:
1.4 kristaps 339: tt = print_otag(h, TAG_TR, 0, NULL);
340:
1.101 kristaps 341: PAIR_CLASS_INIT(&tag, "foot-date");
342: print_otag(h, TAG_TD, 1, &tag);
1.55 kristaps 343:
1.89 schwarze 344: assert(man->date);
345: print_text(h, man->date);
1.4 kristaps 346: print_stagq(h, tt);
347:
1.101 kristaps 348: PAIR_CLASS_INIT(&tag, "foot-os");
349: print_otag(h, TAG_TD, 1, &tag);
1.55 kristaps 350:
1.89 schwarze 351: if (man->source)
352: print_text(h, man->source);
1.4 kristaps 353: print_tagq(h, t);
354: }
355:
356:
357: static int
358: man_br_pre(MAN_ARGS)
359: {
1.7 kristaps 360: struct roffsu su;
361: struct htmlpair tag;
1.4 kristaps 362:
1.7 kristaps 363: SCALE_VS_INIT(&su, 1);
364:
1.49 kristaps 365: if (MAN_sp == n->tok) {
1.75 kristaps 366: if (NULL != (n = n->child))
367: if ( ! a2roffsu(n->string, &su, SCALE_VS))
1.108 schwarze 368: su.scale = 1.0;
1.49 kristaps 369: } else
1.96 schwarze 370: su.scale = 0.0;
1.4 kristaps 371:
1.72 kristaps 372: bufinit(h);
1.7 kristaps 373: bufcat_su(h, "height", &su);
374: PAIR_STYLE_INIT(&tag, h);
1.4 kristaps 375: print_otag(h, TAG_DIV, 1, &tag);
1.24 kristaps 376:
1.16 kristaps 377: /* So the div isn't empty: */
378: print_text(h, "\\~");
379:
1.7 kristaps 380: return(0);
1.4 kristaps 381: }
382:
383: static int
384: man_SH_pre(MAN_ARGS)
385: {
1.54 kristaps 386: struct htmlpair tag;
1.4 kristaps 387:
1.113 schwarze 388: if (n->type == ROFFT_BLOCK) {
1.76 kristaps 389: mh->fl &= ~MANH_LITERAL;
1.54 kristaps 390: PAIR_CLASS_INIT(&tag, "section");
391: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 392: return(1);
1.113 schwarze 393: } else if (n->type == ROFFT_BODY)
1.4 kristaps 394: return(1);
395:
1.54 kristaps 396: print_otag(h, TAG_H1, 0, NULL);
1.4 kristaps 397: return(1);
398: }
399:
400: static int
1.8 kristaps 401: man_alt_pre(MAN_ARGS)
402: {
1.114 ! schwarze 403: const struct roff_node *nn;
1.78 kristaps 404: int i, savelit;
1.57 kristaps 405: enum htmltag fp;
406: struct tag *t;
1.8 kristaps 407:
1.93 schwarze 408: if ((savelit = mh->fl & MANH_LITERAL))
1.78 kristaps 409: print_otag(h, TAG_BR, 0, NULL);
410:
411: mh->fl &= ~MANH_LITERAL;
412:
1.8 kristaps 413: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.57 kristaps 414: t = NULL;
1.8 kristaps 415: switch (n->tok) {
1.93 schwarze 416: case MAN_BI:
1.57 kristaps 417: fp = i % 2 ? TAG_I : TAG_B;
1.8 kristaps 418: break;
1.93 schwarze 419: case MAN_IB:
1.57 kristaps 420: fp = i % 2 ? TAG_B : TAG_I;
1.8 kristaps 421: break;
1.93 schwarze 422: case MAN_RI:
1.57 kristaps 423: fp = i % 2 ? TAG_I : TAG_MAX;
1.8 kristaps 424: break;
1.93 schwarze 425: case MAN_IR:
1.57 kristaps 426: fp = i % 2 ? TAG_MAX : TAG_I;
1.8 kristaps 427: break;
1.93 schwarze 428: case MAN_BR:
1.57 kristaps 429: fp = i % 2 ? TAG_MAX : TAG_B;
1.8 kristaps 430: break;
1.93 schwarze 431: case MAN_RB:
1.57 kristaps 432: fp = i % 2 ? TAG_B : TAG_MAX;
1.8 kristaps 433: break;
434: default:
435: abort();
436: /* NOTREACHED */
437: }
438:
439: if (i)
440: h->flags |= HTML_NOSPACE;
441:
1.57 kristaps 442: if (TAG_MAX != fp)
443: t = print_otag(h, fp, 0, NULL);
444:
1.89 schwarze 445: print_man_node(man, nn, mh, h);
1.57 kristaps 446:
447: if (t)
448: print_tagq(h, t);
1.8 kristaps 449: }
450:
1.78 kristaps 451: if (savelit)
452: mh->fl |= MANH_LITERAL;
453:
1.8 kristaps 454: return(0);
455: }
456:
457: static int
1.56 kristaps 458: man_SM_pre(MAN_ARGS)
1.8 kristaps 459: {
1.93 schwarze 460:
1.57 kristaps 461: print_otag(h, TAG_SMALL, 0, NULL);
1.56 kristaps 462: if (MAN_SB == n->tok)
1.57 kristaps 463: print_otag(h, TAG_B, 0, NULL);
1.8 kristaps 464: return(1);
465: }
466:
467: static int
1.4 kristaps 468: man_SS_pre(MAN_ARGS)
469: {
1.54 kristaps 470: struct htmlpair tag;
1.4 kristaps 471:
1.113 schwarze 472: if (n->type == ROFFT_BLOCK) {
1.76 kristaps 473: mh->fl &= ~MANH_LITERAL;
1.54 kristaps 474: PAIR_CLASS_INIT(&tag, "subsection");
475: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 476: return(1);
1.113 schwarze 477: } else if (n->type == ROFFT_BODY)
1.4 kristaps 478: return(1);
479:
1.54 kristaps 480: print_otag(h, TAG_H2, 0, NULL);
1.4 kristaps 481: return(1);
482: }
483:
484: static int
485: man_PP_pre(MAN_ARGS)
486: {
487:
1.113 schwarze 488: if (n->type == ROFFT_HEAD)
1.47 kristaps 489: return(0);
1.113 schwarze 490: else if (n->type == ROFFT_BLOCK)
1.74 kristaps 491: print_bvspace(h, n);
1.47 kristaps 492:
1.5 kristaps 493: return(1);
494: }
495:
496: static int
497: man_IP_pre(MAN_ARGS)
498: {
1.114 ! schwarze 499: const struct roff_node *nn;
1.5 kristaps 500:
1.113 schwarze 501: if (n->type == ROFFT_BODY) {
1.77 kristaps 502: print_otag(h, TAG_DD, 0, NULL);
503: return(1);
1.113 schwarze 504: } else if (n->type != ROFFT_HEAD) {
1.77 kristaps 505: print_otag(h, TAG_DL, 0, NULL);
1.6 kristaps 506: return(1);
507: }
508:
1.78 kristaps 509: /* FIXME: width specification. */
510:
1.77 kristaps 511: print_otag(h, TAG_DT, 0, NULL);
1.6 kristaps 512:
1.59 schwarze 513: /* For IP, only print the first header element. */
1.7 kristaps 514:
1.59 schwarze 515: if (MAN_IP == n->tok && n->child)
1.89 schwarze 516: print_man_node(man, n->child, mh, h);
1.27 kristaps 517:
1.59 schwarze 518: /* For TP, only print next-line header elements. */
1.6 kristaps 519:
1.91 schwarze 520: if (MAN_TP == n->tok) {
521: nn = n->child;
522: while (NULL != nn && 0 == (MAN_LINE & nn->flags))
523: nn = nn->next;
524: while (NULL != nn) {
525: print_man_node(man, nn, mh, h);
526: nn = nn->next;
527: }
528: }
1.6 kristaps 529:
530: return(0);
531: }
532:
533: static int
534: man_HP_pre(MAN_ARGS)
535: {
1.103 kristaps 536: struct htmlpair tag[2];
1.56 kristaps 537: struct roffsu su;
1.114 ! schwarze 538: const struct roff_node *np;
1.6 kristaps 539:
1.113 schwarze 540: if (n->type == ROFFT_HEAD)
1.77 kristaps 541: return(0);
1.113 schwarze 542: else if (n->type != ROFFT_BLOCK)
1.77 kristaps 543: return(1);
1.72 kristaps 544:
1.77 kristaps 545: np = n->head->child;
1.6 kristaps 546:
1.56 kristaps 547: if (NULL == np || ! a2width(np, &su))
548: SCALE_HS_INIT(&su, INDENT);
1.6 kristaps 549:
1.77 kristaps 550: bufinit(h);
1.5 kristaps 551:
1.77 kristaps 552: print_bvspace(h, n);
553: bufcat_su(h, "margin-left", &su);
1.56 kristaps 554: su.scale = -su.scale;
1.7 kristaps 555: bufcat_su(h, "text-indent", &su);
1.103 kristaps 556: PAIR_STYLE_INIT(&tag[0], h);
557: PAIR_CLASS_INIT(&tag[1], "spacer");
558: print_otag(h, TAG_DIV, 2, tag);
1.4 kristaps 559: return(1);
560: }
1.86 kristaps 561:
562: static int
563: man_OP_pre(MAN_ARGS)
564: {
565: struct tag *tt;
566: struct htmlpair tag;
567:
568: print_text(h, "[");
569: h->flags |= HTML_NOSPACE;
570: PAIR_CLASS_INIT(&tag, "opt");
571: tt = print_otag(h, TAG_SPAN, 1, &tag);
572:
573: if (NULL != (n = n->child)) {
574: print_otag(h, TAG_B, 0, NULL);
575: print_text(h, n->string);
576: }
577:
578: print_stagq(h, tt);
579:
580: if (NULL != n && NULL != n->next) {
581: print_otag(h, TAG_I, 0, NULL);
582: print_text(h, n->next->string);
583: }
584:
585: print_stagq(h, tt);
586: h->flags |= HTML_NOSPACE;
587: print_text(h, "]");
588: return(0);
589: }
590:
1.8 kristaps 591: static int
592: man_B_pre(MAN_ARGS)
593: {
594:
1.57 kristaps 595: print_otag(h, TAG_B, 0, NULL);
1.8 kristaps 596: return(1);
597: }
598:
599: static int
600: man_I_pre(MAN_ARGS)
601: {
1.93 schwarze 602:
1.57 kristaps 603: print_otag(h, TAG_I, 0, NULL);
1.8 kristaps 604: return(1);
1.45 kristaps 605: }
606:
607: static int
608: man_literal_pre(MAN_ARGS)
609: {
610:
1.88 schwarze 611: if (MAN_fi == n->tok || MAN_EE == n->tok) {
1.45 kristaps 612: print_otag(h, TAG_BR, 0, NULL);
1.78 kristaps 613: mh->fl &= ~MANH_LITERAL;
614: } else
1.45 kristaps 615: mh->fl |= MANH_LITERAL;
616:
1.67 schwarze 617: return(0);
1.45 kristaps 618: }
619:
620: static int
621: man_in_pre(MAN_ARGS)
622: {
623:
624: print_otag(h, TAG_BR, 0, NULL);
625: return(0);
1.8 kristaps 626: }
627:
628: static int
629: man_ign_pre(MAN_ARGS)
630: {
631:
632: return(0);
633: }
1.9 kristaps 634:
635: static int
636: man_RS_pre(MAN_ARGS)
637: {
638: struct htmlpair tag;
639: struct roffsu su;
640:
1.113 schwarze 641: if (n->type == ROFFT_HEAD)
1.9 kristaps 642: return(0);
1.113 schwarze 643: else if (n->type == ROFFT_BODY)
1.9 kristaps 644: return(1);
645:
646: SCALE_HS_INIT(&su, INDENT);
1.56 kristaps 647: if (n->head->child)
1.9 kristaps 648: a2width(n->head->child, &su);
649:
1.72 kristaps 650: bufinit(h);
1.56 kristaps 651: bufcat_su(h, "margin-left", &su);
1.9 kristaps 652: PAIR_STYLE_INIT(&tag, h);
653: print_otag(h, TAG_DIV, 1, &tag);
654: return(1);
1.90 schwarze 655: }
656:
657: static int
658: man_UR_pre(MAN_ARGS)
659: {
660: struct htmlpair tag[2];
661:
662: n = n->child;
1.113 schwarze 663: assert(n->type == ROFFT_HEAD);
1.90 schwarze 664: if (n->nchild) {
1.113 schwarze 665: assert(n->child->type == ROFFT_TEXT);
1.90 schwarze 666: PAIR_CLASS_INIT(&tag[0], "link-ext");
667: PAIR_HREF_INIT(&tag[1], n->child->string);
668: print_otag(h, TAG_A, 2, tag);
669: }
670:
1.113 schwarze 671: assert(n->next->type == ROFFT_BODY);
1.90 schwarze 672: if (n->next->nchild)
673: n = n->next;
674:
675: print_man_nodelist(man, n->child, mh, h);
676:
677: return(0);
1.9 kristaps 678: }
CVSweb