From 11ca698139e046fa350cedaf688e7f34d7df405d Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 12 Mar 2023 19:40:37 +0100 Subject: [PATCH] allow generated html being rendered in dark mode `` is a hint to the browsers that the page can be rendered in light as well as in dark mode and that the browser can apply corresponding defaults. as we do not add css colors on our own, this is sufficient for letting generated html messasge being rendered in dark mode. cmp. https://drafts.csswg.org/css-color-adjust/#color-scheme-prop closes #4146 --- CHANGELOG.md | 1 + src/html.rs | 20 ++++++++++++++++---- src/plaintext.rs | 44 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50731518e..750db29b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Changes - Drop unused SQL columns #4141 - "full message view" not needed because of footers that go to contact status #4151 +- Pick up system's light/dark mode in generated message HTML #4150 ## 1.111.0 diff --git a/src/html.rs b/src/html.rs index b4dbd32e7..a76214bc6 100644 --- a/src/html.rs +++ b/src/html.rs @@ -292,7 +292,10 @@ mod tests { assert_eq!( parser.html, r##" - + + + + This message does not have Content-Type nor Subject.

@@ -308,7 +311,10 @@ This message does not have Content-Type nor Subject.
assert_eq!( parser.html, r##" - + + + + message with a non-UTF-8 encoding: äöüßÄÖÜ

@@ -325,7 +331,10 @@ message with a non-UTF-8 encoding: äöüßÄÖÜ
assert_eq!( parser.html, r##" - + + + + This line ends with a space and will be merged with the next one due to format=flowed.

This line does not end with a space
@@ -344,7 +353,10 @@ and will be wrapped as usual.
assert_eq!( parser.html, r##" - + + + + mime-modified should not be set set as there is no html and no special stuff;
although not being a delta-message.
test some special html-characters as < > and & but also " and ' :)
diff --git a/src/plaintext.rs b/src/plaintext.rs index e50311677..2808e68a8 100644 --- a/src/plaintext.rs +++ b/src/plaintext.rs @@ -34,8 +34,13 @@ impl PlainText { let lines = split_lines(&self.text); - let mut ret = - "\n\n".to_string(); + let mut ret = r#" + + + + +"# + .to_string(); for line in lines { let is_quote = line.starts_with('>'); @@ -118,7 +123,10 @@ http://link-at-start-of-line.org assert_eq!( html, r##" - + + + + line 1
line 2
line with https://link-mid-of-line.org and http://link-end-of-line.com/file?foo=bar%20
@@ -140,7 +148,10 @@ line with https://link-mid-of-line.org - + + + + line with <http://encapsulated.link/?foo=_bar> here!
"# @@ -158,7 +169,10 @@ line with <http://encapsulated.l assert_eq!( html, r#" - + + + + line with nohttp://no.link here
"# @@ -176,7 +190,10 @@ line with nohttp://no.link here
assert_eq!( html, r#" - + + + + just an address:
foo@bar.org another@one.de
"# @@ -194,7 +211,10 @@ just an address: foo@bar.org - + + + + line still line
>quote
>still quote
@@ -215,7 +235,10 @@ line still line
assert_eq!( html, r#" - + + + + linestill line
>quote
>still quote
@@ -236,7 +259,10 @@ linestill line
assert_eq!( html, r#" - + + + + line
still line
>quote