From f320cf87ffa92fb0499eff1bbaf5db5c1fddf564 Mon Sep 17 00:00:00 2001 From: AlexVonB Date: Sun, 21 Feb 2021 20:53:41 +0100 Subject: [PATCH] closing #25 and #18 Adds newlines after blockquotes, allowing for paragraphs after a blockquote. Due to merging problems with @lucafrance 's code I had to quickly copy and paste their code. Thanks for the contribution! --- markdownify/__init__.py | 2 +- tests/test_conversions.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 5c008d3..c9bc9a2 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -148,7 +148,7 @@ class MarkdownConverter(object): if convert_as_inline: return text - return '\n' + line_beginning_re.sub('> ', text) if text else '' + return '\n' + (line_beginning_re.sub('> ', text) + '\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 edaefbc..a32bf65 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -75,12 +75,16 @@ def test_b_spaces(): def test_blockquote(): - assert md('
Hello
').strip() == '> Hello' + assert md('
Hello
') == '\n> Hello\n\n' + + +def test_blockquote_with_paragraph(): + assert md('
Hello

handsome

') == '\n> Hello\n\nhandsome\n\n' def test_nested_blockquote(): - text = md('
And she was like
Hello
').strip() - assert text == '> And she was like \n> > Hello' + text = md('
And she was like
Hello
') + assert text == '\n> And she was like \n> > Hello\n> \n> \n\n' def test_br():