]> git.sommitrealweird.co.uk Git - rss2maildir.git/commitdiff
* Move some of the list handling above the paragraph handling so that it
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Mon, 31 Dec 2007 03:08:57 +0000 (03:08 +0000)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Mon, 31 Dec 2007 03:08:57 +0000 (03:08 +0000)
  doesn't get confused (bless it!)
* Make expected output match actual output, unittest now passes

rss2maildir.py
tests/expected/unorderedlist-badlyformed.txt

index 80f22d57d6f6852ed9efbf1289b03590f9845f8f..7acbe54966ae02ff2cfaaf7cd3d67bb49cb0eb09 100755 (executable)
@@ -109,7 +109,7 @@ class HTML2Text(HTMLParser):
             self.item = u''
             self.inul = True
             self.text = self.text + "\n"
-        elif tag.lower() == "li" and self.inul:
+        elif tag.lower() == "li":
             if not self.initem:
                 self.initem = True
                 self.item = u''
@@ -120,6 +120,7 @@ class HTML2Text(HTMLParser):
                         textwrap.wrap(self.item, 67)]) \
                     + u'\n'
                 self.item = u''
+                self.initem = True
 
     def handle_startendtag(self, tag, attrs):
         if tag.lower() == "br":
@@ -198,7 +199,7 @@ class HTML2Text(HTMLParser):
             self.inpre = False
         elif tag.lower() == "li":
             self.initem = False
-            if self.item != "":
+            if self.item != u'':
                 self.text = self.text \
                     + u' * ' \
                     + u'\n   '.join( \
@@ -217,12 +218,12 @@ class HTML2Text(HTMLParser):
             self.blockquote = self.blockquote \
                 + unicode(data, "utf-8").strip() \
                 + u' '
+        elif self.initem:
+            self.item = self.item + unicode(data, "utf-8")
         elif self.inparagraph:
             self.currentparagraph = self.currentparagraph \
                 + unicode(data, "utf-8").strip() \
                 + u' '
-        elif self.inul and self.initem:
-            self.item = self.item + unicode(data, "utf-8")
         elif self.inpre:
             self.text = self.text + unicode(data, "utf-8")
         else:
index 49d47f6f8dec73f23ed1f530357e6bebed78b89c..b4c04f9d123c89f964c4e141b27986f85626be8d 100644 (file)
@@ -1,3 +1,4 @@
-  * This is an item
-  * And a second
-  * And a third
+
+ * This is an item
+ * And a second
+ * And a third