projects
/
rss2maildir.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8e58c22
)
Refactor <br /> handling code so that there's no duplication
author
Brett Parker
<iDunno@sommitrealweird.co.uk>
Fri, 21 Dec 2007 19:14:29 +0000
(19:14 +0000)
committer
Brett Parker
<iDunno@sommitrealweird.co.uk>
Fri, 21 Dec 2007 19:14:29 +0000
(19:14 +0000)
rss2maildir.py
patch
|
blob
|
history
diff --git
a/rss2maildir.py
b/rss2maildir.py
index 931de3ae5307bbae1fe860dbc3bff739c8cfb783..25ddb3c676cb8de3eb07d2502ed41d27be1087e0 100755
(executable)
--- a/
rss2maildir.py
+++ b/
rss2maildir.py
@@
-88,23
+88,7
@@
class HTML2Text(HTMLParser):
elif tag.lower() == "a":
self.inlink = True
elif tag.lower() == "br":
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'
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":
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( \
if self.inparagraph:
self.text = self.text \
+ u'\n'.join( \