From 9df739fcf2e837d0131c8d468564b46f8c7adb98 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Tue, 2 Jan 2018 00:31:54 +0000 Subject: md_tw.py: Add TWBlockLexer._keyify. * md_tw.py (TWBlockLexer._keyify): New private method. (TWBlockLexer.__init__): Update method. --- md_tw.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/md_tw.py b/md_tw.py index bd9d991..6c73903 100644 --- a/md_tw.py +++ b/md_tw.py @@ -18,6 +18,7 @@ # along with markdown-textwrap (see COPYING). If not, see # . +import re import textwrap import mistune @@ -29,6 +30,13 @@ class TWBlockLexer(mistune.BlockLexer): def __init__(self, rules=None, **kwargs): super(TWBlockLexer, self).__init__(rules, **kwargs) + # from mistune + self._key_pattern = re.compile(r'\s+') + + # from mistune + def _keyify(self, key): + key = mistune.escape(key.lower(), quote=True) + return self._key_pattern.sub(' ', key) class TWInlineLexer(mistune.InlineLexer): -- cgit v1.2.3