Watson - Html
Utility methods for dealing with HTML.
Installation
pip install watson-html
Testing
Watson can be tested with py.test. Simply activate your virtualenv and run python setup.py test
.
Contributing
If you would like to contribute to Watson, please feel free to issue a
pull request via Github with the associated tests for your code. Your
name will be added to the AUTHORS file under contributors.
Table of Contents
Reference Library
watson.html.elements
-
class
watson.html.elements.
TagMixin
(**kwargs)[source]
Simple tag mixin used for all html tags.
All keyword arguments that get passed to __init__ will be converted into
attributes for the element.
-
attributes
dict – a dictionary of attributes associated with the tag.
-
__init__
(**kwargs)[source]
-
watson.html.elements.
flatten_attributes
(attrs, keep_empty=False)[source]
Flattens attributes into a single string of key=value pairs.
Attributes are sorted alphabetically.
watson.html.entities
-
watson.html.entities.
decode
(string)[source]
Decodes html entities.
Returns: | string with html entities decoded. |
-
watson.html.entities.
encode
(string)[source]
Encodes html entities.
This is a little more full featured than html.escape, as it will
replace all charactes from codepoint2name.
Returns: | string with replaced html entities. |