# -*- 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). """ from markdown.test_tools import TestCase class TestParagraphBlocks(TestCase): def test_simple_paragraph(self): self.assertMarkdownRenders( 'A simple paragraph.', '
A simple paragraph.
' ) def test_blank_line_before_paragraph(self): self.assertMarkdownRenders( '\nA paragraph preceded by a blank line.', 'A paragraph preceded by a blank line.
' ) def test_multiline_paragraph(self): self.assertMarkdownRenders( self.dedent( """ This is a paragraph on multiple lines with hard returns. """ ), self.dedent( """This is a paragraph on multiple lines with hard returns.
""" ) ) def test_paragraph_long_line(self): self.assertMarkdownRenders( 'A very long long long long long long long long long long long long long long long long long long long ' 'long long long long long long long long long long long long long paragraph on 1 line.', 'A very long long long long long long long long long long long long long long long long long long ' 'long long long long long long long long long long long long long long paragraph on 1 line.
' ) def test_2_paragraphs_long_line(self): self.assertMarkdownRenders( 'A very long long long long long long long long long long long long long long long long long long long ' 'long long long long long long long long long long long long long paragraph on 1 line.\n\n' 'A new long long long long long long long long long long long long long long long ' 'long paragraph on 1 line.', 'A very long long long long long long long long long long long long long long long long long long ' 'long long long long long long long long long long long long long long paragraph on 1 line.
\n' 'A new long long long long long long long long long long long long long long long ' 'long paragraph on 1 line.
' ) def test_consecutive_paragraphs(self): self.assertMarkdownRenders( self.dedent( """ Paragraph 1. Paragraph 2. """ ), self.dedent( """Paragraph 1.
Paragraph 2.
""" ) ) def test_consecutive_paragraphs_tab(self): self.assertMarkdownRenders( self.dedent( """ Paragraph followed by a line with a tab only. \t Paragraph after a line with a tab only. """ ), self.dedent( """Paragraph followed by a line with a tab only.
Paragraph after a line with a tab only.
""" ) ) def test_consecutive_paragraphs_space(self): self.assertMarkdownRenders( self.dedent( """ Paragraph followed by a line with a space only. Paragraph after a line with a space only. """ ), self.dedent( """Paragraph followed by a line with a space only.
Paragraph after a line with a space only.
""" ) ) def test_consecutive_multiline_paragraphs(self): self.assertMarkdownRenders( self.dedent( """ Paragraph 1, line 1. Paragraph 1, line 2. Paragraph 2, line 1. Paragraph 2, line 2. """ ), self.dedent( """Paragraph 1, line 1. Paragraph 1, line 2.
Paragraph 2, line 1. Paragraph 2, line 2.
""" ) ) def test_paragraph_leading_space(self): self.assertMarkdownRenders( ' A paragraph with 1 leading space.', 'A paragraph with 1 leading space.
' ) def test_paragraph_2_leading_spaces(self): self.assertMarkdownRenders( ' A paragraph with 2 leading spaces.', 'A paragraph with 2 leading spaces.
' ) def test_paragraph_3_leading_spaces(self): self.assertMarkdownRenders( ' A paragraph with 3 leading spaces.', 'A paragraph with 3 leading spaces.
' ) def test_paragraph_trailing_leading_space(self): self.assertMarkdownRenders( ' A paragraph with 1 trailing and 1 leading space. ', 'A paragraph with 1 trailing and 1 leading space.
' ) def test_paragraph_trailing_tab(self): self.assertMarkdownRenders( 'A paragraph with 1 trailing tab.\t', 'A paragraph with 1 trailing tab.
' ) def test_paragraphs_CR(self): self.assertMarkdownRenders( 'Paragraph 1, line 1.\rParagraph 1, line 2.\r\rParagraph 2, line 1.\rParagraph 2, line 2.\r', self.dedent( """Paragraph 1, line 1. Paragraph 1, line 2.
Paragraph 2, line 1. Paragraph 2, line 2.
""" ) ) def test_paragraphs_LF(self): self.assertMarkdownRenders( 'Paragraph 1, line 1.\nParagraph 1, line 2.\n\nParagraph 2, line 1.\nParagraph 2, line 2.\n', self.dedent( """Paragraph 1, line 1. Paragraph 1, line 2.
Paragraph 2, line 1. Paragraph 2, line 2.
""" ) ) def test_paragraphs_CR_LF(self): self.assertMarkdownRenders( 'Paragraph 1, line 1.\r\nParagraph 1, line 2.\r\n\r\nParagraph 2, line 1.\r\nParagraph 2, line 2.\r\n', self.dedent( """Paragraph 1, line 1. Paragraph 1, line 2.
Paragraph 2, line 1. Paragraph 2, line 2.
""" ) )