diff options
-rw-r--r-- | mdoc_html.c | 24 | ||||
-rw-r--r-- | mdoc_macro.c | 8 | ||||
-rw-r--r-- | mdoc_man.c | 16 | ||||
-rw-r--r-- | mdoc_markdown.c | 19 | ||||
-rw-r--r-- | mdoc_term.c | 18 |
5 files changed, 60 insertions, 25 deletions
diff --git a/mdoc_html.c b/mdoc_html.c index 27ca1a49..d8c86936 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.278 2017/03/17 12:10:16 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.279 2017/04/17 12:53:29 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -1346,19 +1346,25 @@ mdoc_sp_pre(MDOC_ARGS) static int mdoc_lk_pre(MDOC_ARGS) { - if (NULL == (n = n->child)) - return 0; - - assert(n->type == ROFFT_TEXT); + struct tag *t; - print_otag(h, TAG_A, "cTh", "Lk", n->string); + if ((n = n->child) == NULL) + return 0; - if (NULL == n->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; n = n->next) + for (n = n->next; n != NULL && !(n->flags & NODE_DELIMC); n = n->next) print_text(h, n->string); + print_tagq(h, t); + /* Trailing punctuation. */ + while (n != NULL) { + h->flags |= HTML_NOSPACE; + print_text(h, n->string); + n = n->next; + } return 0; } diff --git a/mdoc_macro.c b/mdoc_macro.c index 5ab9c412..fd34a7ac 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.217 2017/02/16 09:47:31 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.218 2017/04/17 12:53:29 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -903,8 +903,10 @@ in_line(MACRO_PROT_ARGS) } } - if (scope) + if (scope && tok != MDOC_Lk) { rew_elem(mdoc, tok); + scope = 0; + } /* * If no elements have been collected and we're allowed to have @@ -924,6 +926,8 @@ in_line(MACRO_PROT_ARGS) } if (nl) append_delims(mdoc, line, pos, buf); + if (scope) + rew_elem(mdoc, tok); } static void @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.106 2017/04/14 18:25:04 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.107 2017/04/17 12:53:29 schwarze Exp $ */ /* * Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org> * @@ -1465,12 +1465,13 @@ pre_lk(DECL_ARGS) { const struct roff_node *link, *descr; - if (NULL == (link = n->child)) + if ((link = n->child) == NULL) return 0; - if (NULL != (descr = link->next)) { + /* Link text. */ + if ((descr = link->next) != NULL && !(descr->flags & NODE_DELIMC)) { font_push('I'); - while (NULL != descr) { + while (descr != NULL && !(descr->flags & NODE_DELIMC)) { print_word(descr->string); descr = descr->next; } @@ -1478,9 +1479,16 @@ pre_lk(DECL_ARGS) print_word(":"); } + /* Link target. */ font_push('B'); print_word(link->string); font_pop(); + + /* Trailing punctuation. */ + while (descr != NULL) { + print_word(descr->string); + descr = descr->next; + } return 0; } diff --git a/mdoc_markdown.c b/mdoc_markdown.c index 6f80d70c..0a4fa961 100644 --- a/mdoc_markdown.c +++ b/mdoc_markdown.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_markdown.c,v 1.15 2017/03/11 12:35:45 schwarze Exp $ */ +/* $Id: mdoc_markdown.c,v 1.16 2017/04/17 12:53:29 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; } diff --git a/mdoc_term.c b/mdoc_term.c index 259f9a2e..b936c5a3 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.348 2017/04/14 19:35:22 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.349 2017/04/17 12:53:29 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -1995,12 +1995,13 @@ termp_lk_pre(DECL_ARGS) const struct roff_node *link, *descr; int display; - if (NULL == (link = n->child)) + if ((link = n->child) == NULL) return 0; - if (NULL != (descr = link->next)) { + /* Link text. */ + if ((descr = link->next) != NULL && !(descr->flags & NODE_DELIMC)) { term_fontpush(p, TERMFONT_UNDER); - while (NULL != descr) { + while (descr != NULL && !(descr->flags & NODE_DELIMC)) { term_word(p, descr->string); descr = descr->next; } @@ -2009,19 +2010,24 @@ termp_lk_pre(DECL_ARGS) term_word(p, ":"); } + /* Link target. */ display = term_strlen(p, link->string) >= 26; if (display) { term_newln(p); p->offset += term_len(p, p->defindent + 1); } - term_fontpush(p, TERMFONT_BOLD); term_word(p, link->string); term_fontpop(p); + /* Trailing punctuation. */ + while (descr != NULL) { + p->flags |= TERMP_NOSPACE; + term_word(p, descr->string); + descr = descr->next; + } if (display) term_newln(p); - return 0; } |