From 41170825eb09fcf3b3c69c9812073727ee8a2b4e Mon Sep 17 00:00:00 2001 From: Brett Parker Date: Fri, 21 Dec 2007 19:14:29 +0000 Subject: [PATCH 1/1] Refactor
handling code so that there's no duplication --- rss2maildir.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/rss2maildir.py b/rss2maildir.py index 931de3a..25ddb3c 100755 --- a/rss2maildir.py +++ b/rss2maildir.py @@ -88,23 +88,7 @@ class HTML2Text(HTMLParser): elif tag.lower() == "a": self.inlink = True elif tag.lower() == "br": - if self.inparagraph: - self.text = self.text \ - + u'\n'.join( \ - textwrap.wrap(self.currentparagraph, 70)) \ - + u'\n' - self.currentparagraph = "" - elif self.inblockquote: - self.text = self.text \ - + u'\n> ' \ - + u'\n> '.join( \ - [a.strip() \ - for a in textwrap.wrap(self.blockquote, 68) \ - ]) \ - + u'\n' - self.blockquote = u'' - else: - self.text = self.text + u'\n' + self.handle_br() elif tag.lower() == "blockquote": self.inblockquote = True self.text = self.text + u'\n' @@ -139,6 +123,9 @@ class HTML2Text(HTMLParser): def handle_startendtag(self, tag, attrs): if tag.lower() == "br": + self.handle_br() + + def handle_br(self): if self.inparagraph: self.text = self.text \ + u'\n'.join( \ -- 2.39.5