Skip to content

Commit

Permalink
Merge branch 'master' into markdown-in-html-same-line
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasserra committed Dec 10, 2023
2 parents 6912b63 + f7b4535 commit f5d0f40
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions test/test_markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
22 changes: 22 additions & 0 deletions test/tm-cases/trailing_table_whitespace.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<table>
<thead>
<tr>
<th>Pros</th>
<th>Cons</th>
</tr>
</thead>
<tbody>
<tr>
<td>Unique and refreshing take on the genre</td>
<td>May not resonate with all viewers</td>
</tr>
<tr>
<td>Cult classic status</td>
<td>Over-the-top humor may polarize audiences</td>
</tr>
<tr>
<td>Influential in launching careers</td>
<td>Niche appeal among comedy aficionados</td>
</tr>
</tbody>
</table>
1 change: 1 addition & 0 deletions test/tm-cases/trailing_table_whitespace.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"extras": ["tables"]}
5 changes: 5 additions & 0 deletions test/tm-cases/trailing_table_whitespace.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| 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 |

0 comments on commit f5d0f40

Please sign in to comment.