Skip to content

Commit 37ed941

Browse files
Merge pull request #550 from Crozzers/trailing-table-whitespace
Fix tables with trailing whitespace not being recognized (#549)
2 parents 9178066 + 3b3e845 commit 37ed941

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## python-markdown2 2.4.12 (not yet released)
44

5-
(nothing yet)
5+
- [pull #550] Fix tables with trailing whitespace not being recognized (#549)
66

77

88
## python-markdown2 2.4.11

lib/markdown2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,21 +1241,21 @@ def _do_tables(self, text):
12411241
(?:(?<=\n\n)|\A\n?) # leading blank line
12421242
12431243
^[ ]{0,%d} # allowed whitespace
1244-
(.*[|].*) \n # $1: header row (at least one pipe)
1244+
(.*[|].*)[ ]*\n # $1: header row (at least one pipe)
12451245
12461246
^[ ]{0,%d} # allowed whitespace
12471247
( # $2: underline row
12481248
# underline row with leading bar
1249-
(?: \|\ *:?-+:?\ * )+ \|? \s? \n
1249+
(?: \|\ *:?-+:?\ * )+ \|? \s?[ ]*\n
12501250
|
12511251
# or, underline row without leading bar
1252-
(?: \ *:?-+:?\ *\| )+ (?: \ *:?-+:?\ * )? \s? \n
1252+
(?: \ *:?-+:?\ *\| )+ (?: \ *:?-+:?\ * )? \s?[ ]*\n
12531253
)
12541254
12551255
( # $3: data rows
12561256
(?:
12571257
^[ ]{0,%d}(?!\ ) # ensure line begins with 0 to less_than_tab spaces
1258-
.*\|.* \n
1258+
.*\|.*[ ]*\n
12591259
)+
12601260
)
12611261
''' % (less_than_tab, less_than_tab, less_than_tab), re.M | re.X)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<table>
2+
<thead>
3+
<tr>
4+
<th>Pros</th>
5+
<th>Cons</th>
6+
</tr>
7+
</thead>
8+
<tbody>
9+
<tr>
10+
<td>Unique and refreshing take on the genre</td>
11+
<td>May not resonate with all viewers</td>
12+
</tr>
13+
<tr>
14+
<td>Cult classic status</td>
15+
<td>Over-the-top humor may polarize audiences</td>
16+
</tr>
17+
<tr>
18+
<td>Influential in launching careers</td>
19+
<td>Niche appeal among comedy aficionados</td>
20+
</tr>
21+
</tbody>
22+
</table>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"extras": ["tables"]}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| Pros | Cons |
2+
|-----------------------------------------|------------------------------------------------|
3+
| Unique and refreshing take on the genre | May not resonate with all viewers |
4+
| Cult classic status | Over-the-top humor may polarize audiences |
5+
| Influential in launching careers | Niche appeal among comedy aficionados |

0 commit comments

Comments
 (0)