summaryrefslogtreecommitdiff
path: root/src/commonmark.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-03-29 16:29:14 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-03-29 16:29:14 -0700
commite63be8475f241cde1f7001252a3039b5c66c3e0f (patch)
tree2335ec5c87e60e8c846463fc102da100f598e0cc /src/commonmark.c
parent464b21b11b17009b09379e7edd6dac9c6479db98 (diff)
commonmark renderer: special case EMPH(EMPH(x)).
This needs to be rendered `*_x_*` rather than `**x**`.
Diffstat (limited to 'src/commonmark.c')
-rw-r--r--src/commonmark.c13
1 files changed, 11 insertions, 2 deletions
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;