diff --git a/markdownify/__init__.py b/markdownify/__init__.py index b43c7d1..c2888f3 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -82,6 +82,9 @@ class MarkdownConverter(object): def convert_a(self, el, text): href = el.get('href') title = el.get('title') + if text == href and not title: + # Shortcut syntax + return '<%s>' % href title_part = ' "%s"' % title.replace('"', r'\"') if title else '' return '[%s](%s%s)' % (text or '', href, title_part) if href else text or '' diff --git a/tests/test_conversions.py b/tests/test_conversions.py index 3edb50d..12bf631 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -10,6 +10,11 @@ def test_a_with_title(): assert text == r'[Google](http://google.com "The \"Goog\"")' +def test_a_shortcut(): + text = md('http://google.com') + assert text == r'' + + def test_b(): assert md('Hello') == '**Hello**'