From d456b6468fe0b165050b448b1fc7be4191ee6581 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Thu, 7 Jul 2011 13:26:25 +0000 Subject: 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. --- man_html.c | 92 ++++++++++---------------------------------------------------- 1 file changed, 14 insertions(+), 78 deletions(-) diff --git a/man_html.c b/man_html.c index 1f03eae8..defeb492 100644 --- a/man_html.c +++ b/man_html.c @@ -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) -- cgit