python-markdownify icon indicating copy to clipboard operation
python-markdownify copied to clipboard

Headers are not handled well when combined with details/summary tags

Open alexei-osipov opened this issue 1 year ago • 1 comments

h3 results in badly formatted output when combined with details/summary tags

This code

from bs4 import BeautifulSoup
from markdownify import MarkdownConverter

sample = """
<details><summary>Some question text</summary><div><h3>Answer</h3> Answer text</div></details>
"""

soup = BeautifulSoup(sample, 'html.parser')
result = MarkdownConverter().convert_soup(soup)
print(result)

Actual result (on 0.12.1):

Some question text### Answer

 Answer text

Expected result:

Some question text

### Answer

Answer text

alexei-osipov avatar May 24 '24 13:05 alexei-osipov

PR #120 should help here, it fixes various cases of block tags not being properly separated from adjacent content, including headers.

jsm28 avatar May 24 '24 20:05 jsm28

This was fixed with #120 , thank you for reporting!

AlexVonB avatar Nov 24 '24 20:11 AlexVonB