From 7f391f8e9afdf2b65a74b1cff2f332da2899c233 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Fri, 6 Jul 2012 21:09:48 -0400 Subject: [PATCH] blockquote tag conversion --- markdownify/__init__.py | 4 ++++ tests.py | 3 +++ 2 files changed, 7 insertions(+) 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')