don't escape text in pre tag (Fenced Code Blocks) (#67)

don't escape text in pre tag (Fenced Code Blocks)
This commit is contained in:
Adam Bambuch
2022-08-28 20:58:54 +02:00
committed by GitHub
parent 59eb069700
commit 17d8586843
2 changed files with 2 additions and 1 deletions

View File

@@ -158,7 +158,7 @@ class MarkdownConverter(object):
and el.parent.parent.name == 'pre')):
text = whitespace_re.sub(' ', text)
if el.parent.name != 'code':
if el.parent.name != 'code' and el.parent.name != 'pre':
text = self.escape(text)
# remove trailing whitespaces if any of the following condition is true:

View File

@@ -187,6 +187,7 @@ def test_p():
def test_pre():
assert md('<pre>test\n foo\nbar</pre>') == '\n```\ntest\n foo\nbar\n```\n'
assert md('<pre><code>test\n foo\nbar</code></pre>') == '\n```\ntest\n foo\nbar\n```\n'
assert md('<pre>this_should_not_escape</pre>') == '\n```\nthis_should_not_escape\n```\n'
def test_s():