vmg / redcarpet

The safe Markdown parser, reloaded.
MIT License
4.99k stars 527 forks source link

Smartypants converts --> into en dash if comment contains HTML #608

Open lord opened 7 years ago

lord commented 7 years ago

@mbuttler found a (slightly esoteric) bug in https://github.com/lord/slate/issues/715, and I think Smartypants might be causing the problem? Here's a minimal example:

require "redcarpet"
puts Redcarpet::Render::SmartyPants.render("Oh SmartyPants, you're so crazy...")
# output: Oh SmartyPants, you’re so crazy…
puts Redcarpet::Render::SmartyPants.render("<!-- Oh SmartyPants, you're so crazy... -->")
# output: <!-- Oh SmartyPants, you're so crazy... -->
puts Redcarpet::Render::SmartyPants.render("<!-- <p>Oh SmartyPants, you're so crazy...</p> -->")
# output: <!-- <p>Oh SmartyPants, you&rsquo;re so crazy&hellip;</p> &ndash;>

Even though the last example is just one giant HTML comment, it seems like the HTML tags inside put Smartpants back into converting-mode, which makes the enclosing comment never end? Let me know if I can provide any additional information!

(As an aside, since I'm not sure I've came in here and said it: thanks for the excellent markdown parser, thousands of Slate users have loved and enjoyed the extensive features you support! ❤️ )

lord commented 7 years ago

Oh, and the above code was run with Redcarpet 3.4.0.

robin850 commented 7 years ago

Hi !

Thank you very much for the kind words and detailed report and sorry for the delay ! I will try to look into this very soon ! :-)

lord commented 7 years ago

Yea, no rush! It's not the most impactful bug. :)