python-markdownify
python-markdownify copied to clipboard
heading and list item not converted well
Example HTML:
<ol>
<h2>
<li>Test heading</li>
</h2>
<h2>
<li>Test heading 2</li>
</h2>
</ol>
The expected rendering result should be like below:
However, with the converted markdown, headings just disappear:
##
- Test heading
##
- Test heading 2
The provided example is not valid HTML. Per the HTML5 specifications <ol>'s may only contain <li>'s or other <ol> or <ul>'s .
https://www.w3.org/TR/2012/WD-html-markup-20120329/ol.html
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol
Using correct HTML structure, along with heading_style=ATX will give you the desired output
<ol>
<li>
<h2>Test heading</h2>
</li>
<li>
<h2>Test heading 2</h2>
</li>
</ol>
1. ## Test heading
2. ## Test heading 2