Skip to content

Commit

Permalink
fix issue #462
Browse files Browse the repository at this point in the history
the issue was fixed in html2text
  • Loading branch information
leonardoo committed Jan 30, 2015
1 parent e484b63 commit 4b5dd73
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions userena/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,7 @@
from django.utils.translation import ugettext as _
from django.core.mail import EmailMultiAlternatives

from html2text import html2text as html2text_orig


LINK_RE = re.compile(r"https?://([^ \n]+\n)+[^ \n]+", re.MULTILINE)
def html2text(html):
"""Use html2text but repair newlines cutting urls.
Need to use this hack until
https://github.com/aaronsw/html2text/issues/#issue/7 is not fixed"""
txt = html2text_orig(html)
links = list(LINK_RE.finditer(txt))
out = StringIO()
pos = 0
for l in links:
out.write(txt[pos:l.start()])
out.write(l.group().replace('\n', ''))
pos = l.end()
out.write(txt[pos:])
return out.getvalue()
from html2text import html2text

def send_mail(subject, message_plain, message_html, email_from, email_to,
custom_headers={}, attachments=()):
Expand Down

0 comments on commit 4b5dd73

Please sign in to comment.