Code block looks wrong in e-mail w/ Thunderbird default dark colors

AI-generated summary

Users report that code blocks in emails sent via Discourse appear incorrectly in Thunderbird (68.8.1) under dark mode, showing wrong colors and no scroll functionality. 532910 provides screenshots and notes that the HTML/CSS is malformed—repeating styles like padding and background-color—and ignores user theme preferences, forcing light mode. jomaxro suggests updating Discourse; thess confirms the OpenWrt forum is on 2.5.0-beta5, but the issue persists. simon tests via Litmus and sees only minor width issues in Thunderbird, not the full problems reported. zogstrip suspects dark mode is the culprit. 532910 clarifies Thunderbird uses Gecko and should resemble Firefox 76.0.1, where rendering is fine. They note emails from Discourse Meta look correct (but white), while locally installed 2.5.0-beta5 emails look bad. After zogstrip sends a test code block, 532910 confirms the content is readable but still lacks proper theme integration and scrolling. The issue is deemed complex, tied to email client rendering and CSS handling, not solely a Discourse bug. codinghorror notes it’s indirectly a Discourse issue and references recent testing by Simon using Litmus.

  1. wrong colors
  2. no scroll

I know we’ve had a few email format related fixes in the last few days, first suggestion would be to update the site.

I don’t maintain OpenWrt’s discourse but can ask the administrator if these fixes were released, weren’t they?

Yep, reach out to the admin. They should be able to run an upgrade.

We are already on 2.5.0.beta4 with the OpenWrt forum.
To which discourse version should we update?

You may be updating within the same version, just ensure you are running the lastest code.

@532910 Site updated to 2.5.0-beta5. That’s the best I can do now.

/ted (OpenWrt - sysadmin)

2.5.0-beta5 has the same issue

I believe this is quite a complex email specific HTML and CSS issue which depends on the email client, so it’s only indirectly a Discourse issue, I know @simon looked at this very recently as well using the Litmus email testing system.

I’m testing this with the same version.

When I send test emails with codeblocks to Litmus, I’m not seeing the problems that are in the initial post in this topic. For long blocks of code, the full code block is displayed. I am seeing a small issue with the background color of codeblocks not extending the full width of the code on the Thunderbird email client, but the code is still legible:

What email client are you using to read the emails? Have any customizations been made to the email template or CSS that can be edited from the site’s Admin / Customize / Email Style section?

Looks like OP is using dark mode? Maybe that’s the issue?

This is Thunderbird 68.8.1 from debian sid, I believe it uses gecko and the content should look similar to firefox 76.0.1 where it looks fine.

The style for this html violates that both fg and bg colors should be defined together and relies on common default: black_fg/white_bg:

<div style="padding-top:5px;"><pre style="word-wrap: break-word; max-width: 694px;"><code style="display: block; background-color: #f1f1ff; padding: 5px;; background-color: #f1f1ff; padding: 2px 5px;">

(BTW, Why it’s so sloppy? padding and background-color are repeated twice.)

Moreover looks like it ignores my discourse-user preferences, tb style and tries to display this in light mode.

Just noticed, that mails from Discourse Meta looks pretty good, but they are white. (While messages from 2.5.0-beta5 that I’ve just installed locally looks bad.)

Could someone reply here with a long-line code block to how it will look on my side, please.

Here’s a long line block :wink:

<div style="padding-top:5px;"><pre style="word-wrap: break-word; max-width: 694px;"><code style="display: block; background-color: #f1f1ff; padding: 5px;; background-color: #f1f1ff; padding: 2px 5px;">

Looks good, except theme and scrolling: