self.start(el)
elif ev == "$":
self.end(el)
- def next(self):
+
- ret = str(self.buf)
- self.buf[:] = ""
++ def __next__(self):
+ if self.src is None:
+ raise StopIteration()
+ try:
+ ev, el = next(self.src)
+ except StopIteration:
+ self.src = None
+ ev, el = "$", None
+ self.handle(ev, el)
+ ret = bytes(self.buf)
+ self.buf[:] = b""
return ret
def nsname(self, el):
self.atbreak = True
self.inline = False
self.stack = []
+ self.last = None, None
def write(self, text):
- lines = text.split(u"\n")
+ lines = text.split("\n")
if len(lines) > 1:
for ln in lines[:-1]:
self.buf.extend(ln.encode(self.charset))
def end(self, el):
self.br()
- super(indenter, self).handle(ev, el)
+ def handle(self, ev, el):
++ super().handle(ev, el)
+ self.last = ev, el
+
class textindenter(indenter):
maxcol = 70
return head
class htmlformatter(util.formatter):
- allowshort = set([u"br", u"hr", u"img", u"input", u"meta", u"link"])
+ allowshort = {"br", "hr", "img", "input", "meta", "link"}
def shorttag(self, el):
if el.name in self.allowshort:
- super(htmlformatter, self).shorttag(el)
+ super().shorttag(el)
else:
- self.starttag(el)
- self.endtag(el)
+ self.handle(">", el)
+ self.handle("<", el)
class htmlindenter(util.textindenter, htmlformatter):
pass