matthewwithanm / python-markdownify

Convert HTML to Markdown
MIT License
1.17k stars 140 forks source link

make sure there are blank lines around table/figure captions #114

Closed chrispy-snps closed 8 months ago

chrispy-snps commented 8 months ago

Fixes #113. Table and figure captions are now covered by unit tests.

The updated output is as follows:

from markdownify import markdownify as md
md('TEXT<table><caption>Caption</caption><tr><td>CELL</td></tr></tbody></table>')  # > 'TEXT\n\nCaption\n| CELL |\n\n'
                                                                                                ^^^^^^^^^

md('TEXT<figure><figcaption>Caption</figcaption><span>SPAN</span></figure>')  # > 'TEXT\n\nCaption\n\nSPAN'
#                                                                                      ^^^^^^^^^^^^^^^

md('<figure><span>SPAN</span><figcaption>Caption</figcaption></figure>TEXT')  # > 'SPAN\n\nCaption\n\nTEXT'
#                                                                                      ^^^^^^^^^^^^^^^