diff --git a/CHANGELOG.md b/CHANGELOG.md index 29f69ae2..37a4e025 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +* Fix emphasis character escape sequence detection while mid-emphasis. + + *jcheatham* + * Convert trailing single quotes to curly quotes. For example, `Road Trippin'` now converts to `Road Trippin’`. diff --git a/ext/redcarpet/markdown.c b/ext/redcarpet/markdown.c index c7b3956f..98d880f8 100644 --- a/ext/redcarpet/markdown.c +++ b/ext/redcarpet/markdown.c @@ -509,14 +509,14 @@ find_emph_char(uint8_t *data, size_t size, uint8_t c) if (i == size) return 0; - if (data[i] == c) - return i; - /* not counting escaped chars */ if (i && data[i - 1] == '\\') { i++; continue; } + if (data[i] == c) + return i; + if (data[i] == '`') { size_t span_nb = 0, bt; size_t tmp_i = 0; @@ -845,7 +845,7 @@ char_quote(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t offse static size_t char_escape(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t offset, size_t size) { - static const char *escape_chars = "\\`*_{}[]()#+-.!:|&<>^~"; + static const char *escape_chars = "\\`*_{}[]()#+-.!:|&<>^~="; struct buf work = { 0, 0, 0, 0 }; if (size > 1) { diff --git a/test/markdown_test.rb b/test/markdown_test.rb index 6dfbbdaa..d59da596 100644 --- a/test/markdown_test.rb +++ b/test/markdown_test.rb @@ -280,6 +280,17 @@ def test_proper_intra_emphasis assert_equal html, render_with({:no_intra_emphasis => true}, markdown) end + def test_emphasis_escaping + markdown = @markdown.render("**foo\\*** _dd\\_dd_") + html_equal "
foo* dd_dd
\n", markdown + end + + def test_char_escaping_when_highlighting + markdown = "==attribute\\===" + output = render_with({highlight: true}, markdown) + html_equal "attribute=
\n", output + end + def test_ordered_lists_with_lax_spacing markdown = "Foo:\n1. Foo\n2. Bar" output = render_with({lax_spacing: true}, markdown) @@ -290,6 +301,6 @@ def test_ordered_lists_with_lax_spacing def test_references_with_tabs_after_colon markdown = @markdown.render("[Link][id]\n[id]:\t\t\thttp://google.es") - html_equal '', markdown + html_equal "\n", markdown end end