{ "info": { "author": "Wichert Akkerman", "author_email": "wichert@wiggy.net", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.4", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup :: HTML" ], "description": "Introduction\n============\n\nThis package contains several handy python methods to cleanup HTML markup\nor perform other common changes. The cleanup is strict enough to be able\nto clean HTML pasted from MS Word or Apple Pages. This package also contains\nintegration code for `z3c.form`_ to provide fields that automatically\nsanitize HTML on save.\n\nThe implementation is based on the ``Cleaner`` class from `lxml`_.\n\n\nCleanup routines\n================\n\nAll cleanup routines can be invoked through the single ``sanitize`` function.\nThis functions takes an input string as input and will return a cleaned up\nversion of that string. Here is a simple example::\n\n >>> from htmllaundry import sanitize\n >>> sanitize('Hello, world')\n '
Hello, world
'\n\nThe sanitize method takes an extra optional parameter with a lxml Cleaner\ninstance, which can be used to use different filtering rules. htmllaundry\nincludes three cleaners:\n\n* ``htmllaundry.cleaners.DocumentCleaner``, which is the default cleaner. This\n cleaner will allow most safe tags, while stripping out inline styles and\n insecure markup.\n\n* ``htmllaundry.cleaners.LineCleaner`` is a more strict cleaner which only\n allows a few inline elements. This is useful in places where you only\n want to accept single-line input, for example in document titles.\n\n* ``htmllaundry.cleaners.CommentCleaner`` only allows a very limited set of\n HTML elements, and is designed to be useful for user provided comments. It\n will also force all external links to open in a new browser window.\n\n\nIf you want to go all the way you can also use ``strip_markup`` to strip\nall markup from your input::\n\n >>> from htmllaundry import strip_markup\n >>> strip_markup('Hello, world')\n 'Hello, world'\n\n\nz3c.form integration\n====================\n\nIf you want to use the ``z3c.form`` integration you should use the ``z3cform``\nextra for this package::\n\n install_requires=[\n ....\n htmllaundry [z3cform]\n ...\n ],\n\nIn addition you will need to load the ZCML. In your ``configure.zcml`` add\na line like this::\n\n