From f3464a4a95d776ac14e32f8203340a9ae08795e5 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Mon, 21 May 2012 01:04:10 +0200 Subject: [PATCH] Added a SP element for outputting unprocessed code. --- wrw/sp/cons.py | 4 ++++ wrw/sp/util.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/wrw/sp/cons.py b/wrw/sp/cons.py index 5341b20..9df4725 100644 --- a/wrw/sp/cons.py +++ b/wrw/sp/cons.py @@ -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 diff --git a/wrw/sp/util.py b/wrw/sp/util.py index f387f1c..a913e74 100644 --- a/wrw/sp/util.py +++ b/wrw/sp/util.py @@ -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"'") if u'"' in buf else (u'"', u""") 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) -- 2.11.0