diff --git a/readme_renderer/markdown.py b/readme_renderer/markdown.py index 8262339..93ac34a 100644 --- a/readme_renderer/markdown.py +++ b/readme_renderer/markdown.py @@ -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 @@ -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)