aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tbl_html.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-01-06 12:31:39 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-01-06 12:31:39 +0000
commite36c59db580e24ff0e23306efe767c18d74b4af6 (patch)
treecea3031bc23ef350700a70da9846ce442bac5bf3 /tbl_html.c
parent40384b46245ed46f132d087f7569bf00117bbf9a (diff)
downloadmandoc-e36c59db580e24ff0e23306efe767c18d74b4af6.tar.gz
mandoc-e36c59db580e24ff0e23306efe767c18d74b4af6.tar.zst
mandoc-e36c59db580e24ff0e23306efe767c18d74b4af6.zip
Restructured tbl_html() function so that we always clean up our columns.
Diffstat (limited to 'tbl_html.c')
-rw-r--r--tbl_html.c83
1 files changed, 43 insertions, 40 deletions
diff --git a/tbl_html.c b/tbl_html.c
index 47db6f60..7594dfc9 100644
--- a/tbl_html.c
+++ b/tbl_html.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_html.c,v 1.4 2011/01/06 11:55:39 kristaps Exp $ */
+/* $Id: tbl_html.c,v 1.5 2011/01/06 12:31:39 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -56,15 +56,6 @@ print_tbl(struct html *h, const struct tbl_span *sp)
struct roffsu su;
struct roffcol *col;
- switch (sp->pos) {
- case (TBL_SPAN_HORIZ):
- /* FALLTHROUGH */
- case (TBL_SPAN_DHORIZ):
- return;
- default:
- break;
- }
-
/* Inhibit printing of spaces: we do padding ourselves. */
h->flags |= HTML_NONOSPACE;
@@ -78,39 +69,51 @@ print_tbl(struct html *h, const struct tbl_span *sp)
tblcalc(&h->tbl, sp);
}
- PAIR_CLASS_INIT(&tag, "tbl");
-
- print_otag(h, TAG_TABLE, 1, &tag);
- print_otag(h, TAG_TR, 0, NULL);
-
- dp = sp->first;
- for (hp = sp->head; hp; hp = hp->next) {
- switch (hp->pos) {
- case (TBL_HEAD_VERT):
- /* FALLTHROUGH */
- case (TBL_HEAD_DVERT):
- continue;
- case (TBL_HEAD_DATA):
- break;
- }
-
- /*
- * For the time being, use the simplest possible table
- * styling: setting the widths of data columns.
- */
-
- col = &h->tbl.cols[hp->ident];
- SCALE_HS_INIT(&su, col->width);
- bufcat_su(h, "width", &su);
- PAIR_STYLE_INIT(&tag, h);
- tt = print_otag(h, TAG_TD, 1, &tag);
- if (dp) {
- if (dp->string)
+ switch (sp->pos) {
+ case (TBL_SPAN_HORIZ):
+ /* FALLTHROUGH */
+ case (TBL_SPAN_DHORIZ):
+ break;
+ default:
+ PAIR_CLASS_INIT(&tag, "tbl");
+ print_otag(h, TAG_TABLE, 1, &tag);
+ print_otag(h, TAG_TR, 0, NULL);
+
+ /* Iterate over template headers. */
+
+ dp = sp->first;
+ for (hp = sp->head; hp; hp = hp->next) {
+ switch (hp->pos) {
+ case (TBL_HEAD_VERT):
+ /* FALLTHROUGH */
+ case (TBL_HEAD_DVERT):
+ continue;
+ case (TBL_HEAD_DATA):
+ break;
+ }
+
+ /*
+ * For the time being, use the simplest possible
+ * table styling: setting the widths of data
+ * columns.
+ */
+
+ col = &h->tbl.cols[hp->ident];
+ SCALE_HS_INIT(&su, col->width);
+ bufcat_su(h, "width", &su);
+ PAIR_STYLE_INIT(&tag, h);
+ tt = print_otag(h, TAG_TD, 1, &tag);
+
+ if (dp && dp->string)
print_text(h, dp->string);
- dp = dp->next;
+ if (dp)
+ dp = dp->next;
+
+ print_tagq(h, tt);
}
- print_tagq(h, tt);
+ break;
}
+
h->flags &= ~HTML_NONOSPACE;
/* Close out column specifiers on the last span. */