diff options
Diffstat (limited to 'creole/html_tools/deentity.py')
-rw-r--r-- | creole/html_tools/deentity.py | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/creole/html_tools/deentity.py b/creole/html_tools/deentity.py index 2f6104a..fd23782 100644 --- a/creole/html_tools/deentity.py +++ b/creole/html_tools/deentity.py @@ -1,24 +1,16 @@ -#!/usr/bin/env python -# coding: utf-8 """ python-creole utils ~~~~~~~~~~~~~~~~~~~ - :copyleft: 2008-2011 by python-creole team, see AUTHORS for more details. + :copyleft: 2008-2020 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ - import re -try: - import htmlentitydefs as entities -except ImportError: - from html import entities # python 3 - -from creole.py3compat import PY3 +from html import entities entities_rules = '|'.join([ @@ -53,18 +45,12 @@ class Deentity(object): def replace_number(self, text): """ unicode number entity """ unicode_no = int(text) - if PY3: - return chr(unicode_no) - else: - return unichr(unicode_no) + return chr(unicode_no) def replace_hex(self, text): """ hex entity """ unicode_no = int(text, 16) - if PY3: - return chr(unicode_no) - else: - return unichr(unicode_no) + return chr(unicode_no) def replace_named(self, text): """ named entity """ @@ -73,10 +59,7 @@ class Deentity(object): return " " else: codepoint = entities.name2codepoint[text] - if PY3: - return chr(codepoint) - else: - return unichr(codepoint) + return chr(codepoint) def replace_all(self, content): """ replace all html entities form the given text. """ |