Skip to content

Commit 3481625

Browse files
committed
Merge pull request #400 from pieterprovoost/emptytable
support empty table
2 parents cf7234d + 8cd0446 commit 3481625

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

markdown/extensions/tables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class TableProcessor(BlockProcessor):
2727

2828
def test(self, parent, block):
2929
rows = block.split('\n')
30-
return (len(rows) > 2 and '|' in rows[0] and
30+
return (len(rows) > 1 and '|' in rows[0] and
3131
'|' in rows[1] and '-' in rows[1] and
3232
rows[1].strip()[0] in ['|', ':', '-'])
3333

@@ -36,7 +36,7 @@ def run(self, parent, blocks):
3636
block = blocks.pop(0).split('\n')
3737
header = block[0].strip()
3838
seperator = block[1].strip()
39-
rows = block[2:]
39+
rows = [] if len(block) < 3 else block[2:]
4040
# Get format type (bordered by pipes or not)
4141
border = False
4242
if header.startswith('|'):

tests/extensions/extra/tables.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,13 @@ <h2>Table Tests</h2>
159159
------------ | -------------
160160
Content Cell | Content Cell
161161
Content Cell | Content Cell
162-
</code></pre>
162+
</code></pre>
163+
<table>
164+
<thead>
165+
<tr>
166+
<th>First Header</th>
167+
<th>Second Header</th>
168+
</tr>
169+
</thead>
170+
<tbody></tbody>
171+
</table>

tests/extensions/extra/tables.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ Four spaces is a code block:
5050
------------ | -------------
5151
Content Cell | Content Cell
5252
Content Cell | Content Cell
53+
54+
| First Header | Second Header |
55+
| ------------ | ------------- |

0 commit comments

Comments
 (0)