Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cuddled tables (#557) #559

Merged
merged 2 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## python-markdown2 2.4.13 (not yet released)

(nothing yet)
- [pull #559] Allow cuddled tables (#557)


## python-markdown2 2.4.12
Expand Down
2 changes: 1 addition & 1 deletion lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ def _do_tables(self, text):
"""
less_than_tab = self.tab_width - 1
table_re = re.compile(r'''
(?:(?<=\n\n)|\A\n?) # leading blank line
(?:(?<=\n)|\A\n?) # leading blank line

^[ ]{0,%d} # allowed whitespace
(.*[|].*)[ ]*\n # $1: header row (at least one pipe)
Expand Down
27 changes: 21 additions & 6 deletions test/tm-cases/tables.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,28 @@ <h1>table with cuddled following content</h1>

<p><em>Note:</em> This passes GFM, but fails in PHP-Markdown.</p>

<h1>FAIL: table with cuddled leading content</h1>
<h1>table with cuddled leading content</h1>

<p>before
| Header 1 | Header 2 |
| -------- | -------- |
| Cell 1 | Cell 2 |
| Cell 3 | Cell 4 |</p>
<p>This would have failed in &lt;=2.4.13</p>

<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
<tr>
<td>Cell 3</td>
<td>Cell 4</td>
</tr>
</tbody>
</table>

<h1>single column single leading bar</h1>

Expand Down
4 changes: 2 additions & 2 deletions test/tm-cases/tables.text
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ after
*Note:* This passes GFM, but fails in PHP-Markdown.


# FAIL: table with cuddled leading content
# table with cuddled leading content

before
This would have failed in <=2.4.13
| Header 1 | Header 2 |
| -------- | -------- |
| Cell 1 | Cell 2 |
Expand Down
Loading