Added a SP element for outputting unprocessed code.
authorFredrik Tolf <fredrik@dolda2000.com>
Sun, 20 May 2012 23:04:10 +0000 (01:04 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Sun, 20 May 2012 23:04:10 +0000 (01:04 +0200)
wrw/sp/cons.py
wrw/sp/util.py

index 5341b20..9df4725 100644 (file)
@@ -9,6 +9,10 @@ class text(node, unicode):
     def __todom__(self, doc):
         return doc.createTextNode(self)
 
+class raw(node, unicode):
+    def __todom__(self, doc):
+        raise Exception("Cannot convert raw code to DOM objects")
+
 class element(node):
     def __init__(self, ns, name, ctx):
         self.ns = ns
index f387f1c..a913e74 100644 (file)
@@ -44,6 +44,9 @@ class formatter(object):
     def text(self, el):
         self.quotewrite(el)
 
+    def rawcode(self, el):
+        self.write(el)
+
     def attrval(self, buf):
         qc, qt = (u"'", u"&apos;") if u'"' in buf else (u'"', u"&quot;")
         self.write(qc)
@@ -112,6 +115,8 @@ class formatter(object):
             self.element(el)
         elif isinstance(el, cons.text):
             self.text(el)
+        elif isinstance(el, cons.raw):
+            self.rawcode(el)
         else:
             raise Exception("Unknown object in element tree: " + el)