Commits

Luke Plant  committed 24ef2b9

Remove spans in clean HTML

  • Participants
  • Parent commits e92f5d0

Comments (0)

Files changed (2)

File semanticeditor/tests.py

 
     def test_existing_divs(self):
         html = "<div><foo><bar><fribble><div><div>Some text <p>para</p> some more</div><div> more <span> of </span> this stuff </div></div></fribble></bar></foo></div>"
-        outh = '<div class="row"><div><div><p><foo><bar><fribble><p>Some text para some more more <span> of </span> this stuff </p></fribble></bar></foo></p></div></div></div>'
+        outh = '<div class="row"><div><div><p><foo><bar><fribble><p>Some text para some more more  of  this stuff </p></fribble></bar></foo></p></div></div></div>'
         self.assertEqual(outh, format_html(html, {}))
 
     def test_add_css_classes(self):
     def test_p_in_li(self):
         self.assertEqualClean("<ul><li><p>An item</p></li></ul>",
                               "<ul><li>An item</li></ul>")
+
+    def test_remove_span(self):
+        self.assertEqualClean("<p>Some <span>text</span> with a silly span</p>",
+                              "<p>Some text with a silly span</p>")

File semanticeditor/utils/presentation.py

         except KeyError:
             pass
 
-def _replace_with_children(e):
-    e.replaceWith(e.find('*'))
-
 def _empty_text(x):
     return x is None or x.strip() == ""
 
     doc('style').remove()
     doc('col').remove()
 
-    for x in ['table', 'tbody', 'thead', 'tr', 'td']:
-        doc(x).each(_replace_with_children)
-
     def pull_up(n):
         p = get_parent(body, n)
         i = get_index(p, n)
         eliminate_tag(p, i)
 
-    for n in doc('li p:only-child'):
-        pull_up(n)
+    for x in ['table', 'tbody', 'thead', 'tr', 'td', 'span', 'li p:only-child']:
+        for n in doc(x):
+            pull_up(n)
 
     doc('br + br').remove()
     doc('p + br').remove()