Metadata-Version: 1.0
Name: htmllaundry
Version: 1.2
Summary: Simple HTML cleanup utilities
Home-page: UNKNOWN
Author: Wichert Akkerman
Author-email: wichert@wiggy.net
License: BSD
Description: Introduction
        ============
        
        This package contains several handy python methods to cleanup HTML markup
        or perform other common changes. The cleanup is strict enough to be able
        to clean HTML pasted from MS Word or Apple Pages. This package also contains
        integration code for `z3c.form`_ to provide fields that automatically
        sanitize HTML on save.
        
        The implementation is based on the ``Cleaner`` class from `lxml`_.
        
        
        Cleanup routines
        ================
        
        All cleanup routines can be invoked through the single ``sanitize`` function.
        This functions takes an input string as input and will return a cleaned up
        version of that string. Here is a simple example::
        
        >>> from htmllaundry import sanitize
        >>> sanitize('Hello, <em>world</em>')
        '<p>Hello, <em>world</em></p>'
        
        The sanitize method takes an extra optional parameter with a lxml Cleaner
        instance, which can be used to use different filtering rules. htmllaundry
        includes three cleaners:
        
        * ``htmllaundry.cleaners.DocumentCleaner``, which is the default cleaner. This
        cleaner will allow most safe tags, while stripping out inline styles and
        insecure markup.
        
        * ``htmllaundry.cleaners.LineCleaner`` is a more strict cleaner which only
        allows a few inline elements. This is useful in places where you only
        want to accept single-line input, for example in document titles.
        
        * ``htmllaundry.cleaners.CommentCleaner`` only allows a very limited set of
        HTML elements, and is designed to be useful for user provided comments.
        
        
        If you want to go all the way you can also use ``StripMarkup`` to strip
        all markup from your input::
        
        >>> from htmllaundry import StripMarkup
        >>> StripMarkup('Hello, <em>world</em>')
        'Hello, world'
        
        
        z3c.form integration
        ====================
        
        If you want to use the ``z3c.form`` integration you should use the ``z3cform``
        extra for this package::
        
        install_requires=[
        ....
        htmllaundry [z3cform]
        ...
        ],
        
        In addition you will need to load the ZCML. In your ``configure.zcml`` add
        a line like this::
        
        <include package="htmllaundry" />
        
        You can then use the `HtmlText` field type in your schemas. For example::
        
        from zope.interface import Interface
        from zope import schema
        from htmllaundry.z3cform import HtmlText
        
        class IDocument(Interface):
        title = schema.TextLine(
        title = _(u"Title"),
        required = True)
        
        description = HtmlText(
        title = _(u"Description"),
        required = True)
        
        Please note that using ``HtmlText`` will not automatically give you a WYSYWIG
        widget.
        
        
        .. _z3c.form: http://pypi.python.org/pypi/z3c.form
        .. _lxml: http://codespeak.net/lxml/
        
        
        Changelog
        =========
        
        1.2 - February 15, 2010
        -----------------------
        
        * Fix a typo in the documentation.
        
        * Strip trailing breaks.
        
        
        1.1 - February 5, 2010
        ----------------------
        
        * Add a simple StripMarkup method.
        
        * Add ZCML necessary for z3c.form integration.
        
        
        1.0 - February 5, 2010
        ----------------------
        
        * First release
        
        
Keywords: html clean
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup :: HTML
