commit 8faa15f0c27e430b19c4137a2b523791efaeb45d
parent cfd2ab9cf0f426adc871e7db76dfdc57b33d2d8b
Author: Christoph Lohmann <20h@r-36.net>
Date: Mon, 21 Jul 2014 19:43:53 +0200
Fix html2text.
Make the old behaviour of a non-breaking body the default. This makes copy, paste and parsing the result easier.
Diffstat:
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/feedemail.py b/feedemail.py
@@ -12,12 +12,7 @@ from email.utils import formataddr, formatdate, parseaddr
from email.header import Header
import time
-import html2text as h2t
-h2t.UNICODE_SNOB = 1
-h2t.LINKS_EACH_PARAGRAPH = 0
-h2t.BODY_WIDTH = 0
-h2t.INLINE_LINKS = 0
-html2text = h2t.html2text
+import html2text
def normalizeheader(hstr):
return hstr.replace("\n", " ").strip()
@@ -26,9 +21,16 @@ def send(feed, to, smtphost="localhost", smtpport=None, ssl="False", \
user=None, password=None):
articles = feed["articles"]
+ h2t = html2text.HTML2Text()
+ h2t.body_width = 0
+ h2t.unicode_snob = 1
+ h2t.escape_snob = 1
+ h2t.inline_links = 0
+ h2t.links_each_paragraph = 0
+
for article in articles:
if "text" in article:
- text = "%s\n" % (html2text(article["text"]))
+ text = "%s\n" % (h2t.handle(article["text"]))
else:
text = ""