diff options
| author | Rohitt Vashishtha <aero31aero@gmail.com> | 2020-06-29 17:35:17 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-29 13:35:17 -0400 |
| commit | 071c4f1420ac3c80ad621522b9996bcc1cd94bcf (patch) | |
| tree | a1714a0f0e7c9b81dd7b9d9d84cf4c6d8de82509 /markdown/extensions | |
| parent | 570625884328ea3c71000391de77776691074033 (diff) | |
| download | python-markdown-071c4f1420ac3c80ad621522b9996bcc1cd94bcf.tar.gz | |
Fix unescaping of HTML characters <> in CodeHilite. (#990)
Previously, we'd unescape both `&gt;` and `>` to the same
string because we were running the & => & replacement first.
By changing the order of this replacement, we now convert:
`&gt; >` => `> >`
as expected.
Fixes #988.
Diffstat (limited to 'markdown/extensions')
| -rw-r--r-- | markdown/extensions/codehilite.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/markdown/extensions/codehilite.py b/markdown/extensions/codehilite.py index 915dfcf..9eed561 100644 --- a/markdown/extensions/codehilite.py +++ b/markdown/extensions/codehilite.py @@ -225,9 +225,11 @@ class HiliteTreeprocessor(Treeprocessor): def code_unescape(self, text): """Unescape code.""" - text = text.replace("&", "&") text = text.replace("<", "<") text = text.replace(">", ">") + # Escaped '&' should be replaced at the end to avoid + # conflicting with < and >. + text = text.replace("&", "&") return text def run(self, root): |
