aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man_html.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-07-07 13:26:25 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-07-07 13:26:25 +0000
commitac50f42d0c7369c7f5b0af47a29dc79ab5a960df (patch)
tree50845f731d29a8ed575edeb2347240150f8039fa /man_html.c
parent0bc53e09f54bd26bf722b58c831b6d8fd182eb66 (diff)
downloadmandoc-ac50f42d0c7369c7f5b0af47a29dc79ab5a960df.tar.gz
mandoc-ac50f42d0c7369c7f5b0af47a29dc79ab5a960df.tar.zst
mandoc-ac50f42d0c7369c7f5b0af47a29dc79ab5a960df.zip
Clean up how -man -T[x]html handles TP, IP, and HP (dd lists and
indented paragraph macros, respectively). This cleans up code and also cleans up the output quite a lot.
Diffstat (limited to 'man_html.c')
-rw-r--r--man_html.c94
1 files changed, 15 insertions, 79 deletions
diff --git a/man_html.c b/man_html.c
index fe79390c..2c79a8f0 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.76 2011/07/03 22:57:32 kristaps Exp $ */
+/* $Id: man_html.c,v 1.77 2011/07/07 13:26:25 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -403,7 +403,6 @@ man_root_post(MAN_ARGS)
}
-
/* ARGSUSED */
static int
man_br_pre(MAN_ARGS)
@@ -431,7 +430,6 @@ man_br_pre(MAN_ARGS)
return(0);
}
-
/* ARGSUSED */
static int
man_SH_pre(MAN_ARGS)
@@ -450,7 +448,6 @@ man_SH_pre(MAN_ARGS)
return(1);
}
-
/* ARGSUSED */
static int
man_alt_pre(MAN_ARGS)
@@ -501,7 +498,6 @@ man_alt_pre(MAN_ARGS)
return(0);
}
-
/* ARGSUSED */
static int
man_SM_pre(MAN_ARGS)
@@ -513,7 +509,6 @@ man_SM_pre(MAN_ARGS)
return(1);
}
-
/* ARGSUSED */
static int
man_SS_pre(MAN_ARGS)
@@ -532,7 +527,6 @@ man_SS_pre(MAN_ARGS)
return(1);
}
-
/* ARGSUSED */
static int
man_PP_pre(MAN_ARGS)
@@ -546,62 +540,21 @@ man_PP_pre(MAN_ARGS)
return(1);
}
-
/* ARGSUSED */
static int
man_IP_pre(MAN_ARGS)
{
- struct roffsu su;
- struct htmlpair tag;
const struct man_node *nn;
- /*
- * This scattering of 1-BU margins and pads is to make sure that
- * when text overruns its box, the subsequent text isn't flush
- * up against it. However, the rest of the right-hand box must
- * also be adjusted in consideration of this 1-BU space.
- */
-
if (MAN_BODY == n->type) {
- print_otag(h, TAG_TD, 0, NULL);
+ print_otag(h, TAG_DD, 0, NULL);
return(1);
- }
-
- nn = MAN_BLOCK == n->type ?
- n->head->child : n->parent->head->child;
-
- SCALE_HS_INIT(&su, INDENT);
-
- /* Width is the second token. */
-
- if (MAN_IP == n->tok && NULL != nn)
- if (NULL != (nn = nn->next))
- a2width(nn, &su);
-
- /* Width is the first token. */
-
- if (MAN_TP == n->tok && NULL != nn) {
- /* Skip past non-text children. */
- while (nn && MAN_TEXT != nn->type)
- nn = nn->next;
- if (nn)
- a2width(nn, &su);
- }
-
- if (MAN_BLOCK == n->type) {
- print_bvspace(h, n);
- print_otag(h, TAG_TABLE, 0, NULL);
- bufinit(h);
- bufcat_su(h, "width", &su);
- PAIR_STYLE_INIT(&tag, h);
- print_otag(h, TAG_COL, 1, &tag);
- print_otag(h, TAG_COL, 0, NULL);
- print_otag(h, TAG_TBODY, 0, NULL);
- print_otag(h, TAG_TR, 0, NULL);
+ } else if (MAN_HEAD != n->type) {
+ print_otag(h, TAG_DL, 0, NULL);
return(1);
- }
+ }
- print_otag(h, TAG_TD, 0, NULL);
+ print_otag(h, TAG_DT, 0, NULL);
/* For IP, only print the first header element. */
@@ -618,7 +571,6 @@ man_IP_pre(MAN_ARGS)
return(0);
}
-
/* ARGSUSED */
static int
man_HP_pre(MAN_ARGS)
@@ -627,38 +579,27 @@ man_HP_pre(MAN_ARGS)
struct roffsu su;
const struct man_node *np;
- bufinit(h);
+ if (MAN_HEAD == n->type)
+ return(0);
+ else if (MAN_BLOCK != n->type)
+ return(1);
- np = MAN_BLOCK == n->type ?
- n->head->child :
- n->parent->head->child;
+ np = n->head->child;
if (NULL == np || ! a2width(np, &su))
SCALE_HS_INIT(&su, INDENT);
- if (MAN_HEAD == n->type) {
- print_otag(h, TAG_TD, 0, NULL);
- return(0);
- } else if (MAN_BLOCK == n->type) {
- print_bvspace(h, n);
- print_otag(h, TAG_TABLE, 0, NULL);
- bufcat_su(h, "width", &su);
- PAIR_STYLE_INIT(&tag, h);
- print_otag(h, TAG_COL, 1, &tag);
- print_otag(h, TAG_COL, 0, NULL);
- print_otag(h, TAG_TBODY, 0, NULL);
- print_otag(h, TAG_TR, 0, NULL);
- return(1);
- }
+ bufinit(h);
+ print_bvspace(h, n);
+ bufcat_su(h, "margin-left", &su);
su.scale = -su.scale;
bufcat_su(h, "text-indent", &su);
PAIR_STYLE_INIT(&tag, h);
- print_otag(h, TAG_TD, 1, &tag);
+ print_otag(h, TAG_P, 1, &tag);
return(1);
}
-
/* ARGSUSED */
static int
man_B_pre(MAN_ARGS)
@@ -668,7 +609,6 @@ man_B_pre(MAN_ARGS)
return(1);
}
-
/* ARGSUSED */
static int
man_I_pre(MAN_ARGS)
@@ -678,7 +618,6 @@ man_I_pre(MAN_ARGS)
return(1);
}
-
/* ARGSUSED */
static int
man_literal_pre(MAN_ARGS)
@@ -693,7 +632,6 @@ man_literal_pre(MAN_ARGS)
return(0);
}
-
/* ARGSUSED */
static int
man_in_pre(MAN_ARGS)
@@ -703,7 +641,6 @@ man_in_pre(MAN_ARGS)
return(0);
}
-
/* ARGSUSED */
static int
man_ign_pre(MAN_ARGS)
@@ -712,7 +649,6 @@ man_ign_pre(MAN_ARGS)
return(0);
}
-
/* ARGSUSED */
static int
man_RS_pre(MAN_ARGS)