Support conversion of header rows in tables without th tag (#83)

* Fixed support for header row conversion for tables without th tag
This commit is contained in:
huuya
2024-03-27 05:32:36 +09:00
committed by GitHub
parent 804a3f8f07
commit e4df41225d
2 changed files with 30 additions and 3 deletions

View File

@@ -377,7 +377,11 @@ class MarkdownConverter(object):
def convert_tr(self, el, text, convert_as_inline):
cells = el.find_all(['td', 'th'])
is_headrow = all([cell.name == 'th' for cell in cells])
is_headrow = (
all([cell.name == 'th' for cell in cells])
or (not el.previous_sibling and not el.parent.name == 'tbody')
or (not el.previous_sibling and el.parent.name == 'tbody' and len(el.parent.parent.find_all(['thead'])) < 1)
)
overline = ''
underline = ''
if is_headrow and not el.previous_sibling: