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