Private
Public Access
1
0

improved html tag stripping

This commit is contained in:
Sander Roosendaal
2018-12-12 10:34:12 +01:00
parent 3a06408d3f
commit 6da4c36c68
5 changed files with 17 additions and 4 deletions

View File

@@ -53,6 +53,14 @@ def textify(html):
# Strip single spaces in the beginning of each line
return text_only.replace('\n ', '\n').strip()
def htmlstripnobr(html):
safe_html = re.sub('[ \t]+', ' ', strip_tags(html))
return safe_html
def htmlstrip(html):
safe_html = re.sub('[ \t]+', ' ', strip_tags(html))
return newlinetobr(safe_html)
def newlinetobr(html):
html = html.replace('\n\n','<br>')
return html.replace('\n','<br>')
@@ -65,7 +73,7 @@ def send_template_email(from_email,to_email,subject,
html_content = htmly.render(context)
text_content = textify(html_content)
html_content = newlinetobr(html_content)
# html_content = newlinetobr(html_content)
if 'cc' in kwargs:
msg = EmailMultiAlternatives(subject, text_content, from_email, to_email,cc=kwargs['cc'])