summaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_html.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-07-02 10:42:46 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-07-02 10:42:46 +0000
commit52a3740500a22481ff2d10cdf92c312254ef4c1b (patch)
treee09a75695dd91e8d7d6cf7148890fe78b33ccf95 /mdoc_html.c
parent07951ccc1e374899d68a29ee1909b6128fdb13e2 (diff)
downloadmandoc-52a3740500a22481ff2d10cdf92c312254ef4c1b.tar.gz
mandoc-52a3740500a22481ff2d10cdf92c312254ef4c1b.tar.zst
mandoc-52a3740500a22481ff2d10cdf92c312254ef4c1b.zip
Implemented -Thtml bits for handling `Nm' blocks.
Diffstat (limited to 'mdoc_html.c')
-rw-r--r--mdoc_html.c71
1 files changed, 62 insertions, 9 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index 1277a765..b3839870 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.90 2010/07/01 22:56:17 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.91 2010/07/02 10:42:46 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -736,17 +736,70 @@ mdoc_op_post(MDOC_ARGS)
static int
mdoc_nm_pre(MDOC_ARGS)
{
- struct htmlpair tag;
+ struct htmlpair tag;
+ struct roffsu su;
+ const char *cp;
- if (NULL == n->child && NULL == m->name)
- return(1);
+ /*
+ * Accomodate for `Nm' being both an element (which may have
+ * NULL children AND no m->name) and a block.
+ */
- synopsis_pre(h, n);
+ cp = NULL;
+
+ if (MDOC_ELEM == n->type) {
+ if (NULL == n->child && NULL == m->name)
+ return(1);
+ synopsis_pre(h, n);
+ PAIR_CLASS_INIT(&tag, "name");
+ print_otag(h, TAG_SPAN, 1, &tag);
+ if (NULL == n->child)
+ print_text(h, m->name);
+ } else if (MDOC_BLOCK == n->type) {
+ synopsis_pre(h, n);
+
+ bufcat_style(h, "clear", "both");
+ if (n->head->child || m->name) {
+ if (n->head->child && MDOC_TEXT ==
+ n->head->child->type)
+ cp = n->head->child->string;
+ if (NULL == cp || '\0' == *cp)
+ cp = m->name;
+
+ SCALE_HS_INIT(&su, (double)strlen(cp));
+ bufcat_su(h, "padding-left", &su);
+ }
+
+ PAIR_STYLE_INIT(&tag, h);
+ print_otag(h, TAG_DIV, 1, &tag);
+ } else if (MDOC_HEAD == n->type) {
+ if (NULL == n->child && NULL == m->name)
+ return(1);
+
+ if (n->child && MDOC_TEXT == n->child->type)
+ cp = n->child->string;
+ if (NULL == cp || '\0' == *cp)
+ cp = m->name;
+
+ SCALE_HS_INIT(&su, (double)strlen(cp));
+
+ bufcat_style(h, "float", "left");
+ bufcat_su(h, "min-width", &su);
+ SCALE_INVERT(&su);
+ bufcat_su(h, "margin-left", &su);
+
+ PAIR_STYLE_INIT(&tag, h);
+ print_otag(h, TAG_DIV, 1, &tag);
+
+ if (NULL == n->child)
+ print_text(h, m->name);
+ } else if (MDOC_BODY == n->type) {
+ SCALE_HS_INIT(&su, 2);
+ bufcat_su(h, "margin-left", &su);
+ PAIR_STYLE_INIT(&tag, h);
+ print_otag(h, TAG_DIV, 1, &tag);
+ }
- PAIR_CLASS_INIT(&tag, "name");
- print_otag(h, TAG_SPAN, 1, &tag);
- if (NULL == n->child)
- print_text(h, m->name);
return(1);
}