diff --git a/CHANGES.md b/CHANGES.md index f16d321d..e880d4fe 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ ## python-markdown2 2.4.12 (not yet released) - [pull #547] Update `markdown-in-html` extra to handle markdown on same line as HTML (#546) +- [pull #550] Fix tables with trailing whitespace not being recognized (#549) ## python-markdown2 2.4.11 diff --git a/lib/markdown2.py b/lib/markdown2.py index f2e8d142..6ea3901e 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -1252,21 +1252,21 @@ def _do_tables(self, text): (?:(?<=\n\n)|\A\n?) # leading blank line ^[ ]{0,%d} # allowed whitespace - (.*[|].*) \n # $1: header row (at least one pipe) + (.*[|].*)[ ]*\n # $1: header row (at least one pipe) ^[ ]{0,%d} # allowed whitespace ( # $2: underline row # underline row with leading bar - (?: \|\ *:?-+:?\ * )+ \|? \s? \n + (?: \|\ *:?-+:?\ * )+ \|? \s?[ ]*\n | # or, underline row without leading bar - (?: \ *:?-+:?\ *\| )+ (?: \ *:?-+:?\ * )? \s? \n + (?: \ *:?-+:?\ *\| )+ (?: \ *:?-+:?\ * )? \s?[ ]*\n ) ( # $3: data rows (?: ^[ ]{0,%d}(?!\ ) # ensure line begins with 0 to less_than_tab spaces - .*\|.* \n + .*\|.*[ ]*\n )+ ) ''' % (less_than_tab, less_than_tab, less_than_tab), re.M | re.X) diff --git a/test/test_markdown2.py b/test/test_markdown2.py index cc2a80b2..1f08afd5 100755 --- a/test/test_markdown2.py +++ b/test/test_markdown2.py @@ -345,8 +345,7 @@ def norm_html_from_html(html): html = html.decode('utf-8') html = _markdown_email_link_re.sub( _markdown_email_link_sub, html) - if sys.platform == "win32": - html = html.replace('\r\n', '\n') + html = html.replace('\r\n', '\n') return html diff --git a/test/tm-cases/trailing_table_whitespace.html b/test/tm-cases/trailing_table_whitespace.html new file mode 100644 index 00000000..e0a19866 --- /dev/null +++ b/test/tm-cases/trailing_table_whitespace.html @@ -0,0 +1,22 @@ +
Pros | +Cons | +
---|---|
Unique and refreshing take on the genre | +May not resonate with all viewers | +
Cult classic status | +Over-the-top humor may polarize audiences | +
Influential in launching careers | +Niche appeal among comedy aficionados | +