summaryrefslogtreecommitdiff
path: root/yarnlib
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-06-23 09:12:25 +0100
committerLars Wirzenius <liw@liw.fi>2013-06-23 09:12:25 +0100
commitbec45232f5775bc934a638e3095ac77f78176708 (patch)
tree5682272d4d267cb076079f6c01ded30f766ab25a /yarnlib
parent4d5992fd7bc2a49cd31a8eb36c01b9dc3c2480e5 (diff)
downloadcmdtest-bec45232f5775bc934a638e3095ac77f78176708.tar.gz
Make MarkdownParser return the blocks for each file
Diffstat (limited to 'yarnlib')
-rw-r--r--yarnlib/mdparser.py1
-rw-r--r--yarnlib/mdparser_tests.py9
2 files changed, 7 insertions, 3 deletions
diff --git a/yarnlib/mdparser.py b/yarnlib/mdparser.py
index 9917f8b..7884630 100644
--- a/yarnlib/mdparser.py
+++ b/yarnlib/mdparser.py
@@ -68,6 +68,7 @@ class MarkdownParser(object):
f = StringIO.StringIO()
markdown.markdown(text, output=f, extensions=[ext])
self.blocks.extend(ext.blocks)
+ return ext.blocks
def parse_file(self, filename): # pragma: no cover
with open(filename) as f:
diff --git a/yarnlib/mdparser_tests.py b/yarnlib/mdparser_tests.py
index a9b9cb7..099ff2b 100644
--- a/yarnlib/mdparser_tests.py
+++ b/yarnlib/mdparser_tests.py
@@ -27,7 +27,7 @@ class MarkdownParserTests(unittest.TestCase):
self.parser = yarnlib.MarkdownParser()
def test_finds_code_block(self):
- self.parser.parse_string('''
+ result = self.parser.parse_string('''
This is blah blah text.
this is a code block
@@ -35,6 +35,7 @@ This is blah blah text.
More text.
''')
self.assertEqual(self.parser.blocks, ['this is a code block\n'])
+ self.assertEqual(result, ['this is a code block\n'])
def test_finds_consecutive_code_blocks_as_one(self):
self.parser.parse_string('''
@@ -83,11 +84,13 @@ More text.
self.assertEqual(self.parser.blocks, ['this is a code block\n'])
def test_parses_multiple_files(self):
- self.parser.parse_string('''
+ result1 = self.parser.parse_string('''
block 1
''')
- self.parser.parse_string('''
+ result2 = self.parser.parse_string('''
block 2
''')
+ self.assertEqual(result1, ['block 1\n'])
+ self.assertEqual(result2, ['block 2\n'])
self.assertEqual(self.parser.blocks, ['block 1\n', 'block 2\n'])