thephpleague / html-to-markdown

Convert HTML to Markdown with PHP
MIT License
1.77k stars 205 forks source link

Line break inside formatting tag kills markdown #134

Closed miamibc closed 6 years ago

miamibc commented 7 years ago

First of all, thank you for very flexible library!

I found small problem. Converting HTML <p><b>This<br>tag</b> will break the markup</p> gives markdown that can't be displayed correctly

**This 
tag** will break the markup

My pull request allows to avoid such problem inside of some formatting tags (b, i, h1, h2...). Added necessary tests.

colinodell commented 7 years ago

I ran your sample output through Babelmark2 and it looks like most parsers handle that Markdown just fine: https://johnmacfarlane.net/babelmark2/?normalize=1&text=**This%0Atag**+will+break+the+markup

However, note that most of them do not render the line break. According to the CommonMark spec, we can fix this by adding two spaces after **This. Most Markdown implementations will then render this line break: https://johnmacfarlane.net/babelmark2/?normalize=1&text=**This++%0Atag**+will+break+the+markup