Code blocks in emails have empty newlines

Code blocks appear to be formatted with an empty newline between each line ONLY in the HTML portion of emails. They appear correctly on both the forum itself, and in the plain text portion of the email. This is not an email formatting / CSS problem - there is an actual newline inserted in the source ONLY in the email case.

An example: [iFFT Freeze/Scrub - #25 by toneburst - Questions - scsynth]

The original source text of the post looks like:

The formatted post on the website looks like:

The HTML email received, however, looks like:

In the source for the email, you can see that all newlines have been doubled:

4 Likes

I agree, this is tends to look quite off.

@techAPJ can you investigate?

3 Likes

I am unable to repro this on latest Discourse version.

HTML:

Text:

This might be an issue with your email client.

I still see the problem with emails sent from 2.9.0.beta1 - please ignore the rest of this if it’s been fixed since then :slight_smile:

This is not related to a specific email client - the second screenshot I posted is of the raw HTML being generated for emails. But actually, it’s more enlightening to look at the actual email content (a snippet…):

<pre style=3D"word-wrap: break-word; max-width: 694px;"><code style=3D"di=
splay: block; background-color: #f9f9f9; overflow: auto; padding: 5px;; b=
ackground-color: #f9f9f9; padding: 2px 5px;">=0D
(=0D
// This expects two keys to be defined: ~history (the list) and ~recordKe=
y (which key to record)=0D
Pdef(\keyRecorder, Pbind(=0D
	\callback, Pfunc({=0D
		|event|=0D
		event[\callback].addFunc({ // combine your record func with any previou=
s callback that was there (it's okay if its nil)=0D
			~history.add(currentEnvironment[~recordKey])=0D
		}).postln;=0D
	})=0D
));=0D
=0D

It’s clear that there are (a) ACTUAL newlines where there would be newlines in the code, and (b) =0D characters (carriage returns) at the end of every line. AFAIK all newlines inside of a <pre> are supposed to be interpreted literally, which explains the double new-lines.

I can reproduce the issue in Gmail, and by opening the HTML part of the email message directly in a browser (after replacing the quoted printable characters like =0D). This makes me curious:

  • Do you see the same (newlines plus =0D’s) when you look at the raw version of the email you posted?
  • If you do, what does the HTML source look like for the “correct” view you posted? Is your email client somehow stripping the =0D’s (or the newlines, for that matter)?

In any case, even if it’s a specific issue with Gmail, it’s probably worth at least looking into this since Gmail is by far the most common email client.