Ver código fonte

Strip self-closing tags correctly.

tags/v0.3
Ben Kurtovic 11 anos atrás
pai
commit
7a4b1625d3
2 arquivos alterados com 3 adições e 1 exclusões
  1. +1
    -1
      mwparserfromhell/nodes/tag.py
  2. +2
    -0
      tests/test_tag.py

+ 1
- 1
mwparserfromhell/nodes/tag.py Ver arquivo

@@ -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 Ver arquivo

@@ -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__()"""


Carregando…
Cancelar
Salvar