From: Kristaps Dzonsons Date: Mon, 27 Sep 2010 11:21:39 +0000 (+0000) Subject: Suppress whitespace following Pp, Lp, sp, and the other newline-emitting X-Git-Tag: VERSION_1_10_6~2 X-Git-Url: https://git.cameronkatri.com/mandoc.git/commitdiff_plain/1bb462fa770edbf91f52a725195dec2abb9da0c0 Suppress whitespace following Pp, Lp, sp, and the other newline-emitting macros within an unfilled or literal `Bd'. --- diff --git a/TODO b/TODO index 71cb89ac..0e053606 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ ************************************************************************ * Official mandoc TODO. -* $Id: TODO,v 1.54 2010/09/27 10:47:48 kristaps Exp $ +* $Id: TODO,v 1.55 2010/09/27 11:21:39 kristaps Exp $ ************************************************************************ ************************************************************************ @@ -134,9 +134,6 @@ In -unfilled, tabs are 5 spaces, just like in -filled and -ragged. See the CCDF_* display in OpenBSD ccdconfig(8). -- In .Bd -unfilled, .Pp should produce one blank line, not two; - see the ccd.conf display in OpenBSD ccdconfig(8). - - .Nx 1.0a should be "NetBSD 1.0A", not "NetBSD 1.0a", see OpenBSD ccdconfig(8). diff --git a/mdoc.7 b/mdoc.7 index b66829cb..e116e748 100644 --- a/mdoc.7 +++ b/mdoc.7 @@ -1,4 +1,4 @@ -.\" $Id: mdoc.7,v 1.160 2010/09/27 06:56:44 kristaps Exp $ +.\" $Id: mdoc.7,v 1.161 2010/09/27 11:21:39 kristaps Exp $ .\" .\" Copyright (c) 2009, 2010 Kristaps Dzonsons .\" Copyright (c) 2010 Ingo Schwarze @@ -1076,7 +1076,8 @@ implementations render it poorly. Left- and right-justify the block. .It Fl literal Do not justify the block at all. -Preserve white space as it appears in the input. +Preserve white space and newlines as they appear in the input, including +if it follows a macro. .It Fl ragged Only left-justify the block. .It Fl unfilled diff --git a/mdoc_html.c b/mdoc_html.c index 08f34133..a621936a 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -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.108 2010/09/27 11:21:39 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -1316,6 +1316,26 @@ 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_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"); diff --git a/mdoc_term.c b/mdoc_term.c index 5df90460..d57eacd9 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.189 2010/09/26 10:00:42 kristaps Exp $ */ +/* $Id: mdoc_term.c,v 1.190 2010/09/27 11:21:39 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -1578,6 +1578,26 @@ termp_bd_pre(DECL_ARGS) for (nn = n->child; nn; nn = nn->next) { print_mdoc_node(p, pair, m, nn); + /* + * 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_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; term_flushln(p);