diff --git a/markdownify/__init__.py b/markdownify/__init__.py index f9b5f9b..1e7b787 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -237,7 +237,7 @@ def convert_blockquote(self, el, text, convert_as_inline): if convert_as_inline: return text - return '\n' + (line_beginning_re.sub('> ', text) + '\n\n') if text else '' + return '\n' + (line_beginning_re.sub('> ', text.strip()) + '\n\n') if text else '' def convert_br(self, el, text, convert_as_inline): if convert_as_inline: diff --git a/tests/test_conversions.py b/tests/test_conversions.py index b03c874..ae56837 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -52,6 +52,12 @@ def test_b_spaces(): def test_blockquote(): assert md('
Hello
') == '\n> Hello\n\n' + assert md('
\nHello\n
') == '\n> Hello\n\n' + + +def test_blockquote_with_nested_paragraph(): + assert md('

Hello

') == '\n> Hello\n\n' + assert md('

Hello

Hello again

') == '\n> Hello\n> \n> Hello again\n\n' def test_blockquote_with_paragraph(): @@ -60,7 +66,7 @@ def test_blockquote_with_paragraph(): def test_blockquote_nested(): text = md('
And she was like
Hello
') - assert text == '\n> And she was like \n> > Hello\n> \n> \n\n' + assert text == '\n> And she was like \n> > Hello\n\n' def test_br():