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