Aram Dulyan avatar Aram Dulyan committed 0c7b417

Fixed some issues with the interaction of links and simple tags when there are multiple links.

Comments (0)

Files changed (2)

             self._rstrip()
             textile = '\n\n'
         elif tag == 'a':
+            self.block = False
             title = self.a_part.get('title', None)
-            textilized = ' "%(tag_open)s%(haystack)s%(tag_close)s%(title)s":%(href)s ' % {
+            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),
                 'tag_close': ''.join(self.tags_inside_links),
                 'title': ' (%s)' % title if title else '',
                 'href': safe_url(self.a_part.get('href', ''), ' '),
             }
-            self.haystack = []         
+            self.haystack = []
+            self.tags_inside_links = []      
             self.final_output.append(textilized)
-            self.block = False
         elif tag == 'ul':
             self.ul_ident -= 1
             self.list_types.pop()
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-r"""
+"""
 Test the correct handling of whitespace around Textile mark-up:
 
 >>> convert('Some <em>emphasised</em> text.')
 <BLANKLINE>
 bq. Quoted text.
 
+Ensure links are not unnecessarily indented at the start of paragraphs.
+>>> convert('<p><a href="example.com">Link</a></p><p><a href="example.com">Link</a></p>')
+"Link":example.com
+<BLANKLINE>
+"Link":example.com
+
 
 Test line breaks:
 
 >>> convert('<p><span style="color: navy"><span><a href="example.com">Link</a></span></span></p>')
 "%Link%":example.com
 
+Test that behaviour is consistent across paragraps.
+>>> convert('<p><em><strong><a href="example.com">Link</a></strong></em></p>\
+             <p><em><strong><a href="example.com">Link</a></strong></em></p>')
+"_*Link*_":example.com
+<BLANKLINE>
+"_*Link*_":example.com
+
 
 Test classes and IDs.
 >>> convert('<p class="some_class" id="some_id">Some text.</p>')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.