Annotation of mandoc/man_html.c, Revision 1.23
1.23 ! kristaps 1: /* $Id: man_html.c,v 1.22 2009/11/15 06:53:59 kristaps Exp $ */
1.1 kristaps 2: /*
3: * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
4: *
5: * Permission to use, copy, modify, and distribute this software for any
6: * purpose with or without fee is hereby granted, provided that the above
7: * copyright notice and this permission notice appear in all copies.
8: *
9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16: */
17: #include <sys/types.h>
18:
1.5 kristaps 19: #include <assert.h>
20: #include <ctype.h>
1.2 kristaps 21: #include <stdio.h>
1.1 kristaps 22: #include <stdlib.h>
1.4 kristaps 23: #include <string.h>
1.1 kristaps 24:
1.7 kristaps 25: #include "out.h"
1.1 kristaps 26: #include "html.h"
27: #include "man.h"
1.10 kristaps 28: #include "main.h"
1.1 kristaps 29:
1.6 kristaps 30: /* TODO: preserve ident widths. */
1.13 kristaps 31: /* FIXME: have PD set the default vspace width. */
1.6 kristaps 32:
33: #define INDENT 5
1.4 kristaps 34: #define HALFINDENT 3
35:
1.3 kristaps 36: #define MAN_ARGS const struct man_meta *m, \
37: const struct man_node *n, \
38: struct html *h
39:
40: struct htmlman {
41: int (*pre)(MAN_ARGS);
42: int (*post)(MAN_ARGS);
43: };
44:
45: static void print_man(MAN_ARGS);
46: static void print_man_head(MAN_ARGS);
1.4 kristaps 47: static void print_man_nodelist(MAN_ARGS);
48: static void print_man_node(MAN_ARGS);
1.3 kristaps 49:
1.7 kristaps 50: static int a2width(const struct man_node *,
51: struct roffsu *);
1.5 kristaps 52:
1.8 kristaps 53: static int man_alt_pre(MAN_ARGS);
1.4 kristaps 54: static int man_br_pre(MAN_ARGS);
1.8 kristaps 55: static int man_ign_pre(MAN_ARGS);
56: static void man_root_post(MAN_ARGS);
57: static int man_root_pre(MAN_ARGS);
58: static int man_B_pre(MAN_ARGS);
1.6 kristaps 59: static int man_HP_pre(MAN_ARGS);
1.8 kristaps 60: static int man_I_pre(MAN_ARGS);
1.5 kristaps 61: static int man_IP_pre(MAN_ARGS);
1.4 kristaps 62: static int man_PP_pre(MAN_ARGS);
1.9 kristaps 63: static int man_RS_pre(MAN_ARGS);
1.8 kristaps 64: static int man_SB_pre(MAN_ARGS);
1.4 kristaps 65: static int man_SH_pre(MAN_ARGS);
1.8 kristaps 66: static int man_SM_pre(MAN_ARGS);
1.4 kristaps 67: static int man_SS_pre(MAN_ARGS);
68:
69: #ifdef __linux__
70: extern size_t strlcpy(char *, const char *, size_t);
71: extern size_t strlcat(char *, const char *, size_t);
72: #endif
1.3 kristaps 73:
74: static const struct htmlman mans[MAN_MAX] = {
1.4 kristaps 75: { man_br_pre, NULL }, /* br */
1.3 kristaps 76: { NULL, NULL }, /* TH */
1.4 kristaps 77: { man_SH_pre, NULL }, /* SH */
78: { man_SS_pre, NULL }, /* SS */
1.6 kristaps 79: { man_IP_pre, NULL }, /* TP */
1.4 kristaps 80: { man_PP_pre, NULL }, /* LP */
81: { man_PP_pre, NULL }, /* PP */
82: { man_PP_pre, NULL }, /* P */
1.5 kristaps 83: { man_IP_pre, NULL }, /* IP */
1.6 kristaps 84: { man_HP_pre, NULL }, /* HP */
1.8 kristaps 85: { man_SM_pre, NULL }, /* SM */
86: { man_SB_pre, NULL }, /* SB */
87: { man_alt_pre, NULL }, /* BI */
88: { man_alt_pre, NULL }, /* IB */
89: { man_alt_pre, NULL }, /* BR */
90: { man_alt_pre, NULL }, /* RB */
1.3 kristaps 91: { NULL, NULL }, /* R */
1.8 kristaps 92: { man_B_pre, NULL }, /* B */
93: { man_I_pre, NULL }, /* I */
94: { man_alt_pre, NULL }, /* IR */
95: { man_alt_pre, NULL }, /* RI */
1.3 kristaps 96: { NULL, NULL }, /* na */
97: { NULL, NULL }, /* i */
1.4 kristaps 98: { man_br_pre, NULL }, /* sp */
1.3 kristaps 99: { NULL, NULL }, /* nf */
100: { NULL, NULL }, /* fi */
101: { NULL, NULL }, /* r */
102: { NULL, NULL }, /* RE */
1.9 kristaps 103: { man_RS_pre, NULL }, /* RS */
1.8 kristaps 104: { man_ign_pre, NULL }, /* DT */
105: { man_ign_pre, NULL }, /* UC */
1.13 kristaps 106: { man_ign_pre, NULL }, /* PD */
1.3 kristaps 107: };
108:
1.1 kristaps 109:
110: void
111: html_man(void *arg, const struct man *m)
112: {
1.3 kristaps 113: struct html *h;
114: struct tag *t;
115:
116: h = (struct html *)arg;
117:
118: print_gen_doctype(h);
119:
120: t = print_otag(h, TAG_HTML, 0, NULL);
121: print_man(man_meta(m), man_node(m), h);
122: print_tagq(h, t);
123:
124: printf("\n");
125: }
126:
127:
128: static void
129: print_man(MAN_ARGS)
130: {
131: struct tag *t;
132: struct htmlpair tag;
133:
134: t = print_otag(h, TAG_HEAD, 0, NULL);
135:
136: print_man_head(m, n, h);
137: print_tagq(h, t);
138: t = print_otag(h, TAG_BODY, 0, NULL);
139:
140: tag.key = ATTR_CLASS;
141: tag.val = "body";
142: print_otag(h, TAG_DIV, 1, &tag);
143:
1.4 kristaps 144: print_man_nodelist(m, n, h);
1.3 kristaps 145:
146: print_tagq(h, t);
147: }
148:
149:
150: /* ARGSUSED */
151: static void
152: print_man_head(MAN_ARGS)
153: {
154:
155: print_gen_head(h);
156: bufinit(h);
157: buffmt(h, "%s(%d)", m->title, m->msec);
158:
159: print_otag(h, TAG_TITLE, 0, NULL);
160: print_text(h, h->buf);
1.1 kristaps 161: }
1.4 kristaps 162:
163:
164: static void
165: print_man_nodelist(MAN_ARGS)
166: {
167:
168: print_man_node(m, n, h);
169: if (n->next)
170: print_man_nodelist(m, n->next, h);
171: }
172:
173:
174: static void
175: print_man_node(MAN_ARGS)
176: {
177: int child;
178: struct tag *t;
179:
180: child = 1;
1.14 kristaps 181: t = h->tags.head;
1.4 kristaps 182:
183: bufinit(h);
184:
185: switch (n->type) {
186: case (MAN_ROOT):
187: child = man_root_pre(m, n, h);
188: break;
189: case (MAN_TEXT):
190: print_text(h, n->string);
1.19 kristaps 191: return;
1.4 kristaps 192: default:
1.21 kristaps 193: /*
194: * Close out scope of font prior to opening a macro
195: * scope. Assert that the metafont is on the top of the
196: * stack (it's never nested).
197: */
1.20 kristaps 198: if (h->metaf) {
199: assert(h->metaf == t);
200: print_tagq(h, h->metaf);
1.21 kristaps 201: assert(NULL == h->metaf);
1.20 kristaps 202: t = h->tags.head;
203: }
1.4 kristaps 204: if (mans[n->tok].pre)
205: child = (*mans[n->tok].pre)(m, n, h);
206: break;
207: }
208:
1.21 kristaps 209: if (child && n->child)
210: print_man_nodelist(m, n->child, h);
211:
1.4 kristaps 212: print_stagq(h, t);
213:
214: bufinit(h);
215:
216: switch (n->type) {
217: case (MAN_ROOT):
218: man_root_post(m, n, h);
219: break;
220: case (MAN_TEXT):
221: break;
222: default:
223: if (mans[n->tok].post)
224: (*mans[n->tok].post)(m, n, h);
225: break;
226: }
227: }
228:
229:
1.5 kristaps 230: static int
1.7 kristaps 231: a2width(const struct man_node *n, struct roffsu *su)
1.5 kristaps 232: {
233:
1.6 kristaps 234: if (MAN_TEXT != n->type)
1.7 kristaps 235: return(0);
1.11 kristaps 236: if (a2roffsu(n->string, su, SCALE_BU))
1.7 kristaps 237: return(1);
1.5 kristaps 238:
1.7 kristaps 239: return(0);
1.5 kristaps 240: }
241:
242:
1.4 kristaps 243: /* ARGSUSED */
244: static int
245: man_root_pre(MAN_ARGS)
246: {
1.15 kristaps 247: struct htmlpair tag[3];
1.4 kristaps 248: struct tag *t, *tt;
249: char b[BUFSIZ], title[BUFSIZ];
250:
251: b[0] = 0;
252: if (m->vol)
253: (void)strlcat(b, m->vol, BUFSIZ);
254:
255: (void)snprintf(title, BUFSIZ - 1,
256: "%s(%d)", m->title, m->msec);
257:
1.7 kristaps 258: PAIR_CLASS_INIT(&tag[0], "header");
259: bufcat_style(h, "width", "100%");
260: PAIR_STYLE_INIT(&tag[1], h);
1.15 kristaps 261: PAIR_SUMMARY_INIT(&tag[2], "header");
262:
263: t = print_otag(h, TAG_TABLE, 3, tag);
1.4 kristaps 264: tt = print_otag(h, TAG_TR, 0, NULL);
265:
1.7 kristaps 266: bufinit(h);
267: bufcat_style(h, "width", "10%");
268: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 269: print_otag(h, TAG_TD, 1, tag);
270: print_text(h, title);
271: print_stagq(h, tt);
272:
1.7 kristaps 273: bufinit(h);
274: bufcat_style(h, "width", "80%");
275: bufcat_style(h, "white-space", "nowrap");
276: bufcat_style(h, "text-align", "center");
277: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 278: print_otag(h, TAG_TD, 1, tag);
279: print_text(h, b);
280: print_stagq(h, tt);
281:
1.7 kristaps 282: bufinit(h);
283: bufcat_style(h, "width", "10%");
284: bufcat_style(h, "text-align", "right");
285: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 286: print_otag(h, TAG_TD, 1, tag);
287: print_text(h, title);
288: print_tagq(h, t);
289: return(1);
290: }
291:
292:
293: /* ARGSUSED */
294: static void
295: man_root_post(MAN_ARGS)
296: {
1.15 kristaps 297: struct htmlpair tag[3];
1.4 kristaps 298: struct tag *t, *tt;
1.12 kristaps 299: char b[DATESIZ];
1.4 kristaps 300:
1.12 kristaps 301: time2a(m->date, b, DATESIZ);
1.4 kristaps 302:
1.7 kristaps 303: PAIR_CLASS_INIT(&tag[0], "footer");
304: bufcat_style(h, "width", "100%");
305: PAIR_STYLE_INIT(&tag[1], h);
1.15 kristaps 306: PAIR_SUMMARY_INIT(&tag[2], "footer");
307:
308: t = print_otag(h, TAG_TABLE, 3, tag);
1.4 kristaps 309: tt = print_otag(h, TAG_TR, 0, NULL);
310:
1.7 kristaps 311: bufinit(h);
312: bufcat_style(h, "width", "50%");
313: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 314: print_otag(h, TAG_TD, 1, tag);
315: print_text(h, b);
316: print_stagq(h, tt);
317:
1.7 kristaps 318: bufinit(h);
319: bufcat_style(h, "width", "50%");
320: bufcat_style(h, "text-align", "right");
321: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 322: print_otag(h, TAG_TD, 1, tag);
323: if (m->source)
324: print_text(h, m->source);
325: print_tagq(h, t);
326: }
327:
328:
329:
330: /* ARGSUSED */
331: static int
332: man_br_pre(MAN_ARGS)
333: {
1.7 kristaps 334: struct roffsu su;
335: struct htmlpair tag;
1.4 kristaps 336:
1.7 kristaps 337: SCALE_VS_INIT(&su, 1);
338:
1.11 kristaps 339: if (MAN_sp == n->tok && n->child)
340: a2roffsu(n->child->string, &su, SCALE_VS);
341: else if (MAN_br == n->tok)
1.7 kristaps 342: su.scale = 0;
1.4 kristaps 343:
1.7 kristaps 344: bufcat_su(h, "height", &su);
345: PAIR_STYLE_INIT(&tag, h);
1.4 kristaps 346: print_otag(h, TAG_DIV, 1, &tag);
1.16 kristaps 347: /* So the div isn't empty: */
348: print_text(h, "\\~");
349:
1.7 kristaps 350: return(0);
1.4 kristaps 351: }
352:
353:
354: /* ARGSUSED */
355: static int
356: man_SH_pre(MAN_ARGS)
357: {
1.7 kristaps 358: struct htmlpair tag[2];
359: struct roffsu su;
1.4 kristaps 360:
361: if (MAN_BODY == n->type) {
1.7 kristaps 362: SCALE_HS_INIT(&su, INDENT);
363: bufcat_su(h, "margin-left", &su);
364: PAIR_CLASS_INIT(&tag[0], "sec-body");
365: PAIR_STYLE_INIT(&tag[1], h);
1.4 kristaps 366: print_otag(h, TAG_DIV, 2, tag);
367: return(1);
368: } else if (MAN_BLOCK == n->type) {
1.7 kristaps 369: PAIR_CLASS_INIT(&tag[0], "sec-block");
1.4 kristaps 370: if (n->prev && MAN_SH == n->prev->tok)
371: if (NULL == n->prev->body->child) {
372: print_otag(h, TAG_DIV, 1, tag);
373: return(1);
374: }
375:
1.7 kristaps 376: SCALE_VS_INIT(&su, 1);
377: bufcat_su(h, "margin-top", &su);
1.4 kristaps 378: if (NULL == n->next)
1.7 kristaps 379: bufcat_su(h, "margin-bottom", &su);
380: PAIR_STYLE_INIT(&tag[1], h);
1.4 kristaps 381: print_otag(h, TAG_DIV, 2, tag);
382: return(1);
383: }
384:
1.7 kristaps 385: PAIR_CLASS_INIT(&tag[0], "sec-head");
1.4 kristaps 386: print_otag(h, TAG_DIV, 1, tag);
387: return(1);
388: }
389:
390:
391: /* ARGSUSED */
392: static int
1.8 kristaps 393: man_alt_pre(MAN_ARGS)
394: {
395: const struct man_node *nn;
396: struct tag *t;
397: int i;
1.23 ! kristaps 398: enum htmlfont fp;
1.8 kristaps 399:
400: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
401: switch (n->tok) {
402: case (MAN_BI):
1.23 ! kristaps 403: fp = i % 2 ? HTMLFONT_ITALIC : HTMLFONT_BOLD;
1.8 kristaps 404: break;
405: case (MAN_IB):
1.23 ! kristaps 406: fp = i % 2 ? HTMLFONT_BOLD : HTMLFONT_ITALIC;
1.8 kristaps 407: break;
408: case (MAN_RI):
1.23 ! kristaps 409: fp = i % 2 ? HTMLFONT_ITALIC : HTMLFONT_NONE;
1.8 kristaps 410: break;
411: case (MAN_IR):
1.23 ! kristaps 412: fp = i % 2 ? HTMLFONT_NONE : HTMLFONT_ITALIC;
1.8 kristaps 413: break;
414: case (MAN_BR):
1.23 ! kristaps 415: fp = i % 2 ? HTMLFONT_NONE : HTMLFONT_BOLD;
1.8 kristaps 416: break;
417: case (MAN_RB):
1.23 ! kristaps 418: fp = i % 2 ? HTMLFONT_BOLD : HTMLFONT_NONE;
1.8 kristaps 419: break;
420: default:
421: abort();
422: /* NOTREACHED */
423: }
424:
425: if (i)
426: h->flags |= HTML_NOSPACE;
427:
1.23 ! kristaps 428: t = print_ofont(h, fp);
1.21 kristaps 429: print_man_node(m, nn, h);
430: print_tagq(h, t);
1.8 kristaps 431: }
432:
433: return(0);
434: }
435:
436:
437: /* ARGSUSED */
438: static int
439: man_SB_pre(MAN_ARGS)
440: {
441: struct htmlpair tag;
442:
1.23 ! kristaps 443: /* FIXME: print_ofont(). */
1.8 kristaps 444: PAIR_CLASS_INIT(&tag, "small bold");
445: print_otag(h, TAG_SPAN, 1, &tag);
446: return(1);
447: }
448:
449:
450: /* ARGSUSED */
451: static int
452: man_SM_pre(MAN_ARGS)
453: {
454: struct htmlpair tag;
455:
456: PAIR_CLASS_INIT(&tag, "small");
457: print_otag(h, TAG_SPAN, 1, &tag);
458: return(1);
459: }
460:
461:
462: /* ARGSUSED */
463: static int
1.4 kristaps 464: man_SS_pre(MAN_ARGS)
465: {
466: struct htmlpair tag[3];
1.7 kristaps 467: struct roffsu su;
1.4 kristaps 468:
1.7 kristaps 469: SCALE_VS_INIT(&su, 1);
1.4 kristaps 470:
471: if (MAN_BODY == n->type) {
1.7 kristaps 472: PAIR_CLASS_INIT(&tag[0], "ssec-body");
1.4 kristaps 473: if (n->parent->next && n->child) {
1.7 kristaps 474: bufcat_su(h, "margin-bottom", &su);
475: PAIR_STYLE_INIT(&tag[1], h);
476: print_otag(h, TAG_DIV, 2, tag);
477: return(1);
1.4 kristaps 478: }
479:
1.7 kristaps 480: print_otag(h, TAG_DIV, 1, tag);
1.4 kristaps 481: return(1);
482: } else if (MAN_BLOCK == n->type) {
1.7 kristaps 483: PAIR_CLASS_INIT(&tag[0], "ssec-block");
1.4 kristaps 484: if (n->prev && MAN_SS == n->prev->tok)
485: if (n->prev->body->child) {
1.7 kristaps 486: bufcat_su(h, "margin-top", &su);
487: PAIR_STYLE_INIT(&tag[1], h);
488: print_otag(h, TAG_DIV, 2, tag);
489: return(1);
1.4 kristaps 490: }
491:
1.7 kristaps 492: print_otag(h, TAG_DIV, 1, tag);
1.4 kristaps 493: return(1);
494: }
495:
1.7 kristaps 496: SCALE_HS_INIT(&su, INDENT - HALFINDENT);
497: bufcat_su(h, "margin-left", &su);
498: PAIR_CLASS_INIT(&tag[0], "ssec-head");
499: PAIR_STYLE_INIT(&tag[1], h);
1.4 kristaps 500: print_otag(h, TAG_DIV, 2, tag);
501: return(1);
502: }
503:
504:
505: /* ARGSUSED */
506: static int
507: man_PP_pre(MAN_ARGS)
508: {
1.5 kristaps 509: struct htmlpair tag;
1.7 kristaps 510: struct roffsu su;
1.5 kristaps 511: int i;
1.4 kristaps 512:
513: if (MAN_BLOCK != n->type)
514: return(1);
515:
1.5 kristaps 516: i = 0;
517:
1.22 kristaps 518: if (MAN_ROOT == n->parent->type) {
1.7 kristaps 519: SCALE_HS_INIT(&su, INDENT);
520: bufcat_su(h, "margin-left", &su);
1.22 kristaps 521: i = 1;
1.5 kristaps 522: }
1.22 kristaps 523: if (n->prev) {
1.7 kristaps 524: SCALE_VS_INIT(&su, 1);
1.22 kristaps 525: bufcat_su(h, "margin-top", &su);
526: i = 1;
1.5 kristaps 527: }
1.4 kristaps 528:
1.7 kristaps 529: PAIR_STYLE_INIT(&tag, h);
1.22 kristaps 530: print_otag(h, TAG_DIV, i, &tag);
1.5 kristaps 531: return(1);
532: }
533:
534:
535: /* ARGSUSED */
536: static int
537: man_IP_pre(MAN_ARGS)
538: {
1.7 kristaps 539: struct roffsu su;
1.5 kristaps 540: struct htmlpair tag;
541: const struct man_node *nn;
1.7 kristaps 542: int width;
1.5 kristaps 543:
1.7 kristaps 544: /*
545: * This scattering of 1-BU margins and pads is to make sure that
546: * when text overruns its box, the subsequent text isn't flush
547: * up against it. However, the rest of the right-hand box must
548: * also be adjusted in consideration of this 1-BU space.
549: */
550:
551: if (MAN_BODY == n->type) {
552: SCALE_HS_INIT(&su, INDENT);
553: bufcat_su(h, "margin-left", &su);
554: PAIR_STYLE_INIT(&tag, h);
555: print_otag(h, TAG_DIV, 1, &tag);
1.6 kristaps 556: return(1);
557: }
558:
559: nn = MAN_BLOCK == n->type ?
560: n->head->child : n->parent->head->child;
561:
1.7 kristaps 562: SCALE_HS_INIT(&su, INDENT);
563: width = 0;
1.6 kristaps 564:
1.7 kristaps 565: if (MAN_IP == n->tok && NULL != nn)
1.5 kristaps 566: if (NULL != (nn = nn->next)) {
567: for ( ; nn->next; nn = nn->next)
568: /* Do nothing. */ ;
1.7 kristaps 569: width = a2width(nn, &su);
1.5 kristaps 570: }
571:
1.7 kristaps 572: if (MAN_TP == n->tok && NULL != nn)
573: width = a2width(nn, &su);
574:
1.5 kristaps 575: if (MAN_BLOCK == n->type) {
1.7 kristaps 576: bufcat_su(h, "margin-left", &su);
1.9 kristaps 577: SCALE_VS_INIT(&su, 1);
578: bufcat_su(h, "margin-top", &su);
1.7 kristaps 579: bufcat_style(h, "clear", "both");
580: PAIR_STYLE_INIT(&tag, h);
1.5 kristaps 581: print_otag(h, TAG_DIV, 1, &tag);
582: return(1);
1.6 kristaps 583: }
584:
1.7 kristaps 585: bufcat_su(h, "min-width", &su);
586: SCALE_INVERT(&su);
587: bufcat_su(h, "margin-left", &su);
588: SCALE_HS_INIT(&su, 1);
589: bufcat_su(h, "margin-right", &su);
590: bufcat_style(h, "clear", "left");
1.6 kristaps 591:
592: if (n->next && n->next->child)
1.7 kristaps 593: bufcat_style(h, "float", "left");
1.6 kristaps 594:
1.7 kristaps 595: PAIR_STYLE_INIT(&tag, h);
1.6 kristaps 596: print_otag(h, TAG_DIV, 1, &tag);
597:
1.7 kristaps 598: /* With a length string, manually omit the last child. */
599:
600: if ( ! width)
1.6 kristaps 601: return(1);
602:
1.7 kristaps 603: if (MAN_IP == n->tok)
604: for (nn = n->child; nn->next; nn = nn->next)
605: print_man_node(m, nn, h);
606: if (MAN_TP == n->tok)
607: for (nn = n->child->next; nn; nn = nn->next)
608: print_man_node(m, nn, h);
1.6 kristaps 609:
610: return(0);
611: }
612:
613:
614: /* ARGSUSED */
615: static int
616: man_HP_pre(MAN_ARGS)
617: {
618: const struct man_node *nn;
619: struct htmlpair tag;
1.7 kristaps 620: struct roffsu su;
1.6 kristaps 621:
622: if (MAN_HEAD == n->type)
623: return(0);
624:
625: nn = MAN_BLOCK == n->type ?
626: n->head->child : n->parent->head->child;
627:
1.7 kristaps 628: SCALE_HS_INIT(&su, INDENT);
1.6 kristaps 629:
630: if (NULL != nn)
1.7 kristaps 631: (void)a2width(nn, &su);
1.6 kristaps 632:
633: if (MAN_BLOCK == n->type) {
1.7 kristaps 634: bufcat_su(h, "margin-left", &su);
1.9 kristaps 635: SCALE_VS_INIT(&su, 1);
636: bufcat_su(h, "margin-top", &su);
1.7 kristaps 637: bufcat_style(h, "clear", "both");
638: PAIR_STYLE_INIT(&tag, h);
1.5 kristaps 639: print_otag(h, TAG_DIV, 1, &tag);
1.6 kristaps 640: return(1);
641: }
1.5 kristaps 642:
1.7 kristaps 643: bufcat_su(h, "margin-left", &su);
644: SCALE_INVERT(&su);
645: bufcat_su(h, "text-indent", &su);
1.5 kristaps 646:
1.7 kristaps 647: PAIR_STYLE_INIT(&tag, h);
1.6 kristaps 648: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 649: return(1);
650: }
1.6 kristaps 651:
1.8 kristaps 652:
653: /* ARGSUSED */
654: static int
655: man_B_pre(MAN_ARGS)
656: {
657:
1.23 ! kristaps 658: print_ofont(h, HTMLFONT_BOLD);
1.8 kristaps 659: return(1);
660: }
661:
662:
663: /* ARGSUSED */
664: static int
665: man_I_pre(MAN_ARGS)
666: {
1.23 ! kristaps 667:
! 668: print_ofont(h, HTMLFONT_ITALIC);
1.8 kristaps 669: return(1);
670: }
671:
672:
673: /* ARGSUSED */
674: static int
675: man_ign_pre(MAN_ARGS)
676: {
677:
678: return(0);
679: }
1.9 kristaps 680:
681:
682: /* ARGSUSED */
683: static int
684: man_RS_pre(MAN_ARGS)
685: {
686: struct htmlpair tag;
687: struct roffsu su;
688:
689: if (MAN_HEAD == n->type)
690: return(0);
691: else if (MAN_BODY == n->type)
692: return(1);
693:
694: SCALE_HS_INIT(&su, INDENT);
695: bufcat_su(h, "margin-left", &su);
696:
697: if (n->head->child) {
698: SCALE_VS_INIT(&su, 1);
699: a2width(n->head->child, &su);
700: bufcat_su(h, "margin-top", &su);
701: }
702:
703: PAIR_STYLE_INIT(&tag, h);
704: print_otag(h, TAG_DIV, 1, &tag);
705: return(1);
706: }
CVSweb