cybertools/util/html.txt
helmutm 4157c0af04 add test for correct stripping of HTML comments
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3720 fd906abe-77d9-0310-91a1-e0d9ade77398
2010-02-09 12:58:07 +00:00

29 lines
674 B
Text

==================
Tweaking HTML text
==================
$Id$
>>> from cybertools.util.html import sanitize
>>> input = """<html>
... <p class="standard" style="font-size: 200%; font-weight: bold">
... <a href="blubb"><b>Text</b></a>
... </p>
... </html>"""
>>> sanitize(input, validAttrs=['style'])
u'\n<p style="font-weight: bold">\n<a><b>Text</b></a>\n</p>\n'
>>> sanitize(input, ['p', 'b'], ['class'])
u'\n<p class="standard">\n<b>Text</b>\n</p>\n'
All comments are stripped from the HTML input.
>>> input2 = """<html>
... <p>text</p>
... <!-- comment -->
... <p>text</p>"""
>>> sanitize(input2)
u'\n<p>text</p>\n\n<p>text</p>'