summaryrefslogtreecommitdiffstats
path: root/md_tw.py
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2018-01-02 00:49:28 +0000
committerrsiddharth <s@ricketyspace.net>2018-01-02 00:49:28 +0000
commitad8fa809c55e2bf2a6bf2e977f6683e90ad7200d (patch)
treee6e83e16745922476d71831ea7c3c2de37b80683 /md_tw.py
parent12903a82dc2ee039b0356855657e3f66173b9e92 (diff)
md_tw.py: Add TWBlockLexer.parse_def_links.
* md_tw.py (TWBlockLexer.parse_def_links): New method. * tests/test_md_tw.py (TestTWBlockLexer.test_parse_def_links): New test. * tests/data/blexer-def-links.md: New file.
Diffstat (limited to 'md_tw.py')
-rw-r--r--md_tw.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/md_tw.py b/md_tw.py
index 19b5b30..7f9b578 100644
--- a/md_tw.py
+++ b/md_tw.py
@@ -148,6 +148,17 @@ class TWBlockLexer(mistune.BlockLexer):
'spaces': len(quote)
})
+ def parse_def_links(self, m):
+ key = self._keyify(m.group(1))
+ self.def_links[key] = {
+ 'link': m.group(2),
+ 'title': m.group(3),
+ }
+ self.tokens.append({
+ 'type': 'def_links',
+ 'text': m.group(0)
+ })
+
class TWInlineLexer(mistune.InlineLexer):
"""Text Wrap Inline level lexer for inline gramars."""