]> git.cameronkatri.com Git - mandoc.git/blob - tbl_html.c
cda22b0cba4477b8516c54ef830cd795bda6149a
[mandoc.git] / tbl_html.c
1 /* $Id: tbl_html.c,v 1.3 2011/01/05 13:00:11 kristaps Exp $ */
2 /*
3 * Copyright (c) 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 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20
21 #include <assert.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25
26 #include "mandoc.h"
27 #include "out.h"
28 #include "html.h"
29
30 void
31 print_tbl(struct html *h, const struct tbl_span *sp)
32 {
33 const struct tbl_head *hp;
34 const struct tbl_dat *dp;
35 struct tag *tt;
36 struct htmlpair tag;
37
38 switch (sp->pos) {
39 case (TBL_SPAN_HORIZ):
40 /* FALLTHROUGH */
41 case (TBL_SPAN_DHORIZ):
42 return;
43 default:
44 break;
45 }
46
47 /* Inhibit printing of spaces: we do padding ourselves. */
48
49 h->flags |= HTML_NONOSPACE;
50 h->flags |= HTML_NOSPACE;
51
52 PAIR_CLASS_INIT(&tag, "tbl");
53
54 print_otag(h, TAG_TABLE, 1, &tag);
55 print_otag(h, TAG_TR, 0, NULL);
56
57 dp = sp->first;
58 for (hp = sp->head; hp; hp = hp->next) {
59 switch (hp->pos) {
60 case (TBL_HEAD_VERT):
61 /* FALLTHROUGH */
62 case (TBL_HEAD_DVERT):
63 continue;
64 case (TBL_HEAD_DATA):
65 break;
66 }
67 tt = print_otag(h, TAG_TD, 0, NULL);
68 if (dp) {
69 if (dp->string)
70 print_text(h, dp->string);
71 dp = dp->next;
72 }
73 print_tagq(h, tt);
74 }
75 h->flags &= ~HTML_NONOSPACE;
76 }