doc.appendChild(self.__todom__(doc))
return doc
+class xhtmlcontext(_cons.context):
+ attrmap = {"klass": "class"}
+
+ def addattr(self, node, k, v):
+ k = str(k)
+ super().addattr(node, self.attrmap.get(k, k), v)
+
def cons(ctx=None):
+ if ctx is None: ctx = xhtmlcontext()
return _cons.constructor(ns, htmlelement, ctx)
def head(title=None, css=None):
return head
class htmlformatter(util.formatter):
- allowshort = set(["br", "hr", "img", "input"])
+ allowshort = set(["br", "hr", "img", "input", "meta", "link"])
def element(self, el, **extra):
if el.name in self.allowshort:
- super(htmlformatter, self).element(el, **extra)
+ super().element(el, **extra)
else:
self.longtag(el, **extra)
req.ohead["Content-Type"] = "text/html; charset=utf-8"
buf = io.BytesIO()
htmlindenter.output(buf, tree, doctype=(doctype, dtd), charset="utf-8")
- return [buf.getvalue()]
+ ret = buf.getvalue()
+ req.ohead["Content-Length"] = len(ret)
+ return [ret]
def xhtmlresp(callable):
def wrapper(req):
return forreq(req, callable(req))
+ wrapper.__wrapped__ = callable
return wrapper