==================
Tweaking HTML text
==================

  >>> from cybertools.util.html import sanitize, stripComments

  >>> input = """<html>
  ... <p class="standard" style="font-size: 200%; font-weight: bold">
  ...   <a href="blubb"><b>Text</b>, and more</a>
  ... </p>
  ... </html>"""

Sanitize HTML
-------------

  >>> sanitize(input, validAttrs=['style'])
  '\n<p style="font-weight: bold">\n<a><b>Text</b>, and more</a>\n</p>\n'

  >>> sanitize(input, ['p', 'b'], ['class'])
  '\n<p class="standard">\n<b>Text</b>, and more\n</p>\n'

All comments are stripped from the HTML input.

  >>> input2 = """<html>
  ... <p>text</p>
  ... <!-- comment -->
  ... <p>text</p>"""

  >>> sanitize(input2)
  '\n<p>text</p>\n\n<p>text</p>'

It's also possible to remove only the comments from the HTML input.

  >>> stripComments(input2)
  '<html>\n<body><p>text</p>\n\n<p>text</p></body></html>' 

It is also possible to strip all HTML tags from the input string.

  >>> from cybertools.util.html import stripAll
  >>> stripAll(input)
  'Text, and more'

Extract first part of an HTML text
----------------------------------

  >>> from cybertools.util.html import extractFirstPart

  >>> extractFirstPart(input)
  '<p>\n<a href="blubb"><b>Text</b>, and more</a>\n</p>'

  >>> extractFirstPart(input2)
  '<p>text</p>'
