kramdown
kramdown copied to clipboard
Escaping doesn't play well with smart quotes
irb(main):001:0> require 'kramdown'
=> true
irb(main):002:0> Kramdown::Document.new('"[foo]"', entity_output: 'numeric').to_html
=> "<p>“[foo]”</p>\n"
However, when I try to escape the brackets because I want to make sure Kramdown doesn't believe[foo]
is a link tag, then I get the opening double quote gets replaced by a curly closing double quote:
irb(main):003:0> Kramdown::Document.new('"\[foo\]"', entity_output: 'numeric').to_html
=> "<p>”[foo]”</p>\n"
This problem only occurs at the start of a paragraph, not when there is some text before the quote. I have looked at the code but there is no easy solution to this problem as far as I can see.
I have tried some things to get this to work while not introducing another problem but I didn't find a solution. So to work around this problem make sure there is something at the start of the line before the quote.
Pull requests are welcome!