=================================================================== RCS file: /cvs/mandoc/mdoc_markdown.c,v retrieving revision 1.18 retrieving revision 1.22 diff -u -p -r1.18 -r1.22 --- mandoc/mdoc_markdown.c 2017/05/04 17:48:29 1.18 +++ mandoc/mdoc_markdown.c 2017/05/30 16:31:29 1.22 @@ -1,4 +1,4 @@ -/* $Id: mdoc_markdown.c,v 1.18 2017/05/04 17:48:29 schwarze Exp $ */ +/* $Id: mdoc_markdown.c,v 1.22 2017/05/30 16:31:29 schwarze Exp $ */ /* * Copyright (c) 2017 Ingo Schwarze * @@ -19,7 +19,6 @@ #include #include #include -#include #include #include "mandoc_aux.h" @@ -223,10 +222,8 @@ static const struct md_act __md_acts[MDOC_MAX - MDOC_D { md_cond_body, md_pre_En, md_post_En, NULL, NULL }, /* En */ { NULL, NULL, NULL, NULL, NULL }, /* Dx */ { NULL, NULL, md_post_pc, NULL, NULL }, /* %Q */ - { NULL, md_pre_Pp, NULL, NULL, NULL }, /* sp */ { NULL, md_pre_Lk, md_post_pc, NULL, NULL }, /* %U */ { NULL, NULL, NULL, NULL, NULL }, /* Ta */ - { NULL, NULL, NULL, NULL, NULL }, /* ll */ }; static const struct md_act *const md_acts = __md_acts - MDOC_Dd; @@ -323,10 +320,14 @@ md_node(struct roff_node *n) } else if (n->tok < ROFF_MAX) { switch (n->tok) { case ROFF_br: - md_pre_br(n); + process_children = md_pre_br(n); break; + case ROFF_sp: + process_children = md_pre_Pp(n); + break; default: - abort(); + process_children = 0; + break; } } else { assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); @@ -1305,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. */ @@ -1329,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; }