diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 5fdcbf3..fcdc32a 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -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))) elif len(columns) > 0: columns = [colm.text.strip() for colm in columns] - text_data.append(' | '.join([colm for colm in columns if colm])) + text_data.append(' | '.join(columns)) else: continue return '\n'.join(text_data) diff --git a/tests/test_conversions.py b/tests/test_conversions.py index cff19bd..2d2e825 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -67,6 +67,30 @@ table_head_body = re.sub(r'\s+', '', """ """) +table_missing_header = re.sub(r'\s+', '', """ +
| + | Lastname | +Age | +
|---|---|---|
| Jill | +Smith | +50 | +
| Eve | +Jackson | +94 | +