Skip to content

Commit 2b8cf44

Browse files
committed
Merge branch 'develop'
2 parents d375116 + 207d0f4 commit 2b8cf44

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

markdownify/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,13 @@ def convert_tr(self, el, text, convert_as_inline):
370370
if is_headrow and not el.previous_sibling:
371371
# first row and is headline: print headline underline
372372
underline += '| ' + ' | '.join(['---'] * len(cells)) + ' |' + '\n'
373-
elif not el.previous_sibling and not el.parent.name != 'table':
374-
# first row, not headline, and the parent is sth. like tbody:
373+
elif (not el.previous_sibling
374+
and (el.parent.name == 'table'
375+
or (el.parent.name == 'tbody'
376+
and not el.parent.previous_sibling))):
377+
# first row, not headline, and:
378+
# - the parent is table or
379+
# - the parent is tbody at the beginning of a table.
375380
# print empty headline above this row
376381
overline += '| ' + ' | '.join([''] * len(cells)) + ' |' + '\n'
377382
overline += '| ' + ' | '.join(['---'] * len(cells)) + ' |' + '\n'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
pkgmeta = {
1111
'__title__': 'markdownify',
1212
'__author__': 'Matthew Tretter',
13-
'__version__': '0.11.0',
13+
'__version__': '0.11.1',
1414
}
1515

1616

tests/test_tables.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,26 @@
139139
</tr>
140140
</table>"""
141141

142+
table_body = """<table>
143+
<tbody>
144+
<tr>
145+
<td>Firstname</td>
146+
<td>Lastname</td>
147+
<td>Age</td>
148+
</tr>
149+
<tr>
150+
<td>Jill</td>
151+
<td>Smith</td>
152+
<td>50</td>
153+
</tr>
154+
<tr>
155+
<td>Eve</td>
156+
<td>Jackson</td>
157+
<td>94</td>
158+
</tr>
159+
</tbody>
160+
</table>"""
161+
142162

143163
def test_table():
144164
assert md(table) == '\n\n| Firstname | Lastname | Age |\n| --- | --- | --- |\n| Jill | Smith | 50 |\n| Eve | Jackson | 94 |\n\n'
@@ -148,3 +168,4 @@ def test_table():
148168
assert md(table_head_body) == '\n\n| Firstname | Lastname | Age |\n| --- | --- | --- |\n| Jill | Smith | 50 |\n| Eve | Jackson | 94 |\n\n'
149169
assert md(table_missing_text) == '\n\n| | Lastname | Age |\n| --- | --- | --- |\n| Jill | | 50 |\n| Eve | Jackson | 94 |\n\n'
150170
assert md(table_missing_head) == '\n\n| | | |\n| --- | --- | --- |\n| Firstname | Lastname | Age |\n| Jill | Smith | 50 |\n| Eve | Jackson | 94 |\n\n'
171+
assert md(table_body) == '\n\n| | | |\n| --- | --- | --- |\n| Firstname | Lastname | Age |\n| Jill | Smith | 50 |\n| Eve | Jackson | 94 |\n\n'

0 commit comments

Comments
 (0)