Exemple #1
0
 def _test_match(self, token_cls, lines, arg, **kwargs):
     token = next(iter(block_token.tokenize(lines)))
     self.assertIsInstance(token, token_cls)
     self._test_token(token, arg, **kwargs)
Exemple #2
0
 def test_lazy_continuation(self):
     with patch('mistletoe.block_token.Paragraph') as mock:
         token = next(iter(block_token.tokenize(['> line 1\n',
                                                 'line 2\n'])))
         self.assertIsInstance(token, block_token.Quote)
 def test_block_code_no_language(self):
     from mistletoe.block_token import tokenize
     rendered = self.renderer.render(
         tokenize(['```\n', 'foo\n', '```\n'])[0])
     output = '<pre><code>foo\n</code></pre>'
     self.assertEqual(rendered, output)
Exemple #4
0
 def test_case(line):
     token = next(iter(block_token.tokenize([line])))
     self.assertIsInstance(token, block_token.ThematicBreak)
Exemple #5
0
 def test_heading_in_paragraph(self):
     lines = ['foo\n', '# heading\n', 'bar\n']
     token1, token2, token3 = block_token.tokenize(lines)
     self.assertIsInstance(token1, block_token.Paragraph)
     self.assertIsInstance(token2, block_token.Heading)
     self.assertIsInstance(token3, block_token.Paragraph)
Exemple #6
0
 def test_not_easy_table(self):
     lines = ['not header 1 | not header 2\n', 'foo | bar\n']
     token, = block_token.tokenize(lines)
     self.assertIsInstance(token, block_token.Paragraph)
Exemple #7
0
 def test_sublist(self):
     lines = ['- foo\n', '  + bar\n']
     token, = block_token.tokenize(lines)
     self.assertIsInstance(token, block_token.List)
Exemple #8
0
 def test_tight_list(self):
     lines = ['- foo\n', '\n', '# bar\n']
     f = FileWrapper(lines)
     list_item = block_token.tokenize(lines)[0].children[0]
     self.assertEqual(list_item.loose, False)
Exemple #9
0
 def test_sublist(self):
     lines = ['- foo\n', '  - bar\n']
     token1, token2 = block_token.tokenize(lines)[0].children[0].children
     self.assertIsInstance(token1, block_token.Paragraph)
     self.assertIsInstance(token2, block_token.List)
 def test_block(self):
     lines = ['<p>a paragraph\n', 'within an html block\n', '</p>\n']
     token = next(tokenize(lines))
     content = '<p>a paragraph\nwithin an html block\n</p>\n'
     self._test_html_token(token, html_token.HTMLBlock, content)