Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email templates are in HTML, but are not sent as HTML #4

Open
JoeGermuska opened this issue Sep 7, 2023 · 0 comments
Open

Email templates are in HTML, but are not sent as HTML #4

JoeGermuska opened this issue Sep 7, 2023 · 0 comments

Comments

@JoeGermuska
Copy link
Member

The various email templates are in HTML files, but when they are sent, they are not sent in a way which that signals a receiving client to render them as HTML. There's also some code that pulls text out of <p> tags, which kind of undoes the HTML. See

weatherbot/NHC.py

Lines 322 to 324 in 54eefc2

p_tags= soup.find_all('p')
new_story= [re.sub(r'\s+', ' ', p.get_text(strip=True)) for p in p_tags if p.get_text(strip=True)]

(I also wonder if the <ul> content of some email templates comes through that process looking as we'd like it to.)

We could change the templates to be plain text, although formatting lists in ASCII is a pain; or we could use more advanced methods of the python email.message library to send the email as HTML, which is a different kind of a pain.

But if we are sending the messages as text, we should use text templates, and not HTML templates with a custom process for reducing the templates to plain text.

JoeGermuska added a commit that referenced this issue Sep 7, 2023
…edit is handled correctly and consistently for NHC as well as NWS. TODO: cleanup email template rendering, see #4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant