diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 28cdaf6..e3d6810 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -442,6 +442,9 @@ def convert_a(self, el, text, parent_tags): if not text: return '' href = el.get('href') + # Escape parentheses in URLs to prevent breaking markdown link syntax + if href: + href = href.replace('(', '%28').replace(')', '%29') title = el.get('title') # For the replacement see #29: text nodes underscores are escaped if (self.options['autolinks'] diff --git a/tests/test_conversions.py b/tests/test_conversions.py index c95483c..5e02e7b 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -45,6 +45,14 @@ def test_a_in_code(): assert md('