Annotation of mandoc/man_html.c, Revision 1.105
1.105 ! schwarze 1: /* $Id: man_html.c,v 1.104 2014/09/27 11:17:19 kristaps Exp $ */
1.1 kristaps 2: /*
1.104 kristaps 3: * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
1.91 schwarze 4: * Copyright (c) 2013, 2014 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: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
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.105 ! schwarze 29: #include "man.h"
1.7 kristaps 30: #include "out.h"
1.1 kristaps 31: #include "html.h"
1.10 kristaps 32: #include "main.h"
1.1 kristaps 33:
1.6 kristaps 34: /* TODO: preserve ident widths. */
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.89 schwarze 39: #define MAN_ARGS const struct man_meta *man, \
1.3 kristaps 40: const struct man_node *n, \
1.45 kristaps 41: struct mhtml *mh, \
1.3 kristaps 42: struct html *h
43:
1.45 kristaps 44: struct mhtml {
45: int fl;
46: #define MANH_LITERAL (1 << 0) /* literal context */
47: };
48:
1.3 kristaps 49: struct htmlman {
50: int (*pre)(MAN_ARGS);
51: int (*post)(MAN_ARGS);
52: };
53:
1.93 schwarze 54: static void print_bvspace(struct html *,
1.74 kristaps 55: const struct man_node *);
1.3 kristaps 56: static void print_man(MAN_ARGS);
57: static void print_man_head(MAN_ARGS);
1.4 kristaps 58: static void print_man_nodelist(MAN_ARGS);
59: static void print_man_node(MAN_ARGS);
1.7 kristaps 60: static int a2width(const struct man_node *,
61: struct roffsu *);
1.8 kristaps 62: static int man_B_pre(MAN_ARGS);
1.6 kristaps 63: static int man_HP_pre(MAN_ARGS);
1.86 kristaps 64: static int man_IP_pre(MAN_ARGS);
1.8 kristaps 65: static int man_I_pre(MAN_ARGS);
1.86 kristaps 66: static int man_OP_pre(MAN_ARGS);
1.4 kristaps 67: static int man_PP_pre(MAN_ARGS);
1.9 kristaps 68: static int man_RS_pre(MAN_ARGS);
1.4 kristaps 69: static int man_SH_pre(MAN_ARGS);
1.8 kristaps 70: static int man_SM_pre(MAN_ARGS);
1.4 kristaps 71: static int man_SS_pre(MAN_ARGS);
1.90 schwarze 72: static int man_UR_pre(MAN_ARGS);
1.86 kristaps 73: static int man_alt_pre(MAN_ARGS);
74: static int man_br_pre(MAN_ARGS);
75: static int man_ign_pre(MAN_ARGS);
76: static int man_in_pre(MAN_ARGS);
77: static int man_literal_pre(MAN_ARGS);
78: static void man_root_post(MAN_ARGS);
79: static void man_root_pre(MAN_ARGS);
1.4 kristaps 80:
1.3 kristaps 81: static const struct htmlman mans[MAN_MAX] = {
1.4 kristaps 82: { man_br_pre, NULL }, /* br */
1.3 kristaps 83: { NULL, NULL }, /* TH */
1.4 kristaps 84: { man_SH_pre, NULL }, /* SH */
85: { man_SS_pre, NULL }, /* SS */
1.6 kristaps 86: { man_IP_pre, NULL }, /* TP */
1.4 kristaps 87: { man_PP_pre, NULL }, /* LP */
88: { man_PP_pre, NULL }, /* PP */
89: { man_PP_pre, NULL }, /* P */
1.5 kristaps 90: { man_IP_pre, NULL }, /* IP */
1.93 schwarze 91: { man_HP_pre, NULL }, /* HP */
1.8 kristaps 92: { man_SM_pre, NULL }, /* SM */
1.56 kristaps 93: { man_SM_pre, NULL }, /* SB */
1.8 kristaps 94: { man_alt_pre, NULL }, /* BI */
95: { man_alt_pre, NULL }, /* IB */
96: { man_alt_pre, NULL }, /* BR */
97: { man_alt_pre, NULL }, /* RB */
1.3 kristaps 98: { NULL, NULL }, /* R */
1.8 kristaps 99: { man_B_pre, NULL }, /* B */
100: { man_I_pre, NULL }, /* I */
101: { man_alt_pre, NULL }, /* IR */
102: { man_alt_pre, NULL }, /* RI */
1.67 schwarze 103: { man_ign_pre, NULL }, /* na */
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
133: print_bvspace(struct html *h, const struct man_node *n)
134: {
135:
136: if (n->body && n->body->child)
137: if (MAN_TBL == n->body->child->type)
138: return;
139:
140: if (MAN_ROOT == n->parent->type || MAN_RS != n->parent->tok)
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.89 schwarze 196: print_man_node(man, n, mh, h);
1.4 kristaps 197: if (n->next)
1.89 schwarze 198: print_man_nodelist(man, n->next, mh, h);
1.4 kristaps 199: }
200:
201: static void
202: print_man_node(MAN_ARGS)
203: {
204: int child;
205: struct tag *t;
206:
207: child = 1;
1.14 kristaps 208: t = h->tags.head;
1.4 kristaps 209:
210: switch (n->type) {
1.93 schwarze 211: case MAN_ROOT:
1.89 schwarze 212: man_root_pre(man, n, mh, h);
1.4 kristaps 213: break;
1.93 schwarze 214: case MAN_TEXT:
1.65 kristaps 215: /*
216: * If we have a blank line, output a vertical space.
217: * If we have a space as the first character, break
218: * before printing the line's data.
219: */
1.63 kristaps 220: if ('\0' == *n->string) {
1.103 kristaps 221: print_paragraph(h);
1.63 kristaps 222: return;
1.78 kristaps 223: }
224:
225: if (' ' == *n->string && MAN_LINE & n->flags)
226: print_otag(h, TAG_BR, 0, NULL);
227: else if (MANH_LITERAL & mh->fl && n->prev)
1.63 kristaps 228: print_otag(h, TAG_BR, 0, NULL);
229:
1.4 kristaps 230: print_text(h, n->string);
1.68 kristaps 231: return;
1.93 schwarze 232: case MAN_EQN:
1.80 kristaps 233: print_eqn(h, n->eqn);
1.69 kristaps 234: break;
1.93 schwarze 235: case MAN_TBL:
1.66 kristaps 236: /*
237: * This will take care of initialising all of the table
238: * state data for the first table, then tearing it down
239: * for the last one.
240: */
1.60 kristaps 241: print_tbl(h, n->span);
1.64 kristaps 242: return;
1.4 kristaps 243: default:
1.93 schwarze 244: /*
1.21 kristaps 245: * Close out scope of font prior to opening a macro
1.66 kristaps 246: * scope.
1.21 kristaps 247: */
1.57 kristaps 248: if (HTMLFONT_NONE != h->metac) {
249: h->metal = h->metac;
250: h->metac = HTMLFONT_NONE;
1.66 kristaps 251: }
252:
253: /*
254: * Close out the current table, if it's open, and unset
255: * the "meta" table state. This will be reopened on the
256: * next table element.
257: */
258: if (h->tblt) {
259: print_tblclose(h);
260: t = h->tags.head;
1.20 kristaps 261: }
1.4 kristaps 262: if (mans[n->tok].pre)
1.89 schwarze 263: child = (*mans[n->tok].pre)(man, n, mh, h);
1.4 kristaps 264: break;
265: }
266:
1.21 kristaps 267: if (child && n->child)
1.89 schwarze 268: print_man_nodelist(man, n->child, mh, h);
1.21 kristaps 269:
1.24 kristaps 270: /* This will automatically close out any font scope. */
1.4 kristaps 271: print_stagq(h, t);
272:
1.61 kristaps 273: switch (n->type) {
1.93 schwarze 274: case MAN_ROOT:
1.89 schwarze 275: man_root_post(man, n, mh, h);
1.69 kristaps 276: break;
1.93 schwarze 277: case MAN_EQN:
1.61 kristaps 278: break;
279: default:
280: if (mans[n->tok].post)
1.89 schwarze 281: (*mans[n->tok].post)(man, n, mh, h);
1.61 kristaps 282: break;
283: }
1.4 kristaps 284: }
285:
1.5 kristaps 286: static int
1.7 kristaps 287: a2width(const struct man_node *n, struct roffsu *su)
1.5 kristaps 288: {
289:
1.6 kristaps 290: if (MAN_TEXT != n->type)
1.7 kristaps 291: return(0);
1.11 kristaps 292: if (a2roffsu(n->string, su, SCALE_BU))
1.7 kristaps 293: return(1);
1.5 kristaps 294:
1.7 kristaps 295: return(0);
1.5 kristaps 296: }
297:
1.65 kristaps 298: static void
1.4 kristaps 299: man_root_pre(MAN_ARGS)
300: {
1.101 kristaps 301: struct htmlpair tag;
1.4 kristaps 302: struct tag *t, *tt;
1.94 schwarze 303: char *title;
1.4 kristaps 304:
1.89 schwarze 305: assert(man->title);
306: assert(man->msec);
1.94 schwarze 307: mandoc_asprintf(&title, "%s(%s)", man->title, man->msec);
1.4 kristaps 308:
1.101 kristaps 309: PAIR_CLASS_INIT(&tag, "head");
310: t = print_otag(h, TAG_TABLE, 1, &tag);
1.56 kristaps 311:
312: print_otag(h, TAG_TBODY, 0, NULL);
1.15 kristaps 313:
1.4 kristaps 314: tt = print_otag(h, TAG_TR, 0, NULL);
315:
1.101 kristaps 316: PAIR_CLASS_INIT(&tag, "head-ltitle");
317: print_otag(h, TAG_TD, 1, &tag);
1.4 kristaps 318: print_text(h, title);
319: print_stagq(h, tt);
320:
1.101 kristaps 321: PAIR_CLASS_INIT(&tag, "head-vol");
322: print_otag(h, TAG_TD, 1, &tag);
1.95 schwarze 323: if (NULL != man->vol)
324: print_text(h, man->vol);
1.4 kristaps 325: print_stagq(h, tt);
326:
1.101 kristaps 327: PAIR_CLASS_INIT(&tag, "head-rtitle");
328: print_otag(h, TAG_TD, 1, &tag);
1.4 kristaps 329: print_text(h, title);
330: print_tagq(h, t);
1.94 schwarze 331: free(title);
1.4 kristaps 332: }
333:
334: static void
335: man_root_post(MAN_ARGS)
336: {
1.101 kristaps 337: struct htmlpair tag;
1.4 kristaps 338: struct tag *t, *tt;
339:
1.101 kristaps 340: PAIR_CLASS_INIT(&tag, "foot");
341: t = print_otag(h, TAG_TABLE, 1, &tag);
1.15 kristaps 342:
1.4 kristaps 343: tt = print_otag(h, TAG_TR, 0, NULL);
344:
1.101 kristaps 345: PAIR_CLASS_INIT(&tag, "foot-date");
346: print_otag(h, TAG_TD, 1, &tag);
1.55 kristaps 347:
1.89 schwarze 348: assert(man->date);
349: print_text(h, man->date);
1.4 kristaps 350: print_stagq(h, tt);
351:
1.101 kristaps 352: PAIR_CLASS_INIT(&tag, "foot-os");
353: print_otag(h, TAG_TD, 1, &tag);
1.55 kristaps 354:
1.89 schwarze 355: if (man->source)
356: print_text(h, man->source);
1.4 kristaps 357: print_tagq(h, t);
358: }
359:
360:
361: static int
362: man_br_pre(MAN_ARGS)
363: {
1.7 kristaps 364: struct roffsu su;
365: struct htmlpair tag;
1.4 kristaps 366:
1.7 kristaps 367: SCALE_VS_INIT(&su, 1);
368:
1.49 kristaps 369: if (MAN_sp == n->tok) {
1.75 kristaps 370: if (NULL != (n = n->child))
371: if ( ! a2roffsu(n->string, &su, SCALE_VS))
372: SCALE_VS_INIT(&su, atoi(n->string));
1.49 kristaps 373: } else
1.96 schwarze 374: su.scale = 0.0;
1.4 kristaps 375:
1.72 kristaps 376: bufinit(h);
1.7 kristaps 377: bufcat_su(h, "height", &su);
378: PAIR_STYLE_INIT(&tag, h);
1.4 kristaps 379: print_otag(h, TAG_DIV, 1, &tag);
1.24 kristaps 380:
1.16 kristaps 381: /* So the div isn't empty: */
382: print_text(h, "\\~");
383:
1.7 kristaps 384: return(0);
1.4 kristaps 385: }
386:
387: static int
388: man_SH_pre(MAN_ARGS)
389: {
1.54 kristaps 390: struct htmlpair tag;
1.4 kristaps 391:
1.54 kristaps 392: if (MAN_BLOCK == n->type) {
1.76 kristaps 393: mh->fl &= ~MANH_LITERAL;
1.54 kristaps 394: PAIR_CLASS_INIT(&tag, "section");
395: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 396: return(1);
1.54 kristaps 397: } else if (MAN_BODY == n->type)
1.4 kristaps 398: return(1);
399:
1.54 kristaps 400: print_otag(h, TAG_H1, 0, NULL);
1.4 kristaps 401: return(1);
402: }
403:
404: static int
1.8 kristaps 405: man_alt_pre(MAN_ARGS)
406: {
407: const struct man_node *nn;
1.78 kristaps 408: int i, savelit;
1.57 kristaps 409: enum htmltag fp;
410: struct tag *t;
1.8 kristaps 411:
1.93 schwarze 412: if ((savelit = mh->fl & MANH_LITERAL))
1.78 kristaps 413: print_otag(h, TAG_BR, 0, NULL);
414:
415: mh->fl &= ~MANH_LITERAL;
416:
1.8 kristaps 417: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
1.57 kristaps 418: t = NULL;
1.8 kristaps 419: switch (n->tok) {
1.93 schwarze 420: case MAN_BI:
1.57 kristaps 421: fp = i % 2 ? TAG_I : TAG_B;
1.8 kristaps 422: break;
1.93 schwarze 423: case MAN_IB:
1.57 kristaps 424: fp = i % 2 ? TAG_B : TAG_I;
1.8 kristaps 425: break;
1.93 schwarze 426: case MAN_RI:
1.57 kristaps 427: fp = i % 2 ? TAG_I : TAG_MAX;
1.8 kristaps 428: break;
1.93 schwarze 429: case MAN_IR:
1.57 kristaps 430: fp = i % 2 ? TAG_MAX : TAG_I;
1.8 kristaps 431: break;
1.93 schwarze 432: case MAN_BR:
1.57 kristaps 433: fp = i % 2 ? TAG_MAX : TAG_B;
1.8 kristaps 434: break;
1.93 schwarze 435: case MAN_RB:
1.57 kristaps 436: fp = i % 2 ? TAG_B : TAG_MAX;
1.8 kristaps 437: break;
438: default:
439: abort();
440: /* NOTREACHED */
441: }
442:
443: if (i)
444: h->flags |= HTML_NOSPACE;
445:
1.57 kristaps 446: if (TAG_MAX != fp)
447: t = print_otag(h, fp, 0, NULL);
448:
1.89 schwarze 449: print_man_node(man, nn, mh, h);
1.57 kristaps 450:
451: if (t)
452: print_tagq(h, t);
1.8 kristaps 453: }
454:
1.78 kristaps 455: if (savelit)
456: mh->fl |= MANH_LITERAL;
457:
1.8 kristaps 458: return(0);
459: }
460:
461: static int
1.56 kristaps 462: man_SM_pre(MAN_ARGS)
1.8 kristaps 463: {
1.93 schwarze 464:
1.57 kristaps 465: print_otag(h, TAG_SMALL, 0, NULL);
1.56 kristaps 466: if (MAN_SB == n->tok)
1.57 kristaps 467: print_otag(h, TAG_B, 0, NULL);
1.8 kristaps 468: return(1);
469: }
470:
471: static int
1.4 kristaps 472: man_SS_pre(MAN_ARGS)
473: {
1.54 kristaps 474: struct htmlpair tag;
1.4 kristaps 475:
1.54 kristaps 476: if (MAN_BLOCK == n->type) {
1.76 kristaps 477: mh->fl &= ~MANH_LITERAL;
1.54 kristaps 478: PAIR_CLASS_INIT(&tag, "subsection");
479: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 480: return(1);
1.54 kristaps 481: } else if (MAN_BODY == n->type)
1.4 kristaps 482: return(1);
483:
1.54 kristaps 484: print_otag(h, TAG_H2, 0, NULL);
1.4 kristaps 485: return(1);
486: }
487:
488: static int
489: man_PP_pre(MAN_ARGS)
490: {
491:
1.47 kristaps 492: if (MAN_HEAD == n->type)
493: return(0);
1.74 kristaps 494: else if (MAN_BLOCK == n->type)
495: print_bvspace(h, n);
1.47 kristaps 496:
1.5 kristaps 497: return(1);
498: }
499:
500: static int
501: man_IP_pre(MAN_ARGS)
502: {
503: const struct man_node *nn;
504:
1.93 schwarze 505: if (MAN_BODY == n->type) {
1.77 kristaps 506: print_otag(h, TAG_DD, 0, NULL);
507: return(1);
508: } else if (MAN_HEAD != n->type) {
509: print_otag(h, TAG_DL, 0, NULL);
1.6 kristaps 510: return(1);
511: }
512:
1.78 kristaps 513: /* FIXME: width specification. */
514:
1.77 kristaps 515: print_otag(h, TAG_DT, 0, NULL);
1.6 kristaps 516:
1.59 schwarze 517: /* For IP, only print the first header element. */
1.7 kristaps 518:
1.59 schwarze 519: if (MAN_IP == n->tok && n->child)
1.89 schwarze 520: print_man_node(man, n->child, mh, h);
1.27 kristaps 521:
1.59 schwarze 522: /* For TP, only print next-line header elements. */
1.6 kristaps 523:
1.91 schwarze 524: if (MAN_TP == n->tok) {
525: nn = n->child;
526: while (NULL != nn && 0 == (MAN_LINE & nn->flags))
527: nn = nn->next;
528: while (NULL != nn) {
529: print_man_node(man, nn, mh, h);
530: nn = nn->next;
531: }
532: }
1.6 kristaps 533:
534: return(0);
535: }
536:
537: static int
538: man_HP_pre(MAN_ARGS)
539: {
1.103 kristaps 540: struct htmlpair tag[2];
1.56 kristaps 541: struct roffsu su;
542: const struct man_node *np;
1.6 kristaps 543:
1.77 kristaps 544: if (MAN_HEAD == n->type)
545: return(0);
546: else if (MAN_BLOCK != n->type)
547: return(1);
1.72 kristaps 548:
1.77 kristaps 549: np = n->head->child;
1.6 kristaps 550:
1.56 kristaps 551: if (NULL == np || ! a2width(np, &su))
552: SCALE_HS_INIT(&su, INDENT);
1.6 kristaps 553:
1.77 kristaps 554: bufinit(h);
1.5 kristaps 555:
1.77 kristaps 556: print_bvspace(h, n);
557: bufcat_su(h, "margin-left", &su);
1.56 kristaps 558: su.scale = -su.scale;
1.7 kristaps 559: bufcat_su(h, "text-indent", &su);
1.103 kristaps 560: PAIR_STYLE_INIT(&tag[0], h);
561: PAIR_CLASS_INIT(&tag[1], "spacer");
562: print_otag(h, TAG_DIV, 2, tag);
1.4 kristaps 563: return(1);
564: }
1.86 kristaps 565:
566: static int
567: man_OP_pre(MAN_ARGS)
568: {
569: struct tag *tt;
570: struct htmlpair tag;
571:
572: print_text(h, "[");
573: h->flags |= HTML_NOSPACE;
574: PAIR_CLASS_INIT(&tag, "opt");
575: tt = print_otag(h, TAG_SPAN, 1, &tag);
576:
577: if (NULL != (n = n->child)) {
578: print_otag(h, TAG_B, 0, NULL);
579: print_text(h, n->string);
580: }
581:
582: print_stagq(h, tt);
583:
584: if (NULL != n && NULL != n->next) {
585: print_otag(h, TAG_I, 0, NULL);
586: print_text(h, n->next->string);
587: }
588:
589: print_stagq(h, tt);
590: h->flags |= HTML_NOSPACE;
591: print_text(h, "]");
592: return(0);
593: }
594:
1.8 kristaps 595: static int
596: man_B_pre(MAN_ARGS)
597: {
598:
1.57 kristaps 599: print_otag(h, TAG_B, 0, NULL);
1.8 kristaps 600: return(1);
601: }
602:
603: static int
604: man_I_pre(MAN_ARGS)
605: {
1.93 schwarze 606:
1.57 kristaps 607: print_otag(h, TAG_I, 0, NULL);
1.8 kristaps 608: return(1);
1.45 kristaps 609: }
610:
611: static int
612: man_literal_pre(MAN_ARGS)
613: {
614:
1.88 schwarze 615: if (MAN_fi == n->tok || MAN_EE == n->tok) {
1.45 kristaps 616: print_otag(h, TAG_BR, 0, NULL);
1.78 kristaps 617: mh->fl &= ~MANH_LITERAL;
618: } else
1.45 kristaps 619: mh->fl |= MANH_LITERAL;
620:
1.67 schwarze 621: return(0);
1.45 kristaps 622: }
623:
624: static int
625: man_in_pre(MAN_ARGS)
626: {
627:
628: print_otag(h, TAG_BR, 0, NULL);
629: return(0);
1.8 kristaps 630: }
631:
632: static int
633: man_ign_pre(MAN_ARGS)
634: {
635:
636: return(0);
637: }
1.9 kristaps 638:
639: static int
640: man_RS_pre(MAN_ARGS)
641: {
642: struct htmlpair tag;
643: struct roffsu su;
644:
645: if (MAN_HEAD == n->type)
646: return(0);
647: else if (MAN_BODY == n->type)
648: return(1);
649:
650: SCALE_HS_INIT(&su, INDENT);
1.56 kristaps 651: if (n->head->child)
1.9 kristaps 652: a2width(n->head->child, &su);
653:
1.72 kristaps 654: bufinit(h);
1.56 kristaps 655: bufcat_su(h, "margin-left", &su);
1.9 kristaps 656: PAIR_STYLE_INIT(&tag, h);
657: print_otag(h, TAG_DIV, 1, &tag);
658: return(1);
1.90 schwarze 659: }
660:
661: static int
662: man_UR_pre(MAN_ARGS)
663: {
664: struct htmlpair tag[2];
665:
666: n = n->child;
667: assert(MAN_HEAD == n->type);
668: if (n->nchild) {
669: assert(MAN_TEXT == n->child->type);
670: PAIR_CLASS_INIT(&tag[0], "link-ext");
671: PAIR_HREF_INIT(&tag[1], n->child->string);
672: print_otag(h, TAG_A, 2, tag);
673: }
674:
675: assert(MAN_BODY == n->next->type);
676: if (n->next->nchild)
677: n = n->next;
678:
679: print_man_nodelist(man, n->child, mh, h);
680:
681: return(0);
1.9 kristaps 682: }
CVSweb