From b816b91fdd0f469f508ded46a22f46fde0205a71 Mon Sep 17 00:00:00 2001 From: Jonathan Cheatham Date: Tue, 5 Sep 2017 10:16:12 -0700 Subject: [PATCH] Fix backslash escape over-escaping backslash --- ext/redcarpet/markdown.c | 2 +- test/markdown_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/redcarpet/markdown.c b/ext/redcarpet/markdown.c index 95222214..7ed853be 100644 --- a/ext/redcarpet/markdown.c +++ b/ext/redcarpet/markdown.c @@ -848,7 +848,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 4347be9b..828cc94b 100644 --- a/test/markdown_test.rb +++ b/test/markdown_test.rb @@ -45,6 +45,12 @@ def test_that_html_blocks_do_not_require_their_own_end_tag_line assert_equal expected, output end + def test_that_backslashes_escape_properly + output = render("visit \\\\server\\path \\**now**") + expected = "

visit \\\\server\\path *now*

" + assert_equal expected, output + end + # This isn't in the spec but is Markdown.pl behavior. def test_block_quotes_preceded_by_spaces output = render <<-Markdown.strip_heredoc