Skip to content

Commit 24afe5c

Browse files
committed
Fix escaping GT-angles not working
1 parent 309386f commit 24afe5c

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

lib/markdown2.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,11 @@ def _escape_special_chars(self, text: str) -> str:
13201320
.replace('_', self._escape_table['_'])
13211321
)
13221322
else:
1323-
escaped.append(self._encode_backslash_escapes(token.replace('\\<', '&lt;')))
1323+
escaped.append(
1324+
self._encode_backslash_escapes(
1325+
token.replace('\\<', '&lt;').replace('\\>', '&gt;')
1326+
)
1327+
)
13241328
is_html_markup = not is_html_markup
13251329
return ''.join(escaped)
13261330

test/markdowntest-cases/Backslash escapes.html

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

2121
<p>Right paren: )</p>
2222

23-
<p>Greater-than: ></p>
23+
<p>Greater-than: &gt;</p>
2424

2525
<p>Hash: #</p>
2626

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
<p>&lt;abc></p>
1+
<p>&lt;abc&gt;
2+
&lt;abc></p>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
\<abc\>
1+
\<abc\>
2+
\<abc>

0 commit comments

Comments
 (0)