From c41792af6b692d302575b6e66dd6e296974e0e86 Mon Sep 17 00:00:00 2001 From: Lonami Date: Wed, 19 Dec 2018 14:58:49 +0000 Subject: [PATCH] Simplify aesthetify --- stdplugins/markdown.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/stdplugins/markdown.py b/stdplugins/markdown.py index 57c7b94..d9e885e 100644 --- a/stdplugins/markdown.py +++ b/stdplugins/markdown.py @@ -31,16 +31,15 @@ def get_tag_parser(tag, entity): return re.compile(tag + r'(.+?)' + tag, re.DOTALL), tag_parser -PRINTABLE_ASCII = range(0x21, 0x7f) def parse_aesthetics(m): def aesthetify(string): for c in string: - c = ord(c) - if c in PRINTABLE_ASCII: - c += 0xFF00 - 0x20 - elif c == ord(" "): - c = 0x3000 - yield chr(c) + if " " < c <= "~": + yield chr(ord(c) + 0xFF00 - 0x20) + elif c == " ": + yield "\u3000" + else: + yield c return "".join(aesthetify(m[1])), None