X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsp%2Fxhtml.py;h=662c171f12bbf9228b48066dcc82f75172e849cf;hb=8d8d1f703090499006efeb51299b8a267b00aa09;hp=02e8dd666ed2656730c85688a6a3c007b6aa54e0;hpb=6dfbe755cbc3ca1e6af3842d49fb8c6adad4e6c5;p=wrw.git diff --git a/wrw/sp/xhtml.py b/wrw/sp/xhtml.py index 02e8dd6..662c171 100644 --- a/wrw/sp/xhtml.py +++ b/wrw/sp/xhtml.py @@ -14,7 +14,15 @@ class htmlelement(_cons.element): doc.appendChild(self.__todom__(doc)) return doc +class xhtmlcontext(_cons.context): + attrmap = {"klass": "class"} + + def addattr(self, node, k, v): + k = str(k) + node.attrs[self.attrmap.get(k, k)] = str(v) + def cons(ctx=None): + if ctx is None: ctx = xhtmlcontext() return _cons.constructor(ns, htmlelement, ctx) def head(title=None, css=None): @@ -30,7 +38,7 @@ 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) @@ -50,4 +58,5 @@ def forreq(req, tree): def xhtmlresp(callable): def wrapper(req): return forreq(req, callable(req)) + wrapper.__wrapped__ = callable return wrapper