diff --git a/html2text/__init__.py b/html2text/__init__.py index 9054388..fdd59bb 100644 --- a/html2text/__init__.py +++ b/html2text/__init__.py @@ -689,7 +689,7 @@ def link_url(self: HTML2Text, link: str, title: str = "") -> None: self.o("" + config.TABLE_MARKER_FOR_PAD + ">") self.o(" \n") if tag in ["td", "th"] and start: - if self.split_next_td: + if self.split_next_td or self.table_start: self.o("| ") self.split_next_td = True diff --git a/test/test_html2text.py b/test/test_html2text.py index f57cb6b..4bebf23 100644 --- a/test/test_html2text.py +++ b/test/test_html2text.py @@ -236,3 +236,12 @@ def _skip_certain_tags(h2t, tag, attrs, start): "some italics too." ) assert ret == "this is a txt and this is a with text and some _italics_ too.\n\n" + + +def test_table_empty_first_cell(): + h = html2text.HTML2Text() + ret = h.handle( + "
b | |
---|---|
c | d |