summaryrefslogtreecommitdiffstats
path: root/man_html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-02-28 16:36:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-02-28 16:36:13 +0000
commitde0e5309636a7a9c363b09ddd327ce06512201d5 (patch)
treea471c7c54028baca34e94de01fd47018e6c705b7 /man_html.c
parentc2bb42a59886b032702b942900a91f729e9e9480 (diff)
downloadmandoc-de0e5309636a7a9c363b09ddd327ce06512201d5.tar.gz
Format multiple subsequent .IP or multiple subsequent .TP/.TQ
as a single <dl> list rather than opening a new list for each item; feature suggested by Pali dot Rohar at gmail dot com.
Diffstat (limited to 'man_html.c')
-rw-r--r--man_html.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/man_html.c b/man_html.c
index 905c3304..f7dea4e6 100644
--- a/man_html.c
+++ b/man_html.c
@@ -233,7 +233,25 @@ print_man_node(MAN_ARGS)
/* This will automatically close out any font scope. */
t->refcnt--;
- print_stagq(h, t);
+ if (n->type == ROFFT_BLOCK &&
+ (n->tok == MAN_IP || n->tok == MAN_TP || n->tok == MAN_TQ)) {
+ t = h->tag;
+ while (t->tag != TAG_DL)
+ t = t->next;
+ /*
+ * Close the list if no further item of the same type
+ * follows; otherwise, close the item only.
+ */
+ if (n->next == NULL ||
+ (n->tok == MAN_IP && n->next->tok != MAN_IP) ||
+ (n->tok != MAN_IP &&
+ n->next->tok != MAN_TP && n->next->tok != MAN_TQ)) {
+ print_tagq(h, t);
+ t = NULL;
+ }
+ }
+ if (t != NULL)
+ print_stagq(h, t);
if (n->flags & NODE_NOFILL && n->tok != MAN_YS &&
(n->next != NULL && n->next->flags & NODE_LINE)) {
@@ -399,7 +417,15 @@ man_IP_pre(MAN_ARGS)
switch (n->type) {
case ROFFT_BLOCK:
html_close_paragraph(h);
- print_otag(h, TAG_DL, "c", "Bl-tag");
+ /*
+ * Open a new list unless there is an immediately
+ * preceding item of the same type.
+ */
+ if (n->prev == NULL ||
+ (n->tok == MAN_IP && n->prev->tok != MAN_IP) ||
+ (n->tok != MAN_IP &&
+ n->prev->tok != MAN_TP && n->prev->tok != MAN_TQ))
+ print_otag(h, TAG_DL, "c", "Bl-tag");
return 1;
case ROFFT_HEAD:
print_otag(h, TAG_DT, "");