Annotation of mandoc/man_html.c, Revision 1.20
1.20 ! kristaps 1: /* $Id: man_html.c,v 1.19 2009/11/14 11:58:36 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.20 ! kristaps 193: if (h->metaf) {
! 194: assert(h->metaf == t);
! 195: print_tagq(h, h->metaf);
! 196: t = h->tags.head;
! 197: }
1.4 kristaps 198: if (mans[n->tok].pre)
199: child = (*mans[n->tok].pre)(m, n, h);
200: break;
201: }
202:
203: print_stagq(h, t);
204:
205: bufinit(h);
206:
207: switch (n->type) {
208: case (MAN_ROOT):
209: man_root_post(m, n, h);
210: break;
211: case (MAN_TEXT):
212: break;
213: default:
214: if (mans[n->tok].post)
215: (*mans[n->tok].post)(m, n, h);
216: break;
217: }
218: }
219:
220:
1.5 kristaps 221: static int
1.7 kristaps 222: a2width(const struct man_node *n, struct roffsu *su)
1.5 kristaps 223: {
224:
1.6 kristaps 225: if (MAN_TEXT != n->type)
1.7 kristaps 226: return(0);
1.11 kristaps 227: if (a2roffsu(n->string, su, SCALE_BU))
1.7 kristaps 228: return(1);
1.5 kristaps 229:
1.7 kristaps 230: return(0);
1.5 kristaps 231: }
232:
233:
1.4 kristaps 234: /* ARGSUSED */
235: static int
236: man_root_pre(MAN_ARGS)
237: {
1.15 kristaps 238: struct htmlpair tag[3];
1.4 kristaps 239: struct tag *t, *tt;
240: char b[BUFSIZ], title[BUFSIZ];
241:
242: b[0] = 0;
243: if (m->vol)
244: (void)strlcat(b, m->vol, BUFSIZ);
245:
246: (void)snprintf(title, BUFSIZ - 1,
247: "%s(%d)", m->title, m->msec);
248:
1.7 kristaps 249: PAIR_CLASS_INIT(&tag[0], "header");
250: bufcat_style(h, "width", "100%");
251: PAIR_STYLE_INIT(&tag[1], h);
1.15 kristaps 252: PAIR_SUMMARY_INIT(&tag[2], "header");
253:
254: t = print_otag(h, TAG_TABLE, 3, tag);
1.4 kristaps 255: tt = print_otag(h, TAG_TR, 0, NULL);
256:
1.7 kristaps 257: bufinit(h);
258: bufcat_style(h, "width", "10%");
259: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 260: print_otag(h, TAG_TD, 1, tag);
261: print_text(h, title);
262: print_stagq(h, tt);
263:
1.7 kristaps 264: bufinit(h);
265: bufcat_style(h, "width", "80%");
266: bufcat_style(h, "white-space", "nowrap");
267: bufcat_style(h, "text-align", "center");
268: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 269: print_otag(h, TAG_TD, 1, tag);
270: print_text(h, b);
271: print_stagq(h, tt);
272:
1.7 kristaps 273: bufinit(h);
274: bufcat_style(h, "width", "10%");
275: bufcat_style(h, "text-align", "right");
276: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 277: print_otag(h, TAG_TD, 1, tag);
278: print_text(h, title);
279: print_tagq(h, t);
280: return(1);
281: }
282:
283:
284: /* ARGSUSED */
285: static void
286: man_root_post(MAN_ARGS)
287: {
1.15 kristaps 288: struct htmlpair tag[3];
1.4 kristaps 289: struct tag *t, *tt;
1.12 kristaps 290: char b[DATESIZ];
1.4 kristaps 291:
1.12 kristaps 292: time2a(m->date, b, DATESIZ);
1.4 kristaps 293:
1.7 kristaps 294: PAIR_CLASS_INIT(&tag[0], "footer");
295: bufcat_style(h, "width", "100%");
296: PAIR_STYLE_INIT(&tag[1], h);
1.15 kristaps 297: PAIR_SUMMARY_INIT(&tag[2], "footer");
298:
299: t = print_otag(h, TAG_TABLE, 3, tag);
1.4 kristaps 300: tt = print_otag(h, TAG_TR, 0, NULL);
301:
1.7 kristaps 302: bufinit(h);
303: bufcat_style(h, "width", "50%");
304: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 305: print_otag(h, TAG_TD, 1, tag);
306: print_text(h, b);
307: print_stagq(h, tt);
308:
1.7 kristaps 309: bufinit(h);
310: bufcat_style(h, "width", "50%");
311: bufcat_style(h, "text-align", "right");
312: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 313: print_otag(h, TAG_TD, 1, tag);
314: if (m->source)
315: print_text(h, m->source);
316: print_tagq(h, t);
317: }
318:
319:
320:
321: /* ARGSUSED */
322: static int
323: man_br_pre(MAN_ARGS)
324: {
1.7 kristaps 325: struct roffsu su;
326: struct htmlpair tag;
1.4 kristaps 327:
1.7 kristaps 328: SCALE_VS_INIT(&su, 1);
329:
1.11 kristaps 330: if (MAN_sp == n->tok && n->child)
331: a2roffsu(n->child->string, &su, SCALE_VS);
332: else if (MAN_br == n->tok)
1.7 kristaps 333: su.scale = 0;
1.4 kristaps 334:
1.7 kristaps 335: bufcat_su(h, "height", &su);
336: PAIR_STYLE_INIT(&tag, h);
1.4 kristaps 337: print_otag(h, TAG_DIV, 1, &tag);
1.16 kristaps 338: /* So the div isn't empty: */
339: print_text(h, "\\~");
340:
1.7 kristaps 341: return(0);
1.4 kristaps 342: }
343:
344:
345: /* ARGSUSED */
346: static int
347: man_SH_pre(MAN_ARGS)
348: {
1.7 kristaps 349: struct htmlpair tag[2];
350: struct roffsu su;
1.4 kristaps 351:
352: if (MAN_BODY == n->type) {
1.7 kristaps 353: SCALE_HS_INIT(&su, INDENT);
354: bufcat_su(h, "margin-left", &su);
355: PAIR_CLASS_INIT(&tag[0], "sec-body");
356: PAIR_STYLE_INIT(&tag[1], h);
1.4 kristaps 357: print_otag(h, TAG_DIV, 2, tag);
358: return(1);
359: } else if (MAN_BLOCK == n->type) {
1.7 kristaps 360: PAIR_CLASS_INIT(&tag[0], "sec-block");
1.4 kristaps 361: if (n->prev && MAN_SH == n->prev->tok)
362: if (NULL == n->prev->body->child) {
363: print_otag(h, TAG_DIV, 1, tag);
364: return(1);
365: }
366:
1.7 kristaps 367: SCALE_VS_INIT(&su, 1);
368: bufcat_su(h, "margin-top", &su);
1.4 kristaps 369: if (NULL == n->next)
1.7 kristaps 370: bufcat_su(h, "margin-bottom", &su);
371: PAIR_STYLE_INIT(&tag[1], h);
1.4 kristaps 372: print_otag(h, TAG_DIV, 2, tag);
373: return(1);
374: }
375:
1.7 kristaps 376: PAIR_CLASS_INIT(&tag[0], "sec-head");
1.4 kristaps 377: print_otag(h, TAG_DIV, 1, tag);
378: return(1);
379: }
380:
381:
382: /* ARGSUSED */
383: static int
1.8 kristaps 384: man_alt_pre(MAN_ARGS)
385: {
386: const struct man_node *nn;
387: struct tag *t;
388: int i;
389: struct htmlpair tagi, tagb, *tagp;
390:
391: PAIR_CLASS_INIT(&tagi, "italic");
392: PAIR_CLASS_INIT(&tagb, "bold");
393:
394: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
395: switch (n->tok) {
396: case (MAN_BI):
397: tagp = i % 2 ? &tagi : &tagb;
398: break;
399: case (MAN_IB):
400: tagp = i % 2 ? &tagb : &tagi;
401: break;
402: case (MAN_RI):
403: tagp = i % 2 ? &tagi : NULL;
404: break;
405: case (MAN_IR):
406: tagp = i % 2 ? NULL : &tagi;
407: break;
408: case (MAN_BR):
409: tagp = i % 2 ? NULL : &tagb;
410: break;
411: case (MAN_RB):
412: tagp = i % 2 ? &tagb : NULL;
413: break;
414: default:
415: abort();
416: /* NOTREACHED */
417: }
418:
419: if (i)
420: h->flags |= HTML_NOSPACE;
421:
422: if (tagp) {
423: t = print_otag(h, TAG_SPAN, 1, tagp);
424: print_man_node(m, nn, h);
425: print_tagq(h, t);
426: } else
427: print_man_node(m, nn, h);
428: }
429:
430: return(0);
431: }
432:
433:
434: /* ARGSUSED */
435: static int
436: man_SB_pre(MAN_ARGS)
437: {
438: struct htmlpair tag;
439:
440: PAIR_CLASS_INIT(&tag, "small bold");
441: print_otag(h, TAG_SPAN, 1, &tag);
442: return(1);
443: }
444:
445:
446: /* ARGSUSED */
447: static int
448: man_SM_pre(MAN_ARGS)
449: {
450: struct htmlpair tag;
451:
452: PAIR_CLASS_INIT(&tag, "small");
453: print_otag(h, TAG_SPAN, 1, &tag);
454: return(1);
455: }
456:
457:
458: /* ARGSUSED */
459: static int
1.4 kristaps 460: man_SS_pre(MAN_ARGS)
461: {
462: struct htmlpair tag[3];
1.7 kristaps 463: struct roffsu su;
1.4 kristaps 464:
1.7 kristaps 465: SCALE_VS_INIT(&su, 1);
1.4 kristaps 466:
467: if (MAN_BODY == n->type) {
1.7 kristaps 468: PAIR_CLASS_INIT(&tag[0], "ssec-body");
1.4 kristaps 469: if (n->parent->next && n->child) {
1.7 kristaps 470: bufcat_su(h, "margin-bottom", &su);
471: PAIR_STYLE_INIT(&tag[1], h);
472: print_otag(h, TAG_DIV, 2, tag);
473: return(1);
1.4 kristaps 474: }
475:
1.7 kristaps 476: print_otag(h, TAG_DIV, 1, tag);
1.4 kristaps 477: return(1);
478: } else if (MAN_BLOCK == n->type) {
1.7 kristaps 479: PAIR_CLASS_INIT(&tag[0], "ssec-block");
1.4 kristaps 480: if (n->prev && MAN_SS == n->prev->tok)
481: if (n->prev->body->child) {
1.7 kristaps 482: bufcat_su(h, "margin-top", &su);
483: PAIR_STYLE_INIT(&tag[1], h);
484: print_otag(h, TAG_DIV, 2, tag);
485: return(1);
1.4 kristaps 486: }
487:
1.7 kristaps 488: print_otag(h, TAG_DIV, 1, tag);
1.4 kristaps 489: return(1);
490: }
491:
1.7 kristaps 492: SCALE_HS_INIT(&su, INDENT - HALFINDENT);
493: bufcat_su(h, "margin-left", &su);
494: PAIR_CLASS_INIT(&tag[0], "ssec-head");
495: PAIR_STYLE_INIT(&tag[1], h);
1.4 kristaps 496: print_otag(h, TAG_DIV, 2, tag);
497: return(1);
498: }
499:
500:
501: /* ARGSUSED */
502: static int
503: man_PP_pre(MAN_ARGS)
504: {
1.5 kristaps 505: struct htmlpair tag;
1.7 kristaps 506: struct roffsu su;
1.5 kristaps 507: int i;
1.4 kristaps 508:
509: if (MAN_BLOCK != n->type)
510: return(1);
511:
1.5 kristaps 512: i = 0;
513:
514: if (MAN_ROOT == n->parent->tok) {
1.7 kristaps 515: SCALE_HS_INIT(&su, INDENT);
516: bufcat_su(h, "margin-left", &su);
517: i++;
1.5 kristaps 518: }
519: if (n->next && n->next->child) {
1.7 kristaps 520: SCALE_VS_INIT(&su, 1);
521: bufcat_su(h, "margin-bottom", &su);
522: i++;
1.5 kristaps 523: }
1.4 kristaps 524:
1.7 kristaps 525: PAIR_STYLE_INIT(&tag, h);
526: print_otag(h, TAG_DIV, i ? 1 : 0, &tag);
1.5 kristaps 527: return(1);
528: }
529:
530:
531: /* ARGSUSED */
532: static int
533: man_IP_pre(MAN_ARGS)
534: {
1.7 kristaps 535: struct roffsu su;
1.5 kristaps 536: struct htmlpair tag;
537: const struct man_node *nn;
1.7 kristaps 538: int width;
1.5 kristaps 539:
1.7 kristaps 540: /*
541: * This scattering of 1-BU margins and pads is to make sure that
542: * when text overruns its box, the subsequent text isn't flush
543: * up against it. However, the rest of the right-hand box must
544: * also be adjusted in consideration of this 1-BU space.
545: */
546:
547: if (MAN_BODY == n->type) {
548: SCALE_HS_INIT(&su, INDENT);
549: bufcat_su(h, "margin-left", &su);
550: PAIR_STYLE_INIT(&tag, h);
551: print_otag(h, TAG_DIV, 1, &tag);
1.6 kristaps 552: return(1);
553: }
554:
555: nn = MAN_BLOCK == n->type ?
556: n->head->child : n->parent->head->child;
557:
1.7 kristaps 558: SCALE_HS_INIT(&su, INDENT);
559: width = 0;
1.6 kristaps 560:
1.7 kristaps 561: if (MAN_IP == n->tok && NULL != nn)
1.5 kristaps 562: if (NULL != (nn = nn->next)) {
563: for ( ; nn->next; nn = nn->next)
564: /* Do nothing. */ ;
1.7 kristaps 565: width = a2width(nn, &su);
1.5 kristaps 566: }
567:
1.7 kristaps 568: if (MAN_TP == n->tok && NULL != nn)
569: width = a2width(nn, &su);
570:
1.5 kristaps 571: if (MAN_BLOCK == n->type) {
1.7 kristaps 572: bufcat_su(h, "margin-left", &su);
1.9 kristaps 573: SCALE_VS_INIT(&su, 1);
574: bufcat_su(h, "margin-top", &su);
1.7 kristaps 575: bufcat_style(h, "clear", "both");
576: PAIR_STYLE_INIT(&tag, h);
1.5 kristaps 577: print_otag(h, TAG_DIV, 1, &tag);
578: return(1);
1.6 kristaps 579: }
580:
1.7 kristaps 581: bufcat_su(h, "min-width", &su);
582: SCALE_INVERT(&su);
583: bufcat_su(h, "margin-left", &su);
584: SCALE_HS_INIT(&su, 1);
585: bufcat_su(h, "margin-right", &su);
586: bufcat_style(h, "clear", "left");
1.6 kristaps 587:
588: if (n->next && n->next->child)
1.7 kristaps 589: bufcat_style(h, "float", "left");
1.6 kristaps 590:
1.7 kristaps 591: PAIR_STYLE_INIT(&tag, h);
1.6 kristaps 592: print_otag(h, TAG_DIV, 1, &tag);
593:
1.7 kristaps 594: /* With a length string, manually omit the last child. */
595:
596: if ( ! width)
1.6 kristaps 597: return(1);
598:
1.7 kristaps 599: if (MAN_IP == n->tok)
600: for (nn = n->child; nn->next; nn = nn->next)
601: print_man_node(m, nn, h);
602: if (MAN_TP == n->tok)
603: for (nn = n->child->next; nn; nn = nn->next)
604: print_man_node(m, nn, h);
1.6 kristaps 605:
606: return(0);
607: }
608:
609:
610: /* ARGSUSED */
611: static int
612: man_HP_pre(MAN_ARGS)
613: {
614: const struct man_node *nn;
615: struct htmlpair tag;
1.7 kristaps 616: struct roffsu su;
1.6 kristaps 617:
618: if (MAN_HEAD == n->type)
619: return(0);
620:
621: nn = MAN_BLOCK == n->type ?
622: n->head->child : n->parent->head->child;
623:
1.7 kristaps 624: SCALE_HS_INIT(&su, INDENT);
1.6 kristaps 625:
626: if (NULL != nn)
1.7 kristaps 627: (void)a2width(nn, &su);
1.6 kristaps 628:
629: if (MAN_BLOCK == n->type) {
1.7 kristaps 630: bufcat_su(h, "margin-left", &su);
1.9 kristaps 631: SCALE_VS_INIT(&su, 1);
632: bufcat_su(h, "margin-top", &su);
1.7 kristaps 633: bufcat_style(h, "clear", "both");
634: PAIR_STYLE_INIT(&tag, h);
1.5 kristaps 635: print_otag(h, TAG_DIV, 1, &tag);
1.6 kristaps 636: return(1);
637: }
1.5 kristaps 638:
1.7 kristaps 639: bufcat_su(h, "margin-left", &su);
640: SCALE_INVERT(&su);
641: bufcat_su(h, "text-indent", &su);
1.5 kristaps 642:
1.7 kristaps 643: PAIR_STYLE_INIT(&tag, h);
1.6 kristaps 644: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 645: return(1);
646: }
1.6 kristaps 647:
1.8 kristaps 648:
649: /* ARGSUSED */
650: static int
651: man_B_pre(MAN_ARGS)
652: {
653: struct htmlpair tag;
654:
655: PAIR_CLASS_INIT(&tag, "bold");
656: print_otag(h, TAG_SPAN, 1, &tag);
657: return(1);
658: }
659:
660:
661: /* ARGSUSED */
662: static int
663: man_I_pre(MAN_ARGS)
664: {
665: struct htmlpair tag;
666:
667: PAIR_CLASS_INIT(&tag, "italic");
668: print_otag(h, TAG_SPAN, 1, &tag);
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