From 0244474b2dbf15986891a8d700c7bb121dc6f55f Mon Sep 17 00:00:00 2001 From: Adam Wood Date: Wed, 26 Oct 2016 10:17:38 -0700 Subject: lists are not tables - fixes #478 (#507) --- markdown/extensions/tables.py | 3 ++- tests/extensions/extra/tables.html | 7 ++++++- tests/extensions/extra/tables.txt | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/markdown/extensions/tables.py b/markdown/extensions/tables.py index 8c11739..7c75507 100644 --- a/markdown/extensions/tables.py +++ b/markdown/extensions/tables.py @@ -30,7 +30,8 @@ class TableProcessor(BlockProcessor): 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. """ diff --git a/tests/extensions/extra/tables.html b/tests/extensions/extra/tables.html index b5c08be..85d9940 100644 --- a/tests/extensions/extra/tables.html +++ b/tests/extensions/extra/tables.html @@ -250,4 +250,9 @@ Content Cell | Content Cell (bar) and baz. - \ No newline at end of file + +

Lists are not tables

+ \ No newline at end of file diff --git a/tests/extensions/extra/tables.txt b/tests/extensions/extra/tables.txt index c9ca70a..c843918 100644 --- a/tests/extensions/extra/tables.txt +++ b/tests/extensions/extra/tables.txt @@ -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 @@ -74,4 +74,9 @@ A test for issue #440: foo | bar --- | --- -foo | (`bar`) and `baz`. \ No newline at end of file +foo | (`bar`) and `baz`. + +Lists are not tables + + - this | should | not + - be | a | table -- cgit v1.2.3