X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsp%2Fxhtml.py;h=eb82f5736c6948e2eb1961c33177f13054b661ca;hb=cb66c33fdb75345266af29fc4063bf833100cca5;hp=662c171f12bbf9228b48066dcc82f75172e849cf;hpb=ca3dce3812e3fc65f4c021aa76ee1430b47ad3af;p=wrw.git diff --git a/wrw/sp/xhtml.py b/wrw/sp/xhtml.py index 662c171..eb82f57 100644 --- a/wrw/sp/xhtml.py +++ b/wrw/sp/xhtml.py @@ -19,7 +19,7 @@ class xhtmlcontext(_cons.context): def addattr(self, node, k, v): k = str(k) - node.attrs[self.attrmap.get(k, k)] = str(v) + super().addattr(node, self.attrmap.get(k, k), v) def cons(ctx=None): if ctx is None: ctx = xhtmlcontext() @@ -38,14 +38,15 @@ def head(title=None, css=None): return head class htmlformatter(util.formatter): - allowshort = set(["br", "hr", "img", "input", "meta", "link"]) - def element(self, el, **extra): + allowshort = {"br", "hr", "img", "input", "meta", "link"} + def shorttag(self, el): if el.name in self.allowshort: - super(htmlformatter, self).element(el, **extra) + super().shorttag(el) else: - self.longtag(el, **extra) + self.handle(">", el) + self.handle("<", el) -class htmlindenter(util.indenter, htmlformatter): +class htmlindenter(util.textindenter, htmlformatter): pass def forreq(req, tree): @@ -53,7 +54,9 @@ def forreq(req, tree): 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):