guard table lines with pipes, resolves the empty header problem
This commit is contained in:
@@ -245,12 +245,11 @@ class MarkdownConverter(object):
|
||||
columns = row.find_all('td')
|
||||
if len(headers) > 0:
|
||||
headers = [head.text.strip() for head in headers]
|
||||
headers = [head for head in headers if head]
|
||||
text_data.append(' | '.join(headers))
|
||||
text_data.append(' | '.join(['---'] * len(headers)))
|
||||
text_data.append('| ' + ' | '.join(headers) + ' |')
|
||||
text_data.append('| ' + ' | '.join(['---'] * len(headers)) + ' |')
|
||||
elif len(columns) > 0:
|
||||
columns = [colm.text.strip() for colm in columns]
|
||||
text_data.append(' | '.join(columns))
|
||||
text_data.append('| ' + ' | '.join(columns) + ' |')
|
||||
else:
|
||||
continue
|
||||
return '\n'.join(text_data)
|
||||
|
||||
Reference in New Issue
Block a user