You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
490 B

12 years ago
from __future__ import absolute_import, division, unicode_literals
13 years ago
12 years ago
from .. import treewalkers
13 years ago
12 years ago
from .htmlserializer import HTMLSerializer
13 years ago
12 years ago
def serialize(input, tree="etree", format="html", encoding=None,
13 years ago
**serializer_opts):
# XXX: Should we cache this?
12 years ago
walker = treewalkers.getTreeWalker(tree)
13 years ago
if format == "html":
s = HTMLSerializer(**serializer_opts)
else:
12 years ago
raise ValueError("type must be html")
13 years ago
return s.render(walker(input), encoding)