X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsp%2Futil.py;h=a913e7466cc06684062c2298590362f55b300553;hb=f3464a4a95d776ac14e32f8203340a9ae08795e5;hp=96e9880c9675588ef3e9c7db5dca24ee9ea3b226;hpb=ff79cdbf7d4d95e6a84d6b002e28e6df86847954;p=wrw.git diff --git a/wrw/sp/util.py b/wrw/sp/util.py index 96e9880..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) @@ -183,18 +188,21 @@ class indenter(formatter): reind = False if not self.simple(el): sub = self.update(curind=self.curind + self.indent) - sub.out.indent(sub.curind) + sub.reindent() reind = True for ch in el.children: sub.node(ch) if reind: - self.out.indent(self.curind) + self.reindent() self.endtag(el) def element(self, el, **extra): super(indenter, self).element(el, **extra) if self.out.col > 80 and self.simple(el): - self.out.indent(self.curind) + self.reindent() + + def reindent(self): + self.out.indent(self.curind.encode(self.charset)) def start(self): super(indenter, self).start()