diff options
author | rsiddharth <s@ricketyspace.net> | 2018-01-02 00:31:54 +0000 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2018-01-02 00:31:54 +0000 |
commit | 9df739fcf2e837d0131c8d468564b46f8c7adb98 (patch) | |
tree | ac3ae1372b03787e88b9b02ad6198c8ce6eb03b9 | |
parent | 6bc1aeb370ab33bbfa2dbece6d85fc22c198fdcd (diff) |
md_tw.py: Add TWBlockLexer._keyify.
* md_tw.py
(TWBlockLexer._keyify): New private method.
(TWBlockLexer.__init__): Update method.
-rw-r--r-- | md_tw.py | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -18,6 +18,7 @@ # along with markdown-textwrap (see COPYING). If not, see # <http://www.gnu.org/licenses/>. +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): |