From d2cd9238c819ec972957d67572ade29f9296cc22 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Mon, 11 Mar 2019 10:02:47 -0400 Subject: Round out tests of valid markup. There are some design desisions to make as noted in comments. --- tests/test_syntax/blocks/test_html_blocks.py | 234 ++++++++++++++++++++++++++- 1 file changed, 232 insertions(+), 2 deletions(-) (limited to '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 index 8c600a4..8bcdfd2 100644 --- a/tests/test_syntax/blocks/test_html_blocks.py +++ b/tests/test_syntax/blocks/test_html_blocks.py @@ -486,7 +486,18 @@ class TestHTMLBlocks(TestCase): '' ) - # TODO: Confirm this is correct + # TODO: Decide behavior here. Python-Markdown current outputs: + # + # + #

bar

+ # + # But the reference implementation outputs: + # + #

bar

+ # + # As the raw HTML is not alone on the line, the reference implementation + # considers it inline rather than block level. The behavior defined in + # the test below is from the CommonMark spec, which we don't follow. def test_raw_comment_one_line_followed_by_text(self): self.assertMarkdownRenders( '*bar*', @@ -533,4 +544,223 @@ class TestHTMLBlocks(TestCase): ) ) - # TODO: processing instruction, declaration, CDATA... + def test_raw_comment_indented(self): + self.assertMarkdownRenders( + self.dedent( + """ + + """ + ), + self.dedent( + """ + + """ + ) + ) + + def test_raw_processing_instruction_one_line(self): + self.assertMarkdownRenders( + "';' ?>", + "';' ?>" + ) + + # This is inline as it is not on a line by itself. + def test_raw_processing_instruction_one_line_followed_by_text(self): + self.assertMarkdownRenders( + "';' ?>*bar*", + "

'; ' ?>bar

" + ) + + def test_raw_multiline_processing_instruction(self): + self.assertMarkdownRenders( + self.dedent( + """ + ';' + ?> + """ + ), + self.dedent( + """ + ';' + ?> + """ + ) + ) + + def test_raw_processing_instruction_with_blank_lines(self): + self.assertMarkdownRenders( + self.dedent( + """ + ';' + + ?> + """ + ), + self.dedent( + """ + ';' + + ?> + """ + ) + ) + + def test_raw_processing_instruction_indented(self): + self.assertMarkdownRenders( + self.dedent( + """ + ';' + + ?> + """ + ), + self.dedent( + """ + ';' + + ?> + """ + ) + ) + + def test_raw_declaration_one_line(self): + self.assertMarkdownRenders( + '', + '' + ) + + # TODO: Decide correct behavior. This matches current behavior and Commonmark. + # The reference implementation considers this inline not block level: + # + #

bar

+ # + # But most implementations do this instead: + # + #

<!DOCTYPE html>bar

+ # + # Either makes sense, but the later seems more correct to me. + def test_raw_declaration_one_line_followed_by_text(self): + self.assertMarkdownRenders( + '*bar*', + '*bar*' + ) + + def test_raw_multiline_declaration(self): + self.assertMarkdownRenders( + self.dedent( + """ + + """ + ), + self.dedent( + """ + + """ + ) + ) + + def test_raw_cdata_one_line(self): + self.assertMarkdownRenders( + '"); ]]>', + '"); ]]>' + ) + + # TODO: Decide correct behavior. This matches current behavior and Commonmark. + # The reference implementation considers this inline not block level: + # + #

"); ]]>bar

+ # + # But most implementations do this instead: + # + #

<[CDATA[ document.write(“>”); ]]>bar

+ # + # Either makes sense, but the later seems more correct to me. + def test_raw_cdata_one_line_followed_by_text(self): + self.assertMarkdownRenders( + '"); ]]>*bar*', + '"); ]]>*bar*' + ) + + def test_raw_multiline_cdata(self): + self.assertMarkdownRenders( + self.dedent( + """ + "); + ]]> + """ + ), + self.dedent( + """ + "); + ]]> + """ + ) + ) + + def test_raw_cdata_with_blank_lines(self): + self.assertMarkdownRenders( + self.dedent( + """ + "); + + ]]> + """ + ), + self.dedent( + """ + "); + + ]]> + """ + ) + ) + + def test_raw_cdata_indented(self): + self.assertMarkdownRenders( + self.dedent( + """ + "); + + ]]> + """ + ), + self.dedent( + """ + "); + + ]]> + """ + ) + ) -- cgit v1.2.1