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

Entities are not parsed when directly under root node #749

Closed numinit closed 2 years ago

numinit commented 2 years ago
Kramdown::Parser::Html.parse('&')
# => [<kd:root options={:encoding=>#<Encoding:UTF-8>, :location=>1, :options=>{}, :abbrev_defs=>{}, :abbrev_attr=>{}} children=[<kd:text value="&amp;\n" options={:location=>1}>]>, []]

Kramdown::Parser::Html.parse('<p>&amp;</p>')
# => [<kd:root options={:encoding=>#<Encoding:UTF-8>, :location=>1, :options=>{}, :abbrev_defs=>{}, :abbrev_attr=>{}} children=[<kd:p children=[<kd:text value="">, <kd:entity value=#<struct Kramdown::Utils::Entities::Entity code_point=38, name="amp"> options={:original=>"&amp;"}>]>]>, []]
gettalong commented 2 years ago

Thanks - this is fixed for the upcoming release!

numinit commented 2 years ago

Awesome! I can get rid of my terrible hack of manually enclosing everything in a <p>!