Browse Source

Strip self-closing tags correctly.

tags/v0.3
Ben Kurtovic 10 years ago
parent
commit
7a4b1625d3
2 changed files with 3 additions and 1 deletions
  1. +1
    -1
      mwparserfromhell/nodes/tag.py
  2. +2
    -0
      tests/test_tag.py

+ 1
- 1
mwparserfromhell/nodes/tag.py View File

@@ -89,7 +89,7 @@ class Tag(Node):
yield self.closing_tag, child

def __strip__(self, normalize, collapse):
if is_visible(self.tag):
if self.contents and is_visible(self.tag):
return self.contents.strip_code(normalize, collapse)
return None



+ 2
- 0
tests/test_tag.py View File

@@ -102,10 +102,12 @@ class TestTag(TreeEqualityTestCase):
"""test Tag.__strip__()"""
node1 = Tag(wraptext("i"), wraptext("foobar"))
node2 = Tag(wraptext("math"), wraptext("foobar"))
node3 = Tag(wraptext("br"), self_closing=True)
for a in (True, False):
for b in (True, False):
self.assertEqual("foobar", node1.__strip__(a, b))
self.assertEqual(None, node2.__strip__(a, b))
self.assertEqual(None, node3.__strip__(a, b))

def test_showtree(self):
"""test Tag.__showtree__()"""


Loading…
Cancel
Save