Rendering of e-mail template adds unnecessary whitespace

AI-generated summary

Rendering of e-mail template adds unnecessary whitespace

A discussion was raised by vchuravy regarding an unnecessary whitespace indentation in an e-mail template. The issue arises from the <div style='margin-left: 15px'> in the HTML code, which creates an indentation that resembles a citation.

vchuravy pointed out that this is not a citation, and the indentation is unwanted. codinghorror initially thought the issue was related to the suppression of avatars in single short email notifications, but vchuravy clarified that it was due to a user request to make the mailing-list experience more mailinglist-like.

The issue was later identified by neil as a result of old code trying to indent posts, which was made obsolete by a subsequent commit. neil fixed the issue by removing the unnecessary code, and the fix was committed to the Discourse repository.

I have the following e-mail template:

%{message}

%{context}

%{respond_instructions}

Which in turn creates the following e-mail

----==_mimepart_59121ceab749e_713fcbab014f1c98278
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<p><div style='margin-left: 15px'><br>[text]</p>

<p>[text]</p>

<p></div></p>

<hr>

<p><a href="[link]">Visit Topic</a> or reply to this email to respond.</p>

<p>You are receiving this because you enabled mailing list mode.</p>

<p>To unsubscribe from these emails, <a href="[LINK]">click here</a>.</p>
----==_mimepart_59121ceab749e_713fcbab014f1c98278--

The <div style='margin-left: 15px'> creates an unnecessary whitespace indentation and seems odd in itself.

CC: @yuyichao

2개의 좋아요

I assume you are objecting to the suppression of avatar in single short email notifications? This was done to satisfy Spam Assassin rules where small emails with images are penalized.

1개의 좋아요

No, I disabled the header because a user asked for it and we wanted to make the mailing-list experience more mailinglist like :wink:

My issue is that the first paragraph is indented and that makes it look like it might be a citation (which it is not). Looking at the raw html of the e-mail there is a spurious <div style='margin-left: 15px'>.

2개의 좋아요

Oh I see @neil can you have a look?

Yeah I see the problem.

result.gsub!(/\[email-indent\]/, "<div style='margin-left: 15px'>")
result.gsub!(/\[\/email-indent\]/, "</div>")

That will create some mangled html.

3개의 좋아요

Fixed.

Looks like there was old code trying to indent posts, and it probably worked great… for two days in 2013. This commit became obsolete two days later by this commit when a custom html template was used instead of the markdown. Now we allow customized email templates to be used for HTML, which unearthed this archaeological treasure.

7개의 좋아요

archaeological “treasure”

3개의 좋아요