redcarpet icon indicating copy to clipboard operation
redcarpet copied to clipboard

Not every ASCII punctuation character can be escaped

Open TheDeepestSpace opened this issue 5 years ago • 0 comments

Hello. Thank you for a great gem.

When escaping semantically-insignificant characters like ", $, %, ', ,, /, ;, ?, @ using a backslash, that backslash character is kept in the output:

markdown = Redcarpet::Markdown.new Redcarpet::Render::HTML
puts markdown.render '\!\"\#\$\%\&\\\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\`\{\|\}\~'
<p>!\&quot;#\$\%&amp;\&#39;()*+\,-.\/:\;&lt;=&gt;\?\@[\]^_`{|}~</p>

While this kind of makes sense, CommonMark specification suggests that all punctuation characters should be allowed to be escaped: https://spec.commonmark.org/0.29/#backslash-escapes. So the output of the above code should be

<p>!&quot;#$%&amp;'()*+,-./:;&lt;=&gt;?@[\]^_`{|}~</p>

For now simply leaving the aforementioned characters out of the escaping process works.

TheDeepestSpace avatar Oct 21 '20 15:10 TheDeepestSpace