summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-10-04 15:24:54 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-10-04 15:24:54 +0000
commit3b2ccd70393214cf6fb85913738a991c84ff369a (patch)
treec1bf420c4bb9fe993a009eaf82f6b11a46a24925
parentab43bcf702ae29d5e464c13bacd02d17663c64c8 (diff)
downloadmandoc-3b2ccd70393214cf6fb85913738a991c84ff369a.tar.gz
mandoc-3b2ccd70393214cf6fb85913738a991c84ff369a.tar.zst
mandoc-3b2ccd70393214cf6fb85913738a991c84ff369a.zip
Structural components of -man -Thtml in place (note that HP is the same as IP, as HTML doesn't "do" this construction without fixed page widths).
-rw-r--r--man_html.c99
-rw-r--r--man_term.c3
-rw-r--r--mdoc_html.c6
3 files changed, 84 insertions, 24 deletions
diff --git a/man_html.c b/man_html.c
index a7beae5a..41d84fea 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.5 2009/10/04 10:24:31 kristaps Exp $ */
+/* $Id: man_html.c,v 1.6 2009/10/04 15:24:54 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -27,7 +27,9 @@
#include "html.h"
#include "man.h"
-#define INDENT 7
+/* TODO: preserve ident widths. */
+
+#define INDENT 5
#define HALFINDENT 3
#define MAN_ARGS const struct man_meta *m, \
@@ -47,6 +49,7 @@ static void print_man_node(MAN_ARGS);
static int a2width(const struct man_node *);
static int man_br_pre(MAN_ARGS);
+static int man_HP_pre(MAN_ARGS);
static int man_IP_pre(MAN_ARGS);
static int man_PP_pre(MAN_ARGS);
static void man_root_post(MAN_ARGS);
@@ -64,12 +67,12 @@ static const struct htmlman mans[MAN_MAX] = {
{ NULL, NULL }, /* TH */
{ man_SH_pre, NULL }, /* SH */
{ man_SS_pre, NULL }, /* SS */
- { NULL, NULL }, /* TP */
+ { man_IP_pre, NULL }, /* TP */
{ man_PP_pre, NULL }, /* LP */
{ man_PP_pre, NULL }, /* PP */
{ man_PP_pre, NULL }, /* P */
{ man_IP_pre, NULL }, /* IP */
- { NULL, NULL }, /* HP */
+ { man_HP_pre, NULL }, /* HP */
{ NULL, NULL }, /* SM */
{ NULL, NULL }, /* SB */
{ NULL, NULL }, /* BI */
@@ -209,8 +212,8 @@ a2width(const struct man_node *n)
int i, len;
const char *p;
- assert(MAN_TEXT == n->type);
- assert(n->string);
+ if (MAN_TEXT != n->type)
+ return(-1);
p = n->string;
@@ -468,8 +471,19 @@ man_IP_pre(MAN_ARGS)
int len, ival;
const struct man_node *nn;
- len = 1;
- if (NULL != (nn = n->parent->head->child))
+ if (MAN_BODY == n->type) {
+ print_otag(h, TAG_DIV, 0, NULL);
+ return(1);
+ }
+
+ nn = MAN_BLOCK == n->type ?
+ n->head->child : n->parent->head->child;
+ len = INDENT;
+ ival = -1;
+
+ /* Calculate the indentation length. */
+
+ if (NULL != nn)
if (NULL != (nn = nn->next)) {
for ( ; nn->next; nn = nn->next)
/* Do nothing. */ ;
@@ -483,24 +497,67 @@ man_IP_pre(MAN_ARGS)
tag.val = h->buf;
print_otag(h, TAG_DIV, 1, &tag);
return(1);
- } else if (MAN_HEAD == n->type) {
- buffmt(h, "margin-left: -%dem; min-width: %dem;",
- len, len - 1);
- bufcat(h, "clear: left;");
- bufcat(h, "padding-right: 1em;");
- if (n->next && n->next->child)
- bufcat(h, "float: left;");
+ }
+
+ /* If there's an indent string, print it out. */
+
+ buffmt(h, "margin-left: -%dem; min-width: %dem;",
+ len, len - 1);
+ bufcat(h, "clear: left; padding-right: 1em;");
+
+ if (n->next && n->next->child)
+ bufcat(h, "float: left;");
+
+ tag.key = ATTR_STYLE;
+ tag.val = h->buf;
+ print_otag(h, TAG_DIV, 1, &tag);
+
+ if (ival < 0)
+ return(1);
+
+ /* With a length string, omit the last child. */
+
+ for (nn = n->child; nn->next; nn = nn->next)
+ print_man_node(m, nn, h);
+
+ return(0);
+}
+
+
+/* ARGSUSED */
+static int
+man_HP_pre(MAN_ARGS)
+{
+ int ival, len;
+ const struct man_node *nn;
+ struct htmlpair tag;
+
+ if (MAN_HEAD == n->type)
+ return(0);
+
+ nn = MAN_BLOCK == n->type ?
+ n->head->child : n->parent->head->child;
+
+ len = INDENT;
+
+ if (NULL != nn)
+ if ((ival = a2width(nn)) >= 0)
+ len = ival;
+
+ if (MAN_BLOCK == n->type) {
+ buffmt(h, "clear: both; margin-left: %dem;", len);
tag.key = ATTR_STYLE;
tag.val = h->buf;
print_otag(h, TAG_DIV, 1, &tag);
+ return(1);
+ }
- /* Don't print the length value. */
+ buffmt(h, "text-indent: -%dem;", len);
- for (nn = n->child; nn->next; nn = nn->next)
- print_man_node(m, nn, h);
- return(0);
- }
+ tag.key = ATTR_STYLE;
+ tag.val = h->buf;
+ print_otag(h, TAG_DIV, 1, &tag);
- print_otag(h, TAG_DIV, 0, &tag);
return(1);
}
+
diff --git a/man_term.c b/man_term.c
index 8093b7ab..661c7e4c 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.32 2009/10/03 19:57:53 kristaps Exp $ */
+/* $Id: man_term.c,v 1.33 2009/10/04 15:24:54 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -160,7 +160,6 @@ man_run(struct termp *p, const struct man *m)
static void
-
fmt_block_vspace(struct termp *p, const struct man_node *n)
{
term_newln(p);
diff --git a/mdoc_html.c b/mdoc_html.c
index 9d383916..49414b57 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.21 2009/10/04 09:00:40 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.22 2009/10/04 15:24:54 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -580,6 +580,8 @@ mdoc_sh_pre(MDOC_ARGS)
(void)strlcat(link, "_", BUFSIZ);
}
+ /* FIXME: make sure no duplicates! */
+
tag[0].key = ATTR_CLASS;
tag[0].val = "sec-head";
tag[1].key = ATTR_ID;
@@ -636,6 +638,8 @@ mdoc_ss_pre(MDOC_ARGS)
buffmt(h, "margin-left: -%dem;", INDENT - HALFINDENT);
+ /* FIXME: make sure no duplicates! */
+
tag[0].key = ATTR_CLASS;
tag[0].val = "ssec-head";
tag[1].key = ATTR_STYLE;