Skip to content

Commit

Permalink
Work around changes to html_parser.unescape
Browse files Browse the repository at this point in the history
  • Loading branch information
di committed Oct 20, 2020
1 parent fd53ef6 commit be14320
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions readme_renderer/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
import pygments
import pygments.lexers
import pygments.formatters
from six.moves import html_parser

try:
from six.moves.html_parser import unescape
except ImportError: # Python 2
from six.moves import html_parser

unescape = html_parser.HTMLParser().unescape

from .clean import clean

Expand Down Expand Up @@ -99,7 +105,7 @@ def replacer(match):
# translate '"' to '"', but it confuses pygments. Pygments will
# escape any html entities when re-writing the code, and we run
# everything through bleach after.
code = html_parser.HTMLParser().unescape(code)
code = unescape(code)

highlighted = pygments.highlight(code, lexer, formatter)

Expand Down

0 comments on commit be14320

Please sign in to comment.