From e63be8475f241cde1f7001252a3039b5c66c3e0f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 29 Mar 2015 16:29:14 -0700 Subject: commonmark renderer: special case EMPH(EMPH(x)). This needs to be rendered `*_x_*` rather than `**x**`. --- src/commonmark.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/commonmark.c') diff --git a/src/commonmark.c b/src/commonmark.c index 6994ed1..17a89ab 100644 --- a/src/commonmark.c +++ b/src/commonmark.c @@ -254,6 +254,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, const char *info; const char *title; char listmarker[64]; + char *emph_delim; int marker_width; state->in_tight_list_item = @@ -434,10 +435,18 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, break; case CMARK_NODE_EMPH: + // If we have EMPH(EMPH(x)), we need to use *_x_* + // because **x** is STRONG(x): + if (node->parent && node->parent->type == CMARK_NODE_EMPH && + node->next == NULL && node->prev == NULL) { + emph_delim = "_"; + } else { + emph_delim = "*"; + } if (entering) { - lit(state, "*", false); + lit(state, emph_delim, false); } else { - lit(state, "*", false); + lit(state, emph_delim, false); } break; -- cgit v1.2.3