aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_markdown.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-05-30 16:31:29 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-05-30 16:31:29 +0000
commitb85deb01cef03da6ed5386c5a24881bbba2216b2 (patch)
treea2f50414c87131ab5b6592957a8e8f665f938e52 /mdoc_markdown.c
parenta20be95dec7797c55257792a32b6b39bdbdfe595 (diff)
downloadmandoc-b85deb01cef03da6ed5386c5a24881bbba2216b2.tar.gz
mandoc-b85deb01cef03da6ed5386c5a24881bbba2216b2.tar.zst
mandoc-b85deb01cef03da6ed5386c5a24881bbba2216b2.zip
fix formatting of intermediate punctuation in .Lk
Diffstat (limited to 'mdoc_markdown.c')
-rw-r--r--mdoc_markdown.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/mdoc_markdown.c b/mdoc_markdown.c
index f2514429..7f5368fb 100644
--- a/mdoc_markdown.c
+++ b/mdoc_markdown.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_markdown.c,v 1.21 2017/05/05 15:17:32 schwarze Exp $ */
+/* $Id: mdoc_markdown.c,v 1.22 2017/05/30 16:31:29 schwarze Exp $ */
/*
* Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -1306,21 +1306,27 @@ md_uri(const char *s)
static int
md_pre_Lk(struct roff_node *n)
{
- const struct roff_node *link, *descr;
+ const struct roff_node *link, *descr, *punct;
if ((link = n->child) == NULL)
return 0;
+ /* Find beginning of trailing punctuation. */
+ punct = n->last;
+ while (punct != link && punct->flags & NODE_DELIMC)
+ punct = punct->prev;
+ punct = punct->next;
+
/* Link text. */
descr = link->next;
- if (descr == NULL || descr->flags & NODE_DELIMC)
+ if (descr == punct)
descr = link; /* no text */
md_rawword("[");
outflags &= ~MD_spc;
do {
md_word(descr->string);
descr = descr->next;
- } while (descr != NULL && !(descr->flags & NODE_DELIMC));
+ } while (descr != punct);
outflags &= ~MD_spc;
/* Link target. */
@@ -1330,9 +1336,9 @@ md_pre_Lk(struct roff_node *n)
md_rawword(")");
/* Trailing punctuation. */
- while (descr != NULL) {
- md_word(descr->string);
- descr = descr->next;
+ while (punct != NULL) {
+ md_word(punct->string);
+ punct = punct->next;
}
return 0;
}