-/* $OpenBSD: mdoc_html.c,v 1.153 2017/03/17 12:06:02 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.154 2017/04/17 12:52:00 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwarze@openbsd.org>
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;
}
-/* $OpenBSD: mdoc_macro.c,v 1.174 2017/02/16 09:47:10 schwarze Exp $ */
+/* $OpenBSD: mdoc_macro.c,v 1.175 2017/04/17 12:52:00 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
}
}
- 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
}
if (nl)
append_delims(mdoc, line, pos, buf);
+ if (scope)
+ rew_elem(mdoc, tok);
}
static void
-/* $OpenBSD: mdoc_man.c,v 1.104 2017/04/14 18:24:15 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.105 2017/04/17 12:52:00 schwarze Exp $ */
/*
* Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
*
{
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;
}
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;
}
-/* $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>
*
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;
}
-/* $OpenBSD: mdoc_term.c,v 1.247 2017/04/14 19:34:54 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.248 2017/04/17 12:52:00 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
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;
}
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;
}