summaryrefslogtreecommitdiffstatshomepage
path: root/html.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-10-07 12:35:23 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-10-07 12:35:23 +0000
commita38956d48605c5b82c42f5023ba51e80dc6e3728 (patch)
treecd85a23877953bec89a4d3b46e294d054a4990b9 /html.c
parent532d0bbf2d0b8fc89368559b5ed9db0ad323f032 (diff)
downloadmandoc-a38956d48605c5b82c42f5023ba51e80dc6e3728.tar.gz
mandoc-a38956d48605c5b82c42f5023ba51e80dc6e3728.tar.zst
mandoc-a38956d48605c5b82c42f5023ba51e80dc6e3728.zip
Additions to -Tman -Thtml: all structural components tested & in place.
Fitted both -Thtml with handling of arbitrary vertical and horizontal scaling units (see groff(7)). Undocumented until fitted into -Tascii (next release).
Diffstat (limited to 'html.c')
-rw-r--r--html.c58
1 files changed, 55 insertions, 3 deletions
diff --git a/html.c b/html.c
index d73c87b6..5e02de12 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.57 2009/10/04 09:02:40 kristaps Exp $ */
+/* $Id: html.c,v 1.58 2009/10/07 12:35:23 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -25,6 +25,7 @@
#include <string.h>
#include <unistd.h>
+#include "out.h"
#include "chars.h"
#include "html.h"
@@ -499,6 +500,17 @@ bufinit(struct html *h)
void
+bufcat_style(struct html *h, const char *key, const char *val)
+{
+
+ bufcat(h, key);
+ bufncat(h, ":", 1);
+ bufcat(h, val);
+ bufncat(h, ";", 1);
+}
+
+
+void
bufcat(struct html *h, const char *p)
{
@@ -565,10 +577,10 @@ buffmt_man(struct html *h,
bufncat(h, pp, (size_t)(p - pp));
switch (*(p + 1)) {
case('S'):
- bufcat(h, sec);
+ bufcat(h, sec ? sec : "1");
break;
case('N'):
- buffmt(h, name ? name : "1");
+ buffmt(h, name);
break;
default:
bufncat(h, p, 2);
@@ -579,3 +591,43 @@ buffmt_man(struct html *h,
if (pp)
bufcat(h, pp);
}
+
+
+void
+bufcat_su(struct html *h, const char *p, const struct roffsu *su)
+{
+ int v;
+ char *u;
+
+ v = su->scale;
+
+ 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_MM):
+ if (0 == (v /= 100))
+ v = 1;
+ u = "em";
+ break;
+ case (SCALE_VS):
+ /* FALLTHROUGH */
+ case (SCALE_EM):
+ u = "em";
+ break;
+ default:
+ u = "ex";
+ break;
+ }
+
+ buffmt(h, "%s: %d%s;", p, v, u);
+}