aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/html.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-05-17 10:48:06 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-05-17 10:48:06 +0000
commit889ec81be9fc9523bf29226bdb259eb9e5d5154f (patch)
tree3302a7f48bfaa4614eab0ba885c64179d4aada67 /html.c
parenta96cac2f523bff3d1c811444fa013f8d9eca81c9 (diff)
downloadmandoc-889ec81be9fc9523bf29226bdb259eb9e5d5154f.tar.gz
mandoc-889ec81be9fc9523bf29226bdb259eb9e5d5154f.tar.zst
mandoc-889ec81be9fc9523bf29226bdb259eb9e5d5154f.zip
Clean up -T[x]html by using a table instead of a switch statement for
the roff units. Also remove a comment about CSS and number types (they all accept decimal numbers).
Diffstat (limited to 'html.c')
-rw-r--r--html.c59
1 files changed, 17 insertions, 42 deletions
diff --git a/html.c b/html.c
index d6ac1a45..553ff6fd 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.139 2011/05/15 15:47:46 kristaps Exp $ */
+/* $Id: html.c,v 1.140 2011/05/17 10:48:06 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -94,6 +94,19 @@ static const char *const htmlattrs[ATTR_MAX] = {
"colspan", /* ATTR_COLSPAN */
};
+static const char *const roffscales[SCALE_MAX] = {
+ "cm", /* SCALE_CM */
+ "in", /* SCALE_IN */
+ "pc", /* SCALE_PC */
+ "pt", /* SCALE_PT */
+ "em", /* SCALE_EM */
+ "em", /* SCALE_MM */
+ "ex", /* SCALE_EN */
+ "ex", /* SCALE_BU */
+ "em", /* SCALE_VS */
+ "ex", /* SCALE_FS */
+};
+
static void print_num(struct html *, const char *, size_t);
static void print_spec(struct html *, const char *, size_t);
static void print_res(struct html *, const char *, size_t);
@@ -729,50 +742,12 @@ void
bufcat_su(struct html *h, const char *p, const struct roffsu *su)
{
double v;
- const char *u;
v = su->scale;
+ if (SCALE_MM == su->unit && 0.0 == (v /= 100.0))
+ v = 1.0;
- switch (su->unit) {
- case (SCALE_CM):
- u = "cm";
- break;
- case (SCALE_IN):
- u = "in";
- break;
- case (SCALE_PC):
- u = "pc";
- break;
- case (SCALE_PT):
- u = "pt";
- break;
- case (SCALE_EM):
- u = "em";
- break;
- case (SCALE_MM):
- if (0 == (v /= 100))
- v = 1;
- u = "em";
- break;
- case (SCALE_EN):
- u = "ex";
- break;
- case (SCALE_BU):
- u = "ex";
- break;
- case (SCALE_VS):
- u = "em";
- break;
- default:
- u = "ex";
- break;
- }
-
- /*
- * XXX: the CSS spec isn't clear as to which types accept
- * integer or real numbers, so we just make them all decimals.
- */
- buffmt(h, "%s: %.2f%s;", p, v, u);
+ buffmt(h, "%s: %.2f%s;", p, v, roffscales[su->unit]);
}