gettalong / kramdown

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.
http://kramdown.gettalong.org
Other
1.72k stars 275 forks source link

Escaping doesn't play well with smart quotes #375

Open gpakosz opened 8 years ago

gpakosz commented 8 years ago
irb(main):001:0> require 'kramdown'
=> true
irb(main):002:0> Kramdown::Document.new('"[foo]"', entity_output: 'numeric').to_html
=> "<p>&#8220;[foo]&#8221;</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>&#8221;[foo]&#8221;</p>\n"
gettalong commented 7 years ago

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!