Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] support python3.9 by using unescape() from html_parser (python3 only) #175

Closed
sandrotosi opened this issue Oct 19, 2020 · 0 comments · Fixed by #176
Closed

[patch] support python3.9 by using unescape() from html_parser (python3 only) #175

sandrotosi opened this issue Oct 19, 2020 · 0 comments · Fixed by #176

Comments

@sandrotosi
Copy link

Hello,
python3.9 removed html.parser.HTMLParser.unescape() (just scroll above that reference), so markdown.py will need to be updated

in Debian, i wrote a patch that does:

--- a/readme_renderer/markdown.py
+++ b/readme_renderer/markdown.py
@@ -99,7 +99,7 @@ def _highlight(html):
         # 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 = html_parser.unescape(code)
 
         highlighted = pygments.highlight(code, lexer, formatter)

as in python3 unescape() is available from six.modes.html_parser, but that doesnt work on python2.7, which is still supported by this project:

$ python2.7 -c "from six.moves import html_parser ; html_parser.unescape('')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'unescape'

for Debian, this is fine, since we're phasing out python2.7, but if you still want to support 2.7 and add support for 3.9, you may want to check the interpreter version, as i'm afraid six wont help much (i mean, you can use six.PY2|3 but that's about it)

@sandrotosi sandrotosi changed the title support python3.9 by using unescape() from html_parser (python3 only) [patch] support python3.9 by using unescape() from html_parser (python3 only) Oct 19, 2020
@di di mentioned this issue Oct 20, 2020
@di di closed this as completed in #176 Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant