def test_preserve_refs():
    """Test that HTML character/entity references are preserved when we strip
    tags."""
    text = u"la philologie mène au pire"
    assert strip_tags(text) == u"la philologie mène au pire"

    text = u"la philologie mène au pire"
    assert strip_tags(text) == u"la philologie mène au pire"

    text = u"veer & wander"
    assert strip_tags(text) == "veer & wander"
def test_preserve_refs():
    """Test that HTML character/entity references are preserved when we strip
    tags."""
    text = u'la philologie mène au pire'
    assert strip_tags(text) == u'la philologie mène au pire'

    text = u'la philologie mène au pire'
    assert strip_tags(text) == u'la philologie mène au pire'

    text = u'veer & wander'
    assert strip_tags(text) == 'veer & wander'
def test_strip_tags():
    text = (
        "<div><script> AAH JAVASCRIPT</script><style> AAH CSS AHH</style>"
        'check out this <a href="http://example.com">link</a> yo!</div>'
    )
    assert strip_tags(text).strip() == "check out this link yo!"

    # MS Word conditional marked section
    text = "<![if word]>content<![endif]>"

    assert strip_tags(text).strip() == "content"

    # Unknown marked section
    text = """<![FOR]>"""

    with pytest.raises(HTMLParseError):
        strip_tags(text)
Beispiel #4
0
 def calculate_html_snippet(self, text):
     text = text.replace('<br>', ' ').replace('<br/>', ' '). \
         replace('<br />', ' ')
     text = strip_tags(text)
     return self.calculate_plaintext_snippet(text)
 def calculate_html_snippet(self, text):
     text = strip_tags(text)
     return self.calculate_plaintext_snippet(text)
Beispiel #6
0
 def calculate_html_snippet(self, text):
     text = text.replace('<br>', ' ').replace('<br/>', ' '). \
         replace('<br />', ' ')
     text = strip_tags(text)
     self.calculate_plaintext_snippet(text)
Beispiel #7
0
 def calculate_html_snippet(self, text):
     text = strip_tags(text)
     return self.calculate_plaintext_snippet(text)
Beispiel #8
0
 def calculate_html_snippet(msg, text):
     text = text.replace("<br>", " ").replace("<br/>",
                                              " ").replace("<br />", " ")
     text = strip_tags(text)
     calculate_plaintext_snippet(msg, text)
Beispiel #9
0
def test_strip_tags():
    text = ('<div><script> AAH JAVASCRIPT</script><style> AAH CSS AHH</style>'
            'check out this <a href="http://example.com">link</a> yo!</div>')
    assert strip_tags(text) == 'check out this link yo!'
Beispiel #10
0
 def calculate_html_snippet(msg, text):
     text = text.replace('<br>', ' ').replace('<br/>', ' '). \
         replace('<br />', ' ')
     text = strip_tags(text)
     calculate_plaintext_snippet(msg, text)