matthewwithanm/python-markdownify

Add a blank line between table captions and table content

Closed this issue · 0 comments

Currently, table <caption> elements are placed directly adjacent to the table content:

import markdownify

html = """\
<table>
 <caption>Table caption</caption>
 <thead><tr><th>Header 1</th><th>Header 2</th></tr></thead>
 <tbody><tr><td>Body 1</td><td>Body 2</td></tr></tbody>
</table>
d
"""

print(markdownify.markdownify(html))
# Table caption
# | Header 1 | Header 2 |
# | --- | --- |
# | Body 1 | Body 2 |

However, Pandoc requires a blank line before the table content to avoid ambiguity:

$ pandoc --wrap=none test.md --to html
<p>Table caption | Header 1 | Header 2 | | — | — | | Body 1 | Body 2 |</p>

To resolve this, <caption> elements could include an additional newline after them.