You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interestingly, Beautifulsoup, the HTML parser we use, parses your code as <p>1<br/>2<br/>3<br>4<br/>5</br></p>, enclosing 4 and 5 in the non-existant br-tag-pair. I have no idea to why this happens. This would be a bug to be reported at the BS launchpad: https://bugs.launchpad.net/beautifulsoup/ I'm afraid that we cannot really do anything for you in this case :(
There indeed seems to be some kind of bug in the html.parser parser. I think there is a heuristic that tries to identify the <br>/<br/> convention of the content, because if only one style is used, then it seems to be parsed properly:
It might be best to use its default behavior by default, but implement a Markdownify option that allows a particular parser to be explicitly requested.
Activity
AlexVonB commentedon Dec 14, 2021
Hi isaring,
interestingly, Beautifulsoup, the HTML parser we use, parses your code as
<p>1<br/>2<br/>3<br>4<br/>5</br></p>, enclosing 4 and 5 in the non-existant br-tag-pair. I have no idea to why this happens. This would be a bug to be reported at the BS launchpad: https://bugs.launchpad.net/beautifulsoup/ I'm afraid that we cannot really do anything for you in this case :(Keep us updated if you learn something new!
Best
j77h commentedon Jan 2, 2022
"<p>11111<br>22222<br>33333<br/>44444<br><55555</p>"Did you notice? there's an extra "<" before the fives.
isaring commentedon Jan 2, 2022
Oops, that's just a mistyping of my own!
Unfortunately, it has no effect on the result.
LaundroMat commentedon Oct 12, 2022
@isaring: you can convert your markdown yourself using the html5lib parser and use markdownify.MarkdownConverter to convert your html (see https://replit.com/@mathieud/DependentThinDowngrade#main.py).
@AlexVonB: So it's not a bs4 issue, it's a parser problem. So should the parser at https://github.com/matthewwithanm/python-markdownify/blob/develop/markdownify/__init__.py#L96 be upgraded to
html5libfor the next release of markdownify?chrispy-snps commentedon Jan 14, 2024
There indeed seems to be some kind of bug in the
html.parserparser. I think there is a heuristic that tries to identify the<br>/<br/>convention of the content, because if only one style is used, then it seems to be parsed properly:But if a mix is used, then
html.parserseems to get confused:whereas the other parsers do not:
Beautiful Soup tries to choose the best available HTML parser by default:
It might be best to use its default behavior by default, but implement a Markdownify option that allows a particular parser to be explicitly requested.