diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 2c00015..bf1d98d 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -3,6 +3,7 @@ import re convert_heading_re = re.compile(r'convert_h(\d+)') +line_beginning_re = re.compile(r'^', re.MULTILINE) whitespace_re = re.compile(r'[\r\n\s\t ]+') @@ -79,6 +80,9 @@ class MarkdownConverter(object): def convert_b(self, el): return self.convert_strong(el) + def convert_blockquote(self, el): + return line_beginning_re.sub('> ', el.text) if el.text else '' + def convert_br(self, el): return ' \n' diff --git a/tests.py b/tests.py index d62627a..519998b 100644 --- a/tests.py +++ b/tests.py @@ -37,6 +37,9 @@ class ConversionTests(unittest.TestCase): def test_b(self): self.assertEqual(md('Hello'), '**Hello**') + def test_blockquote(self): + self.assertEqual(md('
Hello
'), '> Hello') + def test_br(self): self.assertEqual(md('a
b
c'), 'a \nb \nc')