diff options
author | 2019-02-28 16:36:10 +0000 | |
---|---|---|
committer | 2019-02-28 16:36:10 +0000 | |
commit | ed8117827b241ebf4328653fe3f8af93b38be388 (patch) | |
tree | d2a520e38fbe263d357b7de81fc980939981e277 /usr.bin/mandoc/man_html.c | |
parent | bump smtpd version (diff) | |
download | wireguard-openbsd-ed8117827b241ebf4328653fe3f8af93b38be388.tar.xz wireguard-openbsd-ed8117827b241ebf4328653fe3f8af93b38be388.zip |
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 'usr.bin/mandoc/man_html.c')
-rw-r--r-- | usr.bin/mandoc/man_html.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c index bfe9ca34319..cfdb29175c6 100644 --- a/usr.bin/mandoc/man_html.c +++ b/usr.bin/mandoc/man_html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_html.c,v 1.123 2019/01/18 14:36:16 schwarze Exp $ */ +/* $OpenBSD: man_html.c,v 1.124 2019/02/28 16:36:10 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -231,7 +231,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)) { @@ -397,7 +415,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, ""); |