diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2019-09-03 18:07:58 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2019-09-03 18:07:58 +0000 |
commit | 50c4d6b3ff06d48dfc0622d36b540ca7fb8c80e6 (patch) | |
tree | cf0e66408d6e5e5319ab086551eef21f1f067bb3 /usr.bin/mandoc/html.c | |
parent | 83bd581a487b5f78e8629af7bb6c8ca39262795a (diff) |
Wrap text and phrasing elements in paragraphs unless already
contained in flow containers; never put them directly into sections.
This helps to format paragraphs with the CSS class selector .Pp.
Suggested by bentley@ and also by Colin Watson <cjwatson at debian>
via Michael Stapelberg <stapelberg at debian>,
see https://github.com/Debian/debiman/issues/116
Diffstat (limited to 'usr.bin/mandoc/html.c')
-rw-r--r-- | usr.bin/mandoc/html.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c index ab164e4f827..2cc3e6e552d 100644 --- a/usr.bin/mandoc/html.c +++ b/usr.bin/mandoc/html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: html.c,v 1.130 2019/09/03 12:30:34 schwarze Exp $ */ +/* $OpenBSD: html.c,v 1.131 2019/09/03 18:07:57 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -588,7 +588,15 @@ print_otag(struct html *h, enum htmltag tag, const char *fmt, ...) assert((htmltags[t->tag].flags & HTML_TOPHRASE) == 0); break; } - } + + /* + * Always wrap phrasing elements in a paragraph + * unless already contained in some flow container; + * never put them directly into a section. + */ + + } else if (tflags & HTML_TOPHRASE && h->tag->tag == TAG_SECTION) + print_otag(h, TAG_P, "c", "Pp"); /* Push this tag onto the stack of open scopes. */ @@ -794,6 +802,16 @@ print_gen_comment(struct html *h, struct roff_node *n) void print_text(struct html *h, const char *word) { + /* + * Always wrap text in a paragraph unless already contained in + * some flow container; never put it directly into a section. + */ + + if (h->tag->tag == TAG_SECTION) + print_otag(h, TAG_P, "c", "Pp"); + + /* Output whitespace before this text? */ + if (h->col && (h->flags & HTML_NOSPACE) == 0) { if ( ! (HTML_KEEP & h->flags)) { if (HTML_PREKEEP & h->flags) @@ -803,6 +821,11 @@ print_text(struct html *h, const char *word) print_word(h, " "); } + /* + * Print the text, optionally surrounded by HTML whitespace, + * optionally manually switching fonts before and after. + */ + assert(h->metaf == NULL); print_metaf(h); print_indent(h); |