diff --git a/markdownify/__init__.py b/markdownify/__init__.py
index 2cd8fc8..c2e2ec0 100644
--- a/markdownify/__init__.py
+++ b/markdownify/__init__.py
@@ -131,7 +131,8 @@ class MarkdownConverter(object):
return text
href = el.get('href')
title = el.get('title')
- if self.options['autolinks'] and text == href and not title:
+ # For the replacement see #29: text nodes underscores are escaped
+ if self.options['autolinks'] and text.replace(r'\_', '_') == href and not title:
# Shortcut syntax
return '<%s>' % href
title_part = ' "%s"' % title.replace('"', r'\"') if title else ''
diff --git a/tests/test_conversions.py b/tests/test_conversions.py
index f5fc1c2..2896322 100644
--- a/tests/test_conversions.py
+++ b/tests/test_conversions.py
@@ -34,7 +34,11 @@ def test_chomp():
def test_a():
- assert md('Google') == '[Google](http://google.com)'
+ assert md('Google') == '[Google](https://google.com)'
+ assert md('https://google.com', autolinks=False) == '[https://google.com](https://google.com)'
+ assert md('https://google.com') == ''
+ assert md('https://community.kde.org/Get_Involved') == ''
+ assert md('https://community.kde.org/Get_Involved', autolinks=False) == '[https://community.kde.org/Get\\_Involved](https://community.kde.org/Get_Involved)'
def test_a_spaces():