Fixing autolinks

When checking a links href and text for
equality, first un-escape the underscores
in the text -- because six escapes them.
This should fix #29.
This commit is contained in:
AlexVonB
2021-01-02 17:22:27 +01:00
parent 3544322ed2
commit 453b604096
2 changed files with 7 additions and 2 deletions

View File

@@ -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 ''