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

handling `br` inside formatting tags #780

Closed directionless closed 1 year ago

directionless commented 1 year ago

I'm trying to convert html to markdown. Playing with Kramdown, it's pretty cool. But, I found a bit of a corner case. If there are br tags inside formatting, it comes out a bit funny. Honestly I'm not really sure what correct should be, but:

[78] pry(main)> Kramdown::Document.new('<h1>foo<br>bar</h1>', :input => 'html').to_kramdown
=> "# foo  \nbar\n\n"
gettalong commented 1 year ago

Thanks for the report! From a cursory look at it I think this is a bug in the HTML to AST conversion scheme.

gettalong commented 1 year ago

After having a more in-depth look at this, I have adapted the kramdown converter to correctly handle such cases.