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 274 forks source link

Output is mangled if HTML includes newlines inside a tag #815

Closed fulldecent closed 2 months ago

fulldecent commented 2 months ago

Test case working:

bundle exec ruby -e 'require "kramdown"; puts Kramdown::Document.new("<i></i>").to_html' 
<p><i></i></p>

Test case failing:

bundle exec ruby -e 'require "kramdown"; puts Kramdown::Document.new("<i><\n/i>").to_html'
<p><i>&lt;
/i&gt;</i></p>

Please note that <i></i> is valid HTML, with or without the newline after the < in the closing tag. And Prettier which is a very popular software, running in many projects' workflows by default will generate code like this. (It modifies HTML files for style reasons but keeps them semantically equivalent.)

Originally reported at https://github.com/jekyll/jekyll/issues/9691

gettalong commented 2 months ago

kramdown expects HTML to be formatted in a certain way. Many things that are allowed with HTML5 don't work with kramdown as kramdown is not a full HTML5 parser/processor. So if you use kramdown, you need to provide the input as kramdown expects it.