Commits

Aram Dulyan committed 655fe64

Ignore links that consist only of whitespace.

Comments (0)

Files changed (2)

             textile = '\n\n'
         elif tag == 'a':
             self.block = False
-            title = self.a_part.get('title', None)
-            textilized = '%(space)s"%(tag_open)s%(haystack)s%(tag_close)s%(title)s":%(href)s ' % {
-                'space': '' if self._ends_with_newline() else ' ',
-                'tag_open': ''.join(reversed(self.tags_inside_links)),
-                'haystack': ''.join(self.haystack).strip(),
-                'tag_close': ''.join(self.tags_inside_links),
-                'title': ' (%s)' % title if title else '',
-                'href': safe_url(self.a_part.get('href', ''), ' '),
-            }
+            if ''.join(self.haystack).strip():
+                title = self.a_part.get('title', None)
+                textilized = '%(space)s"%(tag_open)s%(haystack)s%(tag_close)s%(title)s":%(href)s ' % {
+                    'space': '' if self._ends_with_newline() else ' ',
+                    'tag_open': ''.join(reversed(self.tags_inside_links)),
+                    'haystack': ''.join(self.haystack).strip(),
+                    'tag_close': ''.join(self.tags_inside_links),
+                    'title': ' (%s)' % title if title else '',
+                    'href': safe_url(self.a_part.get('href', ''), ' '),
+                }
+                self.final_output.append(textilized)
             self.haystack = []
             self.tags_inside_links = []
-            self.final_output.append(textilized)
         elif tag == 'ul':
             self.ul_ident -= 1
             self.list_types.pop()
 >>> convert('<em><a href="example.com"> Link. </a></em>')
 "_Link._":example.com
 
+>>> convert('<a href="example.com">  </a>')
+<BLANKLINE>
+
 
 Test that the spacing around HTML entities is not affected.
 >>> convert('bangers &amp; mash')