markdown-textwrap

text wrap markdown documents
git clone git://git.ricketyspace.net/markdown-textwrap.git
Log | Files | Refs

commit cad2e7b18e510a89e159148f1141691fd1fc6715
parent d78ac3764a90fc959862777f37fc9f175e5272e1
Author: rsiddharth <s@ricketyspace.net>
Date:   Tue,  2 Jan 2018 00:44:15 +0000

md_tw.py: Add TWBlockLexer.parse_hrule.

* md_tw.py
(TWBlockLexer.parse_hrule): New method
* tests/test_md_tw.py
(TestTWBlockLexer.test_parse_hrule): New test.
* tests/data/blexer-hrules.md: New file.

Diffstat:
md_tw.py | 6++++++
tests/data/blexer-hrules.md | 19+++++++++++++++++++
tests/test_md_tw.py | 13+++++++++++++
3 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/md_tw.py b/md_tw.py @@ -67,6 +67,12 @@ class TWBlockLexer(mistune.BlockLexer): 'text': m.group(0), }) + def parse_hrule(self, m): + self.tokens.append({ + 'type': 'hrule', + 'text': m.group(0) + }) + class TWInlineLexer(mistune.InlineLexer): """Text Wrap Inline level lexer for inline gramars.""" diff --git a/tests/data/blexer-hrules.md b/tests/data/blexer-hrules.md @@ -0,0 +1,19 @@ +* * * + +Dresden Dolls + +*** + +God Damn The Sun + +***** + +Backstabber + +- - - + +Sorry Bunch + +--------------------------------------- + +Gravity diff --git a/tests/test_md_tw.py b/tests/test_md_tw.py @@ -90,6 +90,19 @@ class TestTWBlockLexer(object): self._validate(tokens, 'heading', expected_lhs) + def test_parse_hrule(self): + tokens = self._parse('blexer-hrules.md') + + expected_hrs = [ + '* * *\n\n', + '***\n\n', + '*****\n\n', + '- - -\n\n', + '---------------------------------------\n\n' + ] + + self._validate(tokens, 'hrule', expected_hrs) + def teardown(self): pass