◆ __init__()
def __init__ |
( |
|
self, |
|
|
** |
kwargs |
|
) |
| |
Initialize HTMLSerializer
:arg inject_meta_charset: Whether or not to inject the meta charset.
Defaults to ``True``.
:arg quote_attr_values: Whether to quote attribute values that don't
require quoting per legacy browser behavior (``"legacy"``), when
required by the standard (``"spec"``), or always (``"always"``).
Defaults to ``"legacy"``.
:arg quote_char: Use given quote character for attribute quoting.
Defaults to ``"`` which will use double quotes unless attribute
value contains a double quote, in which case single quotes are
used.
:arg escape_lt_in_attrs: Whether or not to escape ``<`` in attribute
values.
Defaults to ``False``.
:arg escape_rcdata: Whether to escape characters that need to be
escaped within normal elements within rcdata elements such as
style.
Defaults to ``False``.
:arg resolve_entities: Whether to resolve named character entities that
appear in the source tree. The XML predefined entities < >
& " ' are unaffected by this setting.
Defaults to ``True``.
:arg strip_whitespace: Whether to remove semantically meaningless
whitespace. (This compresses all whitespace to a single space
except within ``pre``.)
Defaults to ``False``.
:arg minimize_boolean_attributes: Shortens boolean attributes to give
just the attribute value, for example::
<input disabled="disabled">
becomes::
<input disabled>
Defaults to ``True``.
:arg use_trailing_solidus: Includes a close-tag slash at the end of the
start tag of void elements (empty elements whose end tag is
forbidden). E.g. ``<hr/>``.
Defaults to ``False``.
:arg space_before_trailing_solidus: Places a space immediately before
the closing slash in a tag using a trailing solidus. E.g.
``<hr />``. Requires ``use_trailing_solidus=True``.
Defaults to ``True``.
:arg sanitize: Strip all unsafe or unknown constructs from output.
See :py:class:`html5lib.filters.sanitizer.Filter`.
Defaults to ``False``.
:arg omit_optional_tags: Omit start/end tags that are optional.
Defaults to ``True``.
:arg alphabetical_attributes: Reorder attributes to be in alphabetical order.
Defaults to ``False``.
◆ encode()
def encode |
( |
|
self, |
|
|
|
string |
|
) |
| |
◆ encodeStrict()
def encodeStrict |
( |
|
self, |
|
|
|
string |
|
) |
| |
◆ render()
def render |
( |
|
self, |
|
|
|
treewalker, |
|
|
|
encoding = None |
|
) |
| |
Serializes the stream from the treewalker into a string
:arg treewalker: the treewalker to serialize
:arg encoding: the string encoding to use
:returns: the serialized tree
Example:
>>> from html5lib import parse, getTreeWalker
>>> from html5lib.serializer import HTMLSerializer
>>> token_stream = parse('<html><body>Hi!</body></html>')
>>> walker = getTreeWalker('etree')
>>> serializer = HTMLSerializer(omit_optional_tags=False)
>>> serializer.render(walker(token_stream))
'<html><head></head><body>Hi!</body></html>'
◆ serialize()
def serialize |
( |
|
self, |
|
|
|
treewalker, |
|
|
|
encoding = None |
|
) |
| |
◆ serializeError()
def serializeError |
( |
|
self, |
|
|
|
data = "XXX ERROR MESSAGE NEEDED" |
|
) |
| |
◆ alphabetical_attributes
◆ encoding
◆ errors
◆ escape_lt_in_attrs
◆ escape_rcdata
◆ inject_meta_charset
◆ minimize_boolean_attributes
minimize_boolean_attributes |
|
static |
◆ omit_optional_tags
◆ options
◆ quote_attr_values
◆ quote_char
◆ resolve_entities
◆ sanitize
◆ space_before_trailing_solidus
space_before_trailing_solidus |
|
static |
◆ strict
◆ strip_whitespace
◆ use_best_quote_char
◆ use_trailing_solidus
The documentation for this class was generated from the following file:
- /home/passerat/Stage/flaskProject/venv/lib/python3.8/site-packages/pip/_vendor/html5lib/serializer.py