diff --git a/src/html_epub_preprocessor.py b/src/html_epub_preprocessor.py
index f227a9c..ed38dab 100644
--- a/src/html_epub_preprocessor.py
+++ b/src/html_epub_preprocessor.py
@@ -68,7 +68,7 @@ def preprocess_figure():
def preprocess_table(body_tag: BeautifulSoup):
tables = body_tag.find_all("table")
for table in tables:
- tds = table.find_all("td")
+ tds = table.find_all(re.compile("td|th|tr"))
border_sizes = []
for td in tds:
@@ -101,6 +101,9 @@ def preprocess_table(body_tag: BeautifulSoup):
if td.attrs.get('style'):
td.attrs['style'] = td.attrs['style'].replace('border:0;', '')
+ if td.attrs.get('style') == '':
+ del td.attrs['style']
+
if border_sizes:
border_size = sum(border_sizes) / len(border_sizes)
table.attrs['border'] = f'{border_size:.2}'