Commits

Aram Dulyan committed 60e1545

Empty class/style/lang/id attributes no longer leave empty parentheses around.

Comments (0)

Files changed (2)

         new_tag = None
         newline = '\n'
         dot = ''
-        if 'style' in attrib:
+        if 'style' in attrib and attrib['style']:
             style_value = '{%s}' % attrib['style']
         else:
             style_value = ''
         
         class_value = ''
         class_values = []
-        if 'class' in attrib:
+        if 'class' in attrib and attrib['class']:
             class_values += [attrib['class']]
 
-        if 'id' in attrib:
+        if 'id' in attrib and attrib['id']:
             class_values += ['#%s' % attrib['id']]
         
         if class_values:
             class_value = '(%s)' % ' '.join(class_values)
             
-        if 'lang' in attrib:
+        if 'lang' in attrib and attrib['lang']:
             lang_value = '[%s]' % attrib['lang']
         else:
             lang_value = ''
 >>> convert('<address id="some_id" class="some_class">Some text.</address>')
 Some text.
 
+Test that empty string attributes are correctly ignored
+>>> convert('<span class="" style="" lang="">Text.</span>')
+%Text.%
+
 
 Test that images are handled correctly: