diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-12-28 17:10:46 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-12-28 17:10:46 -0800 |
commit | cbc1bb638e14b010371e657c6861e83d99d230e1 (patch) | |
tree | c868460e219bc52586055d13517b776cb1ed8840 /src | |
parent | 982152041830412fd6c61ba6e4746000709db92c (diff) |
Commonmark renderer: ensure that literal characters get escaped
when they're at the beginning of a block, e.g.
> \- foo
Diffstat (limited to 'src')
-rw-r--r-- | src/commonmark.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/commonmark.c b/src/commonmark.c index 61ef016..69bd2b1 100644 --- a/src/commonmark.c +++ b/src/commonmark.c @@ -31,7 +31,7 @@ static inline void outc(cmark_renderer *renderer, cmark_escaping escape, (c == '*' || c == '_' || c == '[' || c == ']' || c == '#' || c == '<' || c == '>' || c == '\\' || c == '`' || c == '!' || (c == '&' && isalpha(nextc)) || (c == '!' && nextc == '[') || - (renderer->begin_line && (c == '-' || c == '+' || c == '=')) || + (renderer->begin_content && (c == '-' || c == '+' || c == '=')) || ((c == '.' || c == ')') && isdigit(renderer->buffer->ptr[renderer->buffer->size - 1])))) || (escape == URL && (c == '`' || c == '<' || c == '>' || isspace(c) || @@ -176,6 +176,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, case CMARK_NODE_BLOCK_QUOTE: if (entering) { LIT("> "); + renderer->begin_content = true; cmark_strbuf_puts(renderer->prefix, "> "); } else { cmark_strbuf_truncate(renderer->prefix, renderer->prefix->size - 2); @@ -214,9 +215,11 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, if (entering) { if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) { LIT("* "); + renderer->begin_content = true; cmark_strbuf_puts(renderer->prefix, " "); } else { LIT(listmarker); + renderer->begin_content = true; for (i = marker_width; i--;) { cmark_strbuf_putc(renderer->prefix, ' '); } @@ -234,6 +237,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, LIT("#"); } LIT(" "); + renderer->begin_content = true; renderer->no_wrap = true; } else { renderer->no_wrap = false; |