markdown-textwrap

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

commit a18df9d9adc54bbc8ea1f3b1a1c59f316667e840
parent d9d4e31636da136be3a8dd60d507140e03c0cf6c
Author: rsiddharth <s@ricketyspace.net>
Date:   Tue,  2 Jan 2018 00:37:33 +0000

md_tw.py: Add `TWBlockLexer.parse_fences`.

* md_tw.py (TWBlockLexer.parse_fences): New method.
* tests/data/blexer-fences.md: New file.
* tests/test_md_tw.py (test_parse_fences): New test.

Diffstat:
md_tw.py | 7+++++++
tests/data/blexer-fences.md | 12++++++++++++
tests/test_md_tw.py | 10++++++++++
3 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/md_tw.py b/md_tw.py @@ -45,6 +45,13 @@ class TWBlockLexer(mistune.BlockLexer): 'text': m.group(0), }) + def parse_fences(self, m): + self.tokens.append({ + 'type': 'code', + 'lang': None, + 'text': m.group(0), + }) + class TWInlineLexer(mistune.InlineLexer): """Text Wrap Inline level lexer for inline gramars.""" diff --git a/tests/data/blexer-fences.md b/tests/data/blexer-fences.md @@ -0,0 +1,12 @@ +Let's have some chaos: + +```bash +$ echo 'Zap!' +$ rm -rf / +``` +> Some Jaromil art inside a block quote +> +> ```bash +> $ :(){:|:&};: +> ``` +> For more look at jaramil.dyne.org. He's awesome. diff --git a/tests/test_md_tw.py b/tests/test_md_tw.py @@ -58,6 +58,16 @@ class TestTWBlockLexer(object): ] self._validate(tokens, 'code', expected_bc) + def test_parse_fences(self): + tokens = self._parse('blexer-fences.md') + + expected_fences = [ + '```bash\n$ echo \'Zap!\'\n$ rm -rf /\n```\n', + '```bash\n$ :(){:|:&};:\n```\n' + ] + + self._validate(tokens, 'code', expected_fences) + def teardown(self): pass