Merge branch 'master' into python3
[wrw.git] / wrw / sp / xhtml.py
index 02e8dd6..17c5678 100644 (file)
@@ -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)