Commits

Aram Dulyan committed 2ae1156

Now closing image tags properly, and avoiding empty alt text.

  • Participants
  • Parent commits 02f9cdf

Comments (0)

Files changed (1)

File html2textile.py

             newline = ''
             
         elif tag == 'img':
-            if 'alt' in attrib:
-                new_tag = ' !%s(%s)' % (attrib.get('src'), attrib.get('title'),)
+            alt = ''
+            if 'alt' in attrib and attrib['alt']:
+                alt = attrib['alt']
+            elif 'title' in attrib and attrib['title']:
+                alt = attrib['title']
+            if alt:
+                new_tag = ' !%s(%s)!' % (attrib.get('src'), alt,)
             else:
-                new_tag = ' !%s' % attrib.get('src')
+                new_tag = ' !%s!' % attrib.get('src')
             newline = ''
             
         elif tag in ('ul', 'ol'):
                 self.haystack = []            
             self.final_output.append(textilized)
             self.block = False
-        elif tag == 'img':
-            self.final_output.append('!')
         elif tag == 'ul':
             self.ul_ident -= 1
             self.list_types.pop()