=================================================================== RCS file: /cvs/mandoc/mdoc_html.c,v retrieving revision 1.107 retrieving revision 1.111 diff -u -p -r1.107 -r1.111 --- mandoc/mdoc_html.c 2010/09/26 10:32:14 1.107 +++ mandoc/mdoc_html.c 2010/10/10 09:59:48 1.111 @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.107 2010/09/26 10:32:14 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.111 2010/10/10 09:59:48 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -91,6 +91,7 @@ static int mdoc_ex_pre(MDOC_ARGS); static void mdoc_fo_post(MDOC_ARGS); static int mdoc_fo_pre(MDOC_ARGS); static int mdoc_ic_pre(MDOC_ARGS); +static int mdoc_igndelim_pre(MDOC_ARGS); static int mdoc_in_pre(MDOC_ARGS); static int mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list, int, struct roffsu *, struct roffsu *); @@ -109,7 +110,6 @@ static int mdoc_nm_pre(MDOC_ARGS); static int mdoc_ns_pre(MDOC_ARGS); static int mdoc_pa_pre(MDOC_ARGS); static void mdoc_pf_post(MDOC_ARGS); -static int mdoc_pf_pre(MDOC_ARGS); static void mdoc_quote_post(MDOC_ARGS); static int mdoc_quote_pre(MDOC_ARGS); static int mdoc_rs_pre(MDOC_ARGS); @@ -199,12 +199,12 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {NULL, NULL}, /* Eo */ {mdoc_xx_pre, NULL}, /* Fx */ {mdoc_ms_pre, NULL}, /* Ms */ - {NULL, NULL}, /* No */ + {mdoc_igndelim_pre, NULL}, /* No */ {mdoc_ns_pre, NULL}, /* Ns */ {mdoc_xx_pre, NULL}, /* Nx */ {mdoc_xx_pre, NULL}, /* Ox */ {NULL, NULL}, /* Pc */ - {mdoc_pf_pre, mdoc_pf_post}, /* Pf */ + {mdoc_igndelim_pre, mdoc_pf_post}, /* Pf */ {mdoc_quote_pre, mdoc_quote_post}, /* Po */ {mdoc_quote_pre, mdoc_quote_post}, /* Pq */ {NULL, NULL}, /* Qc */ @@ -1316,6 +1316,28 @@ mdoc_bd_pre(MDOC_ARGS) for (nn = n->child; nn; nn = nn->next) { print_mdoc_node(m, nn, h); + /* + * If the printed node flushes its own line, then we + * needn't do it here as well. This is hacky, but the + * notion of selective eoln whitespace is pretty dumb + * anyway, so don't sweat it. + */ + switch (nn->tok) { + case (MDOC_Sm): + /* FALLTHROUGH */ + case (MDOC_br): + /* FALLTHROUGH */ + case (MDOC_sp): + /* FALLTHROUGH */ + case (MDOC_Bl): + /* FALLTHROUGH */ + case (MDOC_Lp): + /* FALLTHROUGH */ + case (MDOC_Pp): + continue; + default: + break; + } if (nn->next && nn->next->line == nn->line) continue; print_text(h, "\n"); @@ -1583,7 +1605,16 @@ mdoc_sm_pre(MDOC_ARGS) assert(n->child && MDOC_TEXT == n->child->type); if (0 == strcmp("on", n->child->string)) { - /* FIXME: no p->col to check... */ + /* + * FIXME: no p->col to check. Thus, if we have + * .Bd -literal + * .Sm off + * 1 2 + * .Sm on + * 3 + * .Ed + * the "3" is preceded by a space. + */ h->flags &= ~HTML_NOSPACE; h->flags &= ~HTML_NONOSPACE; } else @@ -1891,7 +1922,7 @@ mdoc_ms_pre(MDOC_ARGS) /* ARGSUSED */ static int -mdoc_pf_pre(MDOC_ARGS) +mdoc_igndelim_pre(MDOC_ARGS) { h->flags |= HTML_IGNDELIM; @@ -1904,7 +1935,6 @@ static void mdoc_pf_post(MDOC_ARGS) { - h->flags &= ~HTML_IGNDELIM; h->flags |= HTML_NOSPACE; } @@ -2137,6 +2167,7 @@ mdoc_quote_pre(MDOC_ARGS) /* FALLTHROUGH */ case (MDOC_Op): print_text(h, "\\(lB"); + h->flags |= HTML_NOSPACE; PAIR_CLASS_INIT(&tag, "opt"); print_otag(h, TAG_SPAN, 1, &tag); break;