matthewwithanm/python-markdownify

Colspan in first row not handled when table heading is missing

Closed this issue · 2 comments

Colspan is properly handled when there is a table header or one is inferred. But if there is not a table header and there is a colspan in the first row of the table, the empty header (and "---" separator row) ignore the colspan attribute.

This is handled properly:

<table>
<tr><th>Col1</th><th>Col2</th></tr>
<tr><td colspan=2>Data</td></tr>
<tr>...</tr>
</table>

This is not:

<table>
<tr><td colspan=2>Data</td></tr>
<tr>...</tr>
</table>

To fix, the convert_tr() function should be updated. The lines in the elif at the end of the function that say "len(cells)" should instead say "full_colspan" like they do in the if statement.

@sbrown61 - thanks for identifying the problem and narrowing down to a root cause!

Are you interested in creating a pull request with the fix? If not, I can do it.

Fixed by #203. Thanks @sbrown61!