X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsp%2Futil.py;h=df3e6ab349228b55e4c114d2eeedc508951eac76;hb=3b67497cb853ea7dd49f579566e5f0b60a3c97d7;hp=c9f940113cefb6971273d7fa83b40d580a7a9317;hpb=625517699b4576f727b9cd81eb7053a0bc31e9b9;p=wrw.git diff --git a/wrw/sp/util.py b/wrw/sp/util.py index c9f9401..df3e6ab 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 = ("'", "'") if '"' in buf else ('"', """) self.write(qc) @@ -95,7 +98,7 @@ class formatter(object): def endtag(self, el): self.write('') - def longtag(self, el): + def longtag(self, el, **extra): self.starttag(el, **extra) for ch in el.children: self.node(ch) @@ -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) @@ -135,6 +140,10 @@ class formatter(object): def output(cls, out, el, *args, **kw): cls(out=out, root=el, *args, **kw).start() + @classmethod + def fragment(cls, out, el, *args, **kw): + cls(out=out, root=el, *args, **kw).node(el) + def update(self, **ch): ret = type(self).__new__(type(self)) ret.__dict__.update(self.__dict__)