Skip to content

Commit 1504ab0

Browse files
committed
Add documentation for serializer options. Resolves issue html5lib#150, based upon patch by fantasai.
1 parent 8873786 commit 1504ab0

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

html5lib/serializer/htmlserializer.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,49 @@ class HTMLSerializer(object):
9999
"escape_rcdata", "resolve_entities", "sanitize")
100100

101101
def __init__(self, **kwargs):
102+
"""Initialize HTMLSerializer.
103+
104+
Keyword options (default given first unless specified) include:
105+
106+
inject_meta_charset=True|False
107+
Whether it insert a meta element to define the character set of the
108+
document.
109+
quote_attr_values=True|False
110+
Whether to quote attribute values that don't require quoting
111+
per HTML5 parsing rules.
112+
quote_char=u'"'|u"'"
113+
Use given quote character for attribute quoting. Default is to
114+
use double quote unless attribute value contains a double quote,
115+
in which case single quotes are used instead.
116+
escape_lt_in_attrs=False|True
117+
Whether to escape < in attribute values.
118+
escape_rcdata=False|True
119+
Whether to escape characters that need to be escaped within normal
120+
elements within rcdata elements such as style.
121+
resolve_entities=True|False
122+
Whether to resolve named character entities that appear in the
123+
source tree. The XML predefined entities &lt; &gt; &amp; &quot; &apos;
124+
are unaffected by this setting.
125+
strip_whitespace=False|True
126+
Whether to remove semantically meaningless whitespace. (This
127+
compresses all whitespace to a single space except within pre.)
128+
minimize_boolean_attributes=True|False
129+
Shortens boolean attributes to give just the attribute value,
130+
for example <input disabled="disabled"> becomes <input disabled>.
131+
use_trailing_solidus=False|True
132+
Includes a close-tag slash at the end of the start tag of void
133+
elements (empty elements whose end tag is forbidden). E.g. <hr/>.
134+
space_before_trailing_solidus=True|False
135+
Places a space immediately before the closing slash in a tag
136+
using a trailing solidus. E.g. <hr />. Requires use_trailing_solidus.
137+
sanitize=False|True
138+
Strip all unsafe or unknown constructs from output.
139+
See `html5lib user documentation`_
140+
omit_optional_tags=True|False
141+
Omit start/end tags that are optional.
142+
143+
.. _html5lib user documentation: http://code.google.com/p/html5lib/wiki/UserDocumentation
144+
"""
102145
if kwargs.has_key('quote_char'):
103146
self.use_best_quote_char = False
104147
for attr in self.options:

0 commit comments

Comments
 (0)