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**')