From: Ingo Schwarze Date: Tue, 30 May 2017 16:31:29 +0000 (+0000) Subject: fix formatting of intermediate punctuation in .Lk X-Git-Tag: VERSION_1_14_2~167 X-Git-Url: https://git.cameronkatri.com/mandoc.git/commitdiff_plain/b85deb01cef03da6ed5386c5a24881bbba2216b2 fix formatting of intermediate punctuation in .Lk --- diff --git a/mdoc_html.c b/mdoc_html.c index f7aefb37..5cbf68aa 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.288 2017/05/17 17:54:45 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.289 2017/05/30 16:31:29 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze @@ -1309,24 +1309,32 @@ mdoc_pp_pre(MDOC_ARGS) static int mdoc_lk_pre(MDOC_ARGS) { + const struct roff_node *link, *descr, *punct; struct tag *t; - if ((n = n->child) == NULL) + 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 target and link text. */ - t = print_otag(h, TAG_A, "cTh", "Lk", n->string); - if (n->next == NULL || n->next->flags & NODE_DELIMC) - print_text(h, n->string); - for (n = n->next; n != NULL && !(n->flags & NODE_DELIMC); n = n->next) - print_text(h, n->string); + t = print_otag(h, TAG_A, "cTh", "Lk", link->string); + for (descr = link->next; descr != punct; descr = descr->next) { + if (descr->flags & (NODE_DELIMC | NODE_DELIMO)) + h->flags |= HTML_NOSPACE; + print_text(h, descr->string); + } print_tagq(h, t); /* Trailing punctuation. */ - while (n != NULL) { + while (punct != NULL) { h->flags |= HTML_NOSPACE; - print_text(h, n->string); - n = n->next; + print_text(h, punct->string); + punct = punct->next; } return 0; } diff --git a/mdoc_man.c b/mdoc_man.c index 4b792524..f2ccdd0f 100644 --- a/mdoc_man.c +++ b/mdoc_man.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.115 2017/05/08 15:34:54 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.116 2017/05/30 16:31:29 schwarze Exp $ */ /* * Copyright (c) 2011-2017 Ingo Schwarze * @@ -1527,16 +1527,22 @@ post_lb(DECL_ARGS) static int pre_lk(DECL_ARGS) { - const struct roff_node *link, *descr; + const struct roff_node *link, *descr, *punct; int display; 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. */ - if ((descr = link->next) != NULL && !(descr->flags & NODE_DELIMC)) { + if ((descr = link->next) != NULL && descr != punct) { font_push('I'); - while (descr != NULL && !(descr->flags & NODE_DELIMC)) { + while (descr != punct) { print_word(descr->string); descr = descr->next; } @@ -1556,9 +1562,9 @@ pre_lk(DECL_ARGS) font_pop(); /* Trailing punctuation. */ - while (descr != NULL) { - print_word(descr->string); - descr = descr->next; + while (punct != NULL) { + print_word(punct->string); + punct = punct->next; } if (display) print_line(".RE", MMAN_nl); 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 * @@ -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; } diff --git a/mdoc_term.c b/mdoc_term.c index e4c0b92c..382804d5 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.357 2017/05/09 14:10:01 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.358 2017/05/30 16:31:29 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012-2017 Ingo Schwarze @@ -1977,16 +1977,24 @@ termp_li_pre(DECL_ARGS) static int termp_lk_pre(DECL_ARGS) { - const struct roff_node *link, *descr; + const struct roff_node *link, *descr, *punct; int display; 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. */ - if ((descr = link->next) != NULL && !(descr->flags & NODE_DELIMC)) { + if ((descr = link->next) != NULL && descr != punct) { term_fontpush(p, TERMFONT_UNDER); - while (descr != NULL && !(descr->flags & NODE_DELIMC)) { + while (descr != punct) { + if (descr->flags & (NODE_DELIMC | NODE_DELIMO)) + p->flags |= TERMP_NOSPACE; term_word(p, descr->string); descr = descr->next; } @@ -2006,10 +2014,10 @@ termp_lk_pre(DECL_ARGS) term_fontpop(p); /* Trailing punctuation. */ - while (descr != NULL) { + while (punct != NULL) { p->flags |= TERMP_NOSPACE; - term_word(p, descr->string); - descr = descr->next; + term_word(p, punct->string); + punct = punct->next; } if (display) term_newln(p); diff --git a/regress/mdoc/Lk/noarg.in b/regress/mdoc/Lk/noarg.in index a0200ed1..910f641c 100644 --- a/regress/mdoc/Lk/noarg.in +++ b/regress/mdoc/Lk/noarg.in @@ -7,7 +7,7 @@ .Sh DESCRIPTION multiple arguments .Lk http://www.bsd.lv/ the bsd.lv project , -.Lk http://www.gnu.org/software/groff/ GNU troff , +.Lk http://www.gnu.org/software/groff/ GNU troff "," two arguments .Lk http://mdocml.bsd.lv/ mandoc one argument