* Noah Slater <nsla...@bytesexual.org>, 2008-02-05, 00:43:
I am not happy with rss2email's default html2text conversion and would
like to use elinks "--dump" feature as a find it more readable.
You can hack it yourself by appending the attached snippet to your
config.py.
--
Jakub Wilk
def custom_html2text(s):
import sys
import os
import subprocess
import tempfile
htmlfile = tempfile.NamedTemporaryFile(suffix='.html')
try:
if (isinstance(s, unicode)):
s = s.encode('UTF-8')
htmlfile.write(s)
htmlfile.flush()
elinks = subprocess.Popen(
['elinks', '-default-mime-type', 'text/html; charset=UTF-8', '-dump', '-dump-charset', 'UTF-8', htmlfile.name],
stdout=subprocess.PIPE
)
stdout, stderr = elinks.communicate()
return stdout.decode('UTF-8', 'replace')
finally:
htmlfile.close()
import html2text
html2text.html2text = custom_html2text