summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--md_tw.py7
-rw-r--r--tests/data/blexer-heading.md11
-rw-r--r--tests/test_md_tw.py11
3 files changed, 29 insertions, 0 deletions
diff --git a/md_tw.py b/md_tw.py
index 218d324..64c9ced 100644
--- a/md_tw.py
+++ b/md_tw.py
@@ -52,6 +52,13 @@ class TWBlockLexer(mistune.BlockLexer):
'text': m.group(0),
})
+ def parse_heading(self, m):
+ self.tokens.append({
+ 'type': 'heading',
+ 'level': len(m.group(1)),
+ 'text': m.group(0),
+ })
+
class TWInlineLexer(mistune.InlineLexer):
"""Text Wrap Inline level lexer for inline gramars."""
diff --git a/tests/data/blexer-heading.md b/tests/data/blexer-heading.md
new file mode 100644
index 0000000..382896d
--- /dev/null
+++ b/tests/data/blexer-heading.md
@@ -0,0 +1,11 @@
+# Milky Chance
+
+Clemens, Phillipp, Antonio
+
+## Flashed
+
+Lost our mind.
+
+### Junk Mind
+
+In the junkyard.
diff --git a/tests/test_md_tw.py b/tests/test_md_tw.py
index 032ef93..af2ce45 100644
--- a/tests/test_md_tw.py
+++ b/tests/test_md_tw.py
@@ -68,6 +68,17 @@ class TestTWBlockLexer(object):
self._validate(tokens, 'code', expected_fences)
+ def test_parse_heading(self):
+ tokens = self._parse('blexer-heading.md')
+
+ expected_hs = [
+ '# Milky Chance\n\n',
+ '## Flashed\n\n',
+ '### Junk Mind\n\n',
+ ]
+
+ self._validate(tokens, 'heading', expected_hs)
+
def teardown(self):
pass