Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions html2text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(
self.split_next_td = False
self.td_count = 0
self.table_start = False
self.table_label_start = False
self.unicode_snob = config.UNICODE_SNOB # covered in cli
self.escape_snob = config.ESCAPE_SNOB # covered in cli
self.links_each_paragraph = config.LINKS_EACH_PARAGRAPH
Expand Down Expand Up @@ -366,18 +367,26 @@ def handle_tag(
self.p()
else:
self.soft_br()
elif self.astack:
elif self.astack and tag == "div" :
pass
elif self.table_label_start and tag == "p" and start:
pass
elif self.table_label_start and tag == "p" and not start:
self.o("</br>")
else:
self.p()

if tag == "br" and start:
if self.astack:
self.space = True
elif self.blockquote > 0:
self.o(" \n> ")
if start:
if self.blockquote > 0:
self.o(" \n> ")
elif self.table_label_start:
pass
else:
self.o(" \n")
else:
self.o(" \n")
if self.table_label_start:
self.o("</br>")

if tag == "hr" and start:
self.p()
Expand Down Expand Up @@ -683,10 +692,12 @@ def link_url(self: HTML2Text, link: str, title: str = "") -> None:
if tag == "table":
if start:
self.table_start = True
self.table_label_start = True
if self.pad_tables:
self.o("<" + config.TABLE_MARKER_FOR_PAD + ">")
self.o(" \n")
else:
self.table_label_start = False
if self.pad_tables:
# add break in case the table is empty or its 1 row table
self.soft_br()
Expand Down