Skip to content

Commit

Permalink
Merge branch 'master' into always-split-markdown-in-html
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasserra authored Dec 26, 2023
2 parents c119ef5 + 844942a commit 0203031
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## python-markdown2 2.4.13 (not yet released)

- [pull #559] Allow cuddled tables (#557)
- [pull #560] Fix `markdown-in-html` not always splitting HTML tags into separate lines (#558)


Expand Down
2 changes: 1 addition & 1 deletion lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,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

0 comments on commit 0203031

Please sign in to comment.