diff options
author | Waylan Limberg <waylan.limberg@icloud.com> | 2015-04-06 18:48:33 -0400 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2015-04-06 18:48:33 -0400 |
commit | 3481625df718efb6d4d9241085f3b3b3573917e3 (patch) | |
tree | 2232ecabc3db7df283f6b2b408c6a6915ff5dd89 | |
parent | cf7234dea91637de77179bf6e00c66e15c06f070 (diff) | |
parent | 8cd0446d3ddfeee6843549869ce0c20ec6d3e67a (diff) | |
download | markdown-3481625df718efb6d4d9241085f3b3b3573917e3.tar.gz markdown-3481625df718efb6d4d9241085f3b3b3573917e3.tar.bz2 markdown-3481625df718efb6d4d9241085f3b3b3573917e3.zip |
Merge pull request #400 from pieterprovoost/emptytable
support empty table
-rw-r--r-- | markdown/extensions/tables.py | 4 | ||||
-rw-r--r-- | tests/extensions/extra/tables.html | 11 | ||||
-rw-r--r-- | tests/extensions/extra/tables.txt | 3 |
3 files changed, 15 insertions, 3 deletions
diff --git a/markdown/extensions/tables.py b/markdown/extensions/tables.py index cbf711a..368321d 100644 --- a/markdown/extensions/tables.py +++ b/markdown/extensions/tables.py @@ -27,7 +27,7 @@ class TableProcessor(BlockProcessor): def test(self, parent, block): rows = block.split('\n') - return (len(rows) > 2 and '|' in rows[0] and + return (len(rows) > 1 and '|' in rows[0] and '|' in rows[1] and '-' in rows[1] and rows[1].strip()[0] in ['|', ':', '-']) @@ -36,7 +36,7 @@ class TableProcessor(BlockProcessor): block = blocks.pop(0).split('\n') header = block[0].strip() seperator = block[1].strip() - rows = block[2:] + rows = [] if len(block) < 3 else block[2:] # Get format type (bordered by pipes or not) border = False if header.startswith('|'): diff --git a/tests/extensions/extra/tables.html b/tests/extensions/extra/tables.html index 64196ec..85a998d 100644 --- a/tests/extensions/extra/tables.html +++ b/tests/extensions/extra/tables.html @@ -159,4 +159,13 @@ ------------ | ------------- Content Cell | Content Cell Content Cell | Content Cell -</code></pre>
\ No newline at end of file +</code></pre> +<table> +<thead> +<tr> +<th>First Header</th> +<th>Second Header</th> +</tr> +</thead> +<tbody></tbody> +</table>
\ No newline at end of file diff --git a/tests/extensions/extra/tables.txt b/tests/extensions/extra/tables.txt index cf97cb5..8acc3c6 100644 --- a/tests/extensions/extra/tables.txt +++ b/tests/extensions/extra/tables.txt @@ -50,3 +50,6 @@ Four spaces is a code block: ------------ | ------------- Content Cell | Content Cell Content Cell | Content Cell + +| First Header | Second Header | +| ------------ | ------------- |
\ No newline at end of file |