handle un-parsable colspan values

fixes #126
This commit is contained in:
AlexVonB
2024-06-23 13:17:20 +02:00
parent c1672aee44
commit 2ec33384de
2 changed files with 16 additions and 4 deletions

View File

@@ -383,13 +383,13 @@ class MarkdownConverter(object):
def convert_td(self, el, text, convert_as_inline):
colspan = 1
if 'colspan' in el.attrs:
if 'colspan' in el.attrs and el['colspan'].isdigit():
colspan = int(el['colspan'])
return ' ' + text.strip().replace("\n", " ") + ' |' * colspan
def convert_th(self, el, text, convert_as_inline):
colspan = 1
if 'colspan' in el.attrs:
if 'colspan' in el.attrs and el['colspan'].isdigit():
colspan = int(el['colspan'])
return ' ' + text.strip().replace("\n", " ") + ' |' * colspan
@@ -406,7 +406,7 @@ class MarkdownConverter(object):
# first row and is headline: print headline underline
full_colspan = 0
for cell in cells:
if "colspan" in cell.attrs:
if 'colspan' in cell.attrs and cell['colspan'].isdigit():
full_colspan += int(cell["colspan"])
else:
full_colspan += 1