From 71854c0c4415a456cc42e2d6aa27b279ec55f915 Mon Sep 17 00:00:00 2001
From: Waylan Limberg
Date: Thu, 7 Mar 2019 20:16:18 -0500
Subject: Add some new tests
---
tests/test_syntax/blocks/test_html_blocks.py | 310 +++++++++++++++++++++++++++
1 file changed, 310 insertions(+)
create mode 100644 tests/test_syntax/blocks/test_html_blocks.py
diff --git a/tests/test_syntax/blocks/test_html_blocks.py b/tests/test_syntax/blocks/test_html_blocks.py
new file mode 100644
index 0000000..e25d76d
--- /dev/null
+++ b/tests/test_syntax/blocks/test_html_blocks.py
@@ -0,0 +1,310 @@
+# -*- coding: utf-8 -*-
+"""
+Python Markdown
+
+A Python implementation of John Gruber's Markdown.
+
+Documentation: https://python-markdown.github.io/
+GitHub: https://github.com/Python-Markdown/markdown/
+PyPI: https://pypi.org/project/Markdown/
+
+Started by Manfred Stienstra (http://www.dwerg.net/).
+Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
+Currently maintained by Waylan Limberg (https://github.com/waylan),
+Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
+
+Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
+Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
+Copyright 2004 Manfred Stienstra (the original version)
+
+License: BSD (see LICENSE.md for details).
+"""
+
+import unittest
+from markdown.test_tools import TestCase
+
+
+class TestHTMLBlocks(TestCase):
+
+ def test_raw_paragraph(self):
+ self.assertMarkdownRenders(
+ 'A raw paragraph.
',
+ 'A raw paragraph.
'
+ )
+
+ def test_raw_skip_inline_markdown(self):
+ self.assertMarkdownRenders(
+ 'A *raw* paragraph.
',
+ 'A *raw* paragraph.
'
+ )
+
+ def test_raw_indent_one_space(self):
+ self.assertMarkdownRenders(
+ ' A *raw* paragraph.
',
+ # TODO: reevaluate. This matches strict rules and reference
+ # implementation version 1.0.1 but not 1.0.2b8.
+ 'A raw paragraph.
'
+ )
+
+ def test_raw_indent_four_spaces(self):
+ self.assertMarkdownRenders(
+ ' code block
',
+ self.dedent(
+ """
+ <p>code block</p>
+
+ """
+ )
+ )
+
+ def test_raw_span(self):
+ self.assertMarkdownRenders(
+ '*inline*',
+ 'inline
'
+ )
+
+ def test_code_span(self):
+ self.assertMarkdownRenders(
+ '`code span`',
+ '<em>code span</em>
'
+ )
+
+ def test_multiline_raw(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+
+ A raw paragraph
+ with multiple lines.
+
+ """
+ ),
+ self.dedent(
+ """
+
+ A raw paragraph
+ with multiple lines.
+
+ """
+ )
+ )
+
+ def test_blank_lines_in_raw(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+
+
+ A raw paragraph...
+
+ with many blank lines.
+
+
+ """
+ ),
+ self.dedent(
+ """
+
+
+ A raw paragraph...
+
+ with many blank lines.
+
+
+ """
+ )
+ )
+
+ def test_raw_surrounded_by_Markdown(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+ Some *Markdown* text.
+
+ *Raw* HTML.
+
+ More *Markdown* text.
+ """
+ ),
+ self.dedent(
+ """
+ Some Markdown text.
+ *Raw* HTML.
+
+ More Markdown text.
+ """
+ )
+ )
+
+ def test_raw_without_blank_lines(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+ Some *Markdown* text.
+ *Raw* HTML.
+ More *Markdown* text.
+ """
+ ),
+ # The raw gets treated as inline HTML. This follows the rules and this lib's
+ # previous behavior, but not the reference implementation. TODO: Reevaluate.
+ self.dedent(
+ """
+ Some Markdown text.
+
Raw HTML.
+ More Markdown text.
+ """
+ )
+ # The reference implementation does this instead:
+ # self.dedent(
+ # """
+ # Some Markdown text.
+ # *Raw* HTML.
+ # More Markdown text.
+ # """
+ # )
+ )
+
+ def test_raw_with_markdown_blocks(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+
+ Not a Markdown paragraph.
+
+ * Not a list item.
+ * Another non-list item.
+
+ Another non-Markdown paragraph.
+
+ """
+ ),
+ self.dedent(
+ """
+
+ Not a Markdown paragraph.
+
+ * Not a list item.
+ * Another non-list item.
+
+ Another non-Markdown paragraph.
+
+ """
+ )
+ )
+
+ # TODO: This fails. Fix it.
+ def test_adjacent_raw_blocks(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+ A raw paragraph.
+ A second raw paragraph.
+ """
+ ),
+ self.dedent(
+ """
+ A raw paragraph.
+ A second raw paragraph.
+ """
+ )
+ )
+
+ def test_adjacent_raw_blocks_with_blank_lines(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+ A raw paragraph.
+
+ A second raw paragraph.
+ """
+ ),
+ self.dedent(
+ """
+ A raw paragraph.
+
+ A second raw paragraph.
+ """
+ )
+ )
+
+ def test_nested_raw_block(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+
+ """
+ ),
+ self.dedent(
+ """
+
+ """
+ )
+ )
+
+ def test_nested_indented_raw_block(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+
+ """
+ ),
+ self.dedent(
+ """
+
+ """
+ )
+ )
+
+ def test_nested_raw_blocks(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+
+
A raw paragraph.
+
A second raw paragraph.
+
+ """
+ ),
+ self.dedent(
+ """
+
+
A raw paragraph.
+
A second raw paragraph.
+
+ """
+ )
+ )
+
+ def test_nested_raw_blocks_with_blank_lines(self):
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+
+
+
A raw paragraph.
+
+
A second raw paragraph.
+
+
+ """
+ ),
+ self.dedent(
+ """
+
+
+
A raw paragraph.
+
+
A second raw paragraph.
+
+
+ """
+ )
+ )
--
cgit v1.2.1