Merge branch 'master' into python3
authorFredrik Tolf <fredrik@dolda2000.com>
Sat, 28 Dec 2013 05:37:03 +0000 (06:37 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Sat, 28 Dec 2013 05:37:03 +0000 (06:37 +0100)
Conflicts:
wrw/sp/util.py

1  2 
wrw/sp/util.py
wrw/sp/xhtml.py

diff --cc wrw/sp/util.py
@@@ -156,8 -149,18 +149,18 @@@ class formatter(object)
              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):
@@@ -225,9 -228,10 +228,10 @@@ class indenter(formatter)
          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
  
diff --cc wrw/sp/xhtml.py
@@@ -38,13 -38,13 +38,13 @@@ def head(title=None, css=None)
      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