Skip to content

Commit 17d8586

Browse files
authored
don't escape text in pre tag (Fenced Code Blocks) (#67)
don't escape text in pre tag (Fenced Code Blocks)
1 parent 59eb069 commit 17d8586

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

markdownify/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def process_text(self, el):
158158
and el.parent.parent.name == 'pre')):
159159
text = whitespace_re.sub(' ', text)
160160

161-
if el.parent.name != 'code':
161+
if el.parent.name != 'code' and el.parent.name != 'pre':
162162
text = self.escape(text)
163163

164164
# remove trailing whitespaces if any of the following condition is true:

tests/test_conversions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def test_p():
187187
def test_pre():
188188
assert md('<pre>test\n foo\nbar</pre>') == '\n```\ntest\n foo\nbar\n```\n'
189189
assert md('<pre><code>test\n foo\nbar</code></pre>') == '\n```\ntest\n foo\nbar\n```\n'
190+
assert md('<pre>this_should_not_escape</pre>') == '\n```\nthis_should_not_escape\n```\n'
190191

191192

192193
def test_s():

0 commit comments

Comments
 (0)