cybertools/util/html.txt
helmutm 427d043f2c add new utility module for html processing
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3567 fd906abe-77d9-0310-91a1-e0d9ade77398
2009-10-05 21:00:50 +00:00

20 lines
474 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<b>Text</b>\n</p>\n'
>>> sanitize(input, ['p', 'b'], ['class'])
u'\n<p class="standard">\n<b>Text</b>\n</p>\n'