Annotation of mandoc/man_html.c, Revision 1.11
1.11 ! kristaps 1: /* $Id: man_html.c,v 1.10 2009/10/13 10:57:25 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 tm tm;
285: struct htmlpair tag[2];
286: struct tag *t, *tt;
287: char b[BUFSIZ];
288:
289: (void)localtime_r(&m->date, &tm);
290:
291: if (0 == strftime(b, BUFSIZ - 1, "%B %e, %Y", &tm))
292: err(EXIT_FAILURE, "strftime");
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.4 kristaps 297: t = print_otag(h, TAG_TABLE, 2, tag);
298: tt = print_otag(h, TAG_TR, 0, NULL);
299:
1.7 kristaps 300: bufinit(h);
301: bufcat_style(h, "width", "50%");
302: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 303: print_otag(h, TAG_TD, 1, tag);
304: print_text(h, b);
305: print_stagq(h, tt);
306:
1.7 kristaps 307: bufinit(h);
308: bufcat_style(h, "width", "50%");
309: bufcat_style(h, "text-align", "right");
310: PAIR_STYLE_INIT(&tag[0], h);
1.4 kristaps 311: print_otag(h, TAG_TD, 1, tag);
312: if (m->source)
313: print_text(h, m->source);
314: print_tagq(h, t);
315: }
316:
317:
318:
319: /* ARGSUSED */
320: static int
321: man_br_pre(MAN_ARGS)
322: {
1.7 kristaps 323: struct roffsu su;
324: struct htmlpair tag;
1.4 kristaps 325:
1.7 kristaps 326: SCALE_VS_INIT(&su, 1);
327:
1.11 ! kristaps 328: if (MAN_sp == n->tok && n->child)
! 329: a2roffsu(n->child->string, &su, SCALE_VS);
! 330: else if (MAN_br == n->tok)
1.7 kristaps 331: su.scale = 0;
1.4 kristaps 332:
1.7 kristaps 333: bufcat_su(h, "height", &su);
334: PAIR_STYLE_INIT(&tag, h);
1.4 kristaps 335: print_otag(h, TAG_DIV, 1, &tag);
1.7 kristaps 336: return(0);
1.4 kristaps 337: }
338:
339:
340: /* ARGSUSED */
341: static int
342: man_SH_pre(MAN_ARGS)
343: {
1.7 kristaps 344: struct htmlpair tag[2];
345: struct roffsu su;
1.4 kristaps 346:
347: if (MAN_BODY == n->type) {
1.7 kristaps 348: SCALE_HS_INIT(&su, INDENT);
349: bufcat_su(h, "margin-left", &su);
350: PAIR_CLASS_INIT(&tag[0], "sec-body");
351: PAIR_STYLE_INIT(&tag[1], h);
1.4 kristaps 352: print_otag(h, TAG_DIV, 2, tag);
353: return(1);
354: } else if (MAN_BLOCK == n->type) {
1.7 kristaps 355: PAIR_CLASS_INIT(&tag[0], "sec-block");
1.4 kristaps 356: if (n->prev && MAN_SH == n->prev->tok)
357: if (NULL == n->prev->body->child) {
358: print_otag(h, TAG_DIV, 1, tag);
359: return(1);
360: }
361:
1.7 kristaps 362: SCALE_VS_INIT(&su, 1);
363: bufcat_su(h, "margin-top", &su);
1.4 kristaps 364: if (NULL == n->next)
1.7 kristaps 365: bufcat_su(h, "margin-bottom", &su);
366: PAIR_STYLE_INIT(&tag[1], h);
1.4 kristaps 367: print_otag(h, TAG_DIV, 2, tag);
368: return(1);
369: }
370:
1.7 kristaps 371: PAIR_CLASS_INIT(&tag[0], "sec-head");
1.4 kristaps 372: print_otag(h, TAG_DIV, 1, tag);
373: return(1);
374: }
375:
376:
377: /* ARGSUSED */
378: static int
1.8 kristaps 379: man_alt_pre(MAN_ARGS)
380: {
381: const struct man_node *nn;
382: struct tag *t;
383: int i;
384: struct htmlpair tagi, tagb, *tagp;
385:
386: PAIR_CLASS_INIT(&tagi, "italic");
387: PAIR_CLASS_INIT(&tagb, "bold");
388:
389: for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
390: switch (n->tok) {
391: case (MAN_BI):
392: tagp = i % 2 ? &tagi : &tagb;
393: break;
394: case (MAN_IB):
395: tagp = i % 2 ? &tagb : &tagi;
396: break;
397: case (MAN_RI):
398: tagp = i % 2 ? &tagi : NULL;
399: break;
400: case (MAN_IR):
401: tagp = i % 2 ? NULL : &tagi;
402: break;
403: case (MAN_BR):
404: tagp = i % 2 ? NULL : &tagb;
405: break;
406: case (MAN_RB):
407: tagp = i % 2 ? &tagb : NULL;
408: break;
409: default:
410: abort();
411: /* NOTREACHED */
412: }
413:
414: if (i)
415: h->flags |= HTML_NOSPACE;
416:
417: if (tagp) {
418: t = print_otag(h, TAG_SPAN, 1, tagp);
419: print_man_node(m, nn, h);
420: print_tagq(h, t);
421: } else
422: print_man_node(m, nn, h);
423: }
424:
425: return(0);
426: }
427:
428:
429: /* ARGSUSED */
430: static int
431: man_SB_pre(MAN_ARGS)
432: {
433: struct htmlpair tag;
434:
435: PAIR_CLASS_INIT(&tag, "small bold");
436: print_otag(h, TAG_SPAN, 1, &tag);
437: return(1);
438: }
439:
440:
441: /* ARGSUSED */
442: static int
443: man_SM_pre(MAN_ARGS)
444: {
445: struct htmlpair tag;
446:
447: PAIR_CLASS_INIT(&tag, "small");
448: print_otag(h, TAG_SPAN, 1, &tag);
449: return(1);
450: }
451:
452:
453: /* ARGSUSED */
454: static int
1.4 kristaps 455: man_SS_pre(MAN_ARGS)
456: {
457: struct htmlpair tag[3];
1.7 kristaps 458: struct roffsu su;
1.4 kristaps 459:
1.7 kristaps 460: SCALE_VS_INIT(&su, 1);
1.4 kristaps 461:
462: if (MAN_BODY == n->type) {
1.7 kristaps 463: PAIR_CLASS_INIT(&tag[0], "ssec-body");
1.4 kristaps 464: if (n->parent->next && n->child) {
1.7 kristaps 465: bufcat_su(h, "margin-bottom", &su);
466: PAIR_STYLE_INIT(&tag[1], h);
467: print_otag(h, TAG_DIV, 2, tag);
468: return(1);
1.4 kristaps 469: }
470:
1.7 kristaps 471: print_otag(h, TAG_DIV, 1, tag);
1.4 kristaps 472: return(1);
473: } else if (MAN_BLOCK == n->type) {
1.7 kristaps 474: PAIR_CLASS_INIT(&tag[0], "ssec-block");
1.4 kristaps 475: if (n->prev && MAN_SS == n->prev->tok)
476: if (n->prev->body->child) {
1.7 kristaps 477: bufcat_su(h, "margin-top", &su);
478: PAIR_STYLE_INIT(&tag[1], h);
479: print_otag(h, TAG_DIV, 2, tag);
480: return(1);
1.4 kristaps 481: }
482:
1.7 kristaps 483: print_otag(h, TAG_DIV, 1, tag);
1.4 kristaps 484: return(1);
485: }
486:
1.7 kristaps 487: SCALE_HS_INIT(&su, INDENT - HALFINDENT);
488: bufcat_su(h, "margin-left", &su);
489: PAIR_CLASS_INIT(&tag[0], "ssec-head");
490: PAIR_STYLE_INIT(&tag[1], h);
1.4 kristaps 491: print_otag(h, TAG_DIV, 2, tag);
492: return(1);
493: }
494:
495:
496: /* ARGSUSED */
497: static int
498: man_PP_pre(MAN_ARGS)
499: {
1.5 kristaps 500: struct htmlpair tag;
1.7 kristaps 501: struct roffsu su;
1.5 kristaps 502: int i;
1.4 kristaps 503:
504: if (MAN_BLOCK != n->type)
505: return(1);
506:
1.5 kristaps 507: i = 0;
508:
509: if (MAN_ROOT == n->parent->tok) {
1.7 kristaps 510: SCALE_HS_INIT(&su, INDENT);
511: bufcat_su(h, "margin-left", &su);
512: i++;
1.5 kristaps 513: }
514: if (n->next && n->next->child) {
1.7 kristaps 515: SCALE_VS_INIT(&su, 1);
516: bufcat_su(h, "margin-bottom", &su);
517: i++;
1.5 kristaps 518: }
1.4 kristaps 519:
1.7 kristaps 520: PAIR_STYLE_INIT(&tag, h);
521: print_otag(h, TAG_DIV, i ? 1 : 0, &tag);
1.5 kristaps 522: return(1);
523: }
524:
525:
526: /* ARGSUSED */
527: static int
528: man_IP_pre(MAN_ARGS)
529: {
1.7 kristaps 530: struct roffsu su;
1.5 kristaps 531: struct htmlpair tag;
532: const struct man_node *nn;
1.7 kristaps 533: int width;
1.5 kristaps 534:
1.7 kristaps 535: /*
536: * This scattering of 1-BU margins and pads is to make sure that
537: * when text overruns its box, the subsequent text isn't flush
538: * up against it. However, the rest of the right-hand box must
539: * also be adjusted in consideration of this 1-BU space.
540: */
541:
542: if (MAN_BODY == n->type) {
543: SCALE_HS_INIT(&su, INDENT);
544: bufcat_su(h, "margin-left", &su);
545: PAIR_STYLE_INIT(&tag, h);
546: print_otag(h, TAG_DIV, 1, &tag);
1.6 kristaps 547: return(1);
548: }
549:
550: nn = MAN_BLOCK == n->type ?
551: n->head->child : n->parent->head->child;
552:
1.7 kristaps 553: SCALE_HS_INIT(&su, INDENT);
554: width = 0;
1.6 kristaps 555:
1.7 kristaps 556: if (MAN_IP == n->tok && NULL != nn)
1.5 kristaps 557: if (NULL != (nn = nn->next)) {
558: for ( ; nn->next; nn = nn->next)
559: /* Do nothing. */ ;
1.7 kristaps 560: width = a2width(nn, &su);
1.5 kristaps 561: }
562:
1.7 kristaps 563: if (MAN_TP == n->tok && NULL != nn)
564: width = a2width(nn, &su);
565:
1.5 kristaps 566: if (MAN_BLOCK == n->type) {
1.7 kristaps 567: bufcat_su(h, "margin-left", &su);
1.9 kristaps 568: SCALE_VS_INIT(&su, 1);
569: bufcat_su(h, "margin-top", &su);
1.7 kristaps 570: bufcat_style(h, "clear", "both");
571: PAIR_STYLE_INIT(&tag, h);
1.5 kristaps 572: print_otag(h, TAG_DIV, 1, &tag);
573: return(1);
1.6 kristaps 574: }
575:
1.7 kristaps 576: bufcat_su(h, "min-width", &su);
577: SCALE_INVERT(&su);
578: bufcat_su(h, "margin-left", &su);
579: SCALE_HS_INIT(&su, 1);
580: bufcat_su(h, "margin-right", &su);
581: bufcat_style(h, "clear", "left");
1.6 kristaps 582:
583: if (n->next && n->next->child)
1.7 kristaps 584: bufcat_style(h, "float", "left");
1.6 kristaps 585:
1.7 kristaps 586: PAIR_STYLE_INIT(&tag, h);
1.6 kristaps 587: print_otag(h, TAG_DIV, 1, &tag);
588:
1.7 kristaps 589: /* With a length string, manually omit the last child. */
590:
591: if ( ! width)
1.6 kristaps 592: return(1);
593:
1.7 kristaps 594: if (MAN_IP == n->tok)
595: for (nn = n->child; nn->next; nn = nn->next)
596: print_man_node(m, nn, h);
597: if (MAN_TP == n->tok)
598: for (nn = n->child->next; nn; nn = nn->next)
599: print_man_node(m, nn, h);
1.6 kristaps 600:
601: return(0);
602: }
603:
604:
605: /* ARGSUSED */
606: static int
607: man_HP_pre(MAN_ARGS)
608: {
609: const struct man_node *nn;
610: struct htmlpair tag;
1.7 kristaps 611: struct roffsu su;
1.6 kristaps 612:
613: if (MAN_HEAD == n->type)
614: return(0);
615:
616: nn = MAN_BLOCK == n->type ?
617: n->head->child : n->parent->head->child;
618:
1.7 kristaps 619: SCALE_HS_INIT(&su, INDENT);
1.6 kristaps 620:
621: if (NULL != nn)
1.7 kristaps 622: (void)a2width(nn, &su);
1.6 kristaps 623:
624: if (MAN_BLOCK == n->type) {
1.7 kristaps 625: bufcat_su(h, "margin-left", &su);
1.9 kristaps 626: SCALE_VS_INIT(&su, 1);
627: bufcat_su(h, "margin-top", &su);
1.7 kristaps 628: bufcat_style(h, "clear", "both");
629: PAIR_STYLE_INIT(&tag, h);
1.5 kristaps 630: print_otag(h, TAG_DIV, 1, &tag);
1.6 kristaps 631: return(1);
632: }
1.5 kristaps 633:
1.7 kristaps 634: bufcat_su(h, "margin-left", &su);
635: SCALE_INVERT(&su);
636: bufcat_su(h, "text-indent", &su);
1.5 kristaps 637:
1.7 kristaps 638: PAIR_STYLE_INIT(&tag, h);
1.6 kristaps 639: print_otag(h, TAG_DIV, 1, &tag);
1.4 kristaps 640: return(1);
641: }
1.6 kristaps 642:
1.8 kristaps 643:
644: /* ARGSUSED */
645: static int
646: man_B_pre(MAN_ARGS)
647: {
648: struct htmlpair tag;
649:
650: PAIR_CLASS_INIT(&tag, "bold");
651: print_otag(h, TAG_SPAN, 1, &tag);
652: return(1);
653: }
654:
655:
656: /* ARGSUSED */
657: static int
658: man_I_pre(MAN_ARGS)
659: {
660: struct htmlpair tag;
661:
662: PAIR_CLASS_INIT(&tag, "italic");
663: print_otag(h, TAG_SPAN, 1, &tag);
664: return(1);
665: }
666:
667:
668: /* ARGSUSED */
669: static int
670: man_ign_pre(MAN_ARGS)
671: {
672:
673: return(0);
674: }
1.9 kristaps 675:
676:
677: /* ARGSUSED */
678: static int
679: man_RS_pre(MAN_ARGS)
680: {
681: struct htmlpair tag;
682: struct roffsu su;
683:
684: if (MAN_HEAD == n->type)
685: return(0);
686: else if (MAN_BODY == n->type)
687: return(1);
688:
689: SCALE_HS_INIT(&su, INDENT);
690: bufcat_su(h, "margin-left", &su);
691:
692: if (n->head->child) {
693: SCALE_VS_INIT(&su, 1);
694: a2width(n->head->child, &su);
695: bufcat_su(h, "margin-top", &su);
696: }
697:
698: PAIR_STYLE_INIT(&tag, h);
699: print_otag(h, TAG_DIV, 1, &tag);
700: return(1);
701: }
CVSweb