From d73b8d4c4d38e4e5616465e31592c2b23506d991 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Fri, 29 Jun 2012 13:40:27 -0400 Subject: [PATCH] a tag conversion --- markdownify/__init__.py | 4 ++++ tests.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 5c22c8a..d17848b 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -67,6 +67,10 @@ class MarkdownConverter(object): text = (text or '').rstrip() return '%s\n%s\n\n' % (text, pad_char * len(text)) if text else '' + def convert_a(self, el): + href = el.get('href') + return '[%s](%s)' % (el.text or '', href) if href else el.text or '' + def convert_b(self, el): return self.convert_strong(el) diff --git a/tests.py b/tests.py index 5d3e61e..719745c 100644 --- a/tests.py +++ b/tests.py @@ -19,6 +19,12 @@ class EscapeTests(unittest.TestCase): class ConversionTests(unittest.TestCase): + def test_a(self): + self.assertEqual( + md('Google'), + '[Google](http://google.com)' + ) + def test_b(self): self.assertEqual(md('Hello'), '**Hello**')