matthewwithanm/python-markdownify

Blank lines are missing around figure and table captions

chrispy-snps opened this issue · 0 comments

For <table> elements, a newline is missing between the <caption> element and the first | (pipe) character in the table structure:

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

For <figure> elements, blank lines are missing around <figcaption> elements at the top or bottom of the figure:

from markdownify import markdownify as md
md('TEXT<figure><figcaption>Caption</figcaption><span>SPAN</span></figure>')  # > 'TEXTCaptionSPAN'
#                                                                                     ^^^^^^^^^
md('<figure><span>SPAN</span><figcaption>Caption</figcaption></figure>TEXT')  # > 'SPANCaptionTEXT'
#                                                                                     ^^^^^^^^^

These tests use inline text content and no newlines to test the worst-case output scenario (no extra newlines in input propagating to output).