diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-01-29 14:49:44 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-01-29 14:49:44 +0000 |
commit | 739c1eaf9cb6f5ff01a9c080620dfb1542000215 (patch) | |
tree | 82a5c2ecc235ea9b4a58c9d99523f0a5c53a2f4b /mdoc_html.c | |
parent | e14284bb26298ab505a7489586d706f7d5402835 (diff) | |
download | mandoc-739c1eaf9cb6f5ff01a9c080620dfb1542000215.tar.gz mandoc-739c1eaf9cb6f5ff01a9c080620dfb1542000215.tar.zst mandoc-739c1eaf9cb6f5ff01a9c080620dfb1542000215.zip |
When in a <PRE>, don't print out the <BR> before lines that have leading
whitespace.
Diffstat (limited to 'mdoc_html.c')
-rw-r--r-- | mdoc_html.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/mdoc_html.c b/mdoc_html.c index 8b1478de..4d42a5b7 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.148 2011/01/25 16:20:24 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.149 2011/01/29 14:49:44 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -422,8 +422,14 @@ print_mdoc_node(MDOC_ARGS) case (MDOC_TEXT): /* No tables in this mode... */ assert(NULL == h->tblt); + + /* + * Make sure that if we're in a literal mode already + * (i.e., within a <PRE>) don't print the newline. + */ if (' ' == *n->string && MDOC_LINE & n->flags) - print_otag(h, TAG_BR, 0, NULL); + if ( ! (HTML_LITERAL & h->flags)) + print_otag(h, TAG_BR, 0, NULL); print_text(h, n->string); return; case (MDOC_TBL): @@ -1175,7 +1181,7 @@ static int mdoc_bd_pre(MDOC_ARGS) { struct htmlpair tag[2]; - int comp; + int comp, sv; const struct mdoc_node *nn; struct roffsu su; @@ -1214,6 +1220,11 @@ mdoc_bd_pre(MDOC_ARGS) PAIR_CLASS_INIT(&tag[1], "lit display"); print_otag(h, TAG_PRE, 2, tag); + /* This can be recursive: save & set our literal state. */ + + sv = h->flags & HTML_LITERAL; + h->flags |= HTML_LITERAL; + for (nn = n->child; nn; nn = nn->next) { print_mdoc_node(m, nn, h); /* @@ -1250,6 +1261,9 @@ mdoc_bd_pre(MDOC_ARGS) h->flags |= HTML_NOSPACE; } + if (0 == sv) + h->flags &= ~HTML_LITERAL; + return(0); } |