Skip to content

Commit

Permalink
lists are not tables - fixes Python-Markdown#478 (Python-Markdown#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
adammichaelwood authored and waylan committed Oct 26, 2016
1 parent 251183e commit 0244474
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion markdown/extensions/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def test(self, parent, block):
rows = block.split('\n')
return (len(rows) > 1 and '|' in rows[0] and
'|' in rows[1] and '-' in rows[1] and
rows[1].strip()[0] in ['|', ':', '-'])
rows[1].strip()[0] in ['|', ':', '-'] and
set(rows[1]) <= set('|:- '))

def run(self, parent, blocks):
""" Parse a table block and build table. """
Expand Down
7 changes: 6 additions & 1 deletion tests/extensions/extra/tables.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,9 @@ <h2>Table Tests</h2>
<td>(<code>bar</code>) and <code>baz</code>.</td>
</tr>
</tbody>
</table>
</table>
<p>Lists are not tables</p>
<ul>
<li>this | should | not</li>
<li>be | a | table</li>
</ul>
9 changes: 7 additions & 2 deletions tests/extensions/extra/tables.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Three spaces in front of a table:
| Content Cell | Content Cell |

Four spaces is a code block:

First Header | Second Header
------------ | -------------
Content Cell | Content Cell
Expand Down Expand Up @@ -74,4 +74,9 @@ A test for issue #440:

foo | bar
--- | ---
foo | (`bar`) and `baz`.
foo | (`bar`) and `baz`.

Lists are not tables

- this | should | not
- be | a | table

0 comments on commit 0244474

Please sign in to comment.