summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc_markdown.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2017-04-17 12:52:00 +0000
committerschwarze <schwarze@openbsd.org>2017-04-17 12:52:00 +0000
commit96aebfb38c1b18db069e4ba1e2145623b1e36e53 (patch)
tree70a6e2f5c3e1fb20d5aac42fde0ffb25105efde6 /usr.bin/mandoc/mdoc_markdown.c
parentChange COMPILER_VERSION tests which limited additional warnings to gcc4 (diff)
downloadwireguard-openbsd-96aebfb38c1b18db069e4ba1e2145623b1e36e53.tar.xz
wireguard-openbsd-96aebfb38c1b18db069e4ba1e2145623b1e36e53.zip
Fix handling of trailing punctuation in .Lk.
This macro is unusual in so far as trailing punction needs to remain inside the scope because it must be inside, not after the display of long URIs in terminal output mode. Improves formatting of fw_update(1), help(1), less(1), sendbug(1), acx(4), inet6(4), ipsec(4), oce(4), isakmpd.conf(5), afterboot(8), release(8), traceroute(8).
Diffstat (limited to 'usr.bin/mandoc/mdoc_markdown.c')
-rw-r--r--usr.bin/mandoc/mdoc_markdown.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.bin/mandoc/mdoc_markdown.c b/usr.bin/mandoc/mdoc_markdown.c
index 74b261befad..f30186e1fb9 100644
--- a/usr.bin/mandoc/mdoc_markdown.c
+++ b/usr.bin/mandoc/mdoc_markdown.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_markdown.c,v 1.15 2017/03/11 12:35:40 schwarze Exp $ */
+/* $OpenBSD: mdoc_markdown.c,v 1.16 2017/04/17 12:52:00 schwarze Exp $ */
/*
* Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -1304,18 +1304,29 @@ md_pre_Lk(struct roff_node *n)
if ((link = n->child) == NULL)
return 0;
- descr = link->next == NULL ? link : link->next;
+ /* Link text. */
+ descr = link->next;
+ if (descr == NULL || descr->flags & NODE_DELIMC)
+ descr = link; /* no text */
md_rawword("[");
outflags &= ~MD_spc;
do {
md_word(descr->string);
- descr = link->next == NULL ? NULL : descr->next;
- } while (descr != NULL);
+ descr = descr->next;
+ } while (descr != NULL && !(descr->flags & NODE_DELIMC));
outflags &= ~MD_spc;
+
+ /* Link target. */
md_rawword("](");
md_uri(link->string);
outflags &= ~MD_spc;
md_rawword(")");
+
+ /* Trailing punctuation. */
+ while (descr != NULL) {
+ md_word(descr->string);
+ descr = descr->next;
+ }
return 0;
}