Skip to content

Commit 47737e4

Browse files
added support for zero row tables
1 parent cf7234d commit 47737e4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
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.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)