From 8437855e8e2e18058681a1b63c77d0ec970535cb Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sat, 28 Dec 2013 06:47:37 +0100 Subject: [PATCH] Improved indentation a bit further. --- wrw/sp/util.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wrw/sp/util.py b/wrw/sp/util.py index 02f61f0..2599206 100644 --- a/wrw/sp/util.py +++ b/wrw/sp/util.py @@ -229,6 +229,7 @@ class indenter(formatter): self.inline = False self.stack = [] self.last = None, None + self.lastendbr = True def write(self, text): lines = text.split(u"\n") @@ -262,7 +263,7 @@ class indenter(formatter): def starttag(self, el): if not self.inline: - if self.last[0] == "<" and self.last[1].name == el.name: + if self.last[0] == "<" and self.last[1].name == el.name and self.lastendbr: pass else: self.br() @@ -279,8 +280,11 @@ class indenter(formatter): def endtag(self, el): il = self.inline self.pop() - if not il: + if il or (self.last[0] == ">" and self.last[1] == el): + self.lastendbr = False + else: self.br() + self.lastendbr = True super(indenter, self).endtag(el) def start(self, el): -- 2.11.0