Syntax-Highlighting wird beim Kopieren und Einfügen an Orte, die farbigen Text unterstützen, nicht übernommen

Als ich das Folgende von Discourse in meinen E-Mail-Client kopierte:

@@ -1,11 +1,11 @@
-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
+The Young Volunteer Award celebrates young volunteers, aged 16–24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
 
 Do you know a young person who:
 
-Has been volunteering with Neighbourhood Watch and making a positive impact in their community.
+• Has been volunteering with Neighbourhood Watch and making a positive impact in their community?
 
-Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)
+• Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)?
 
-Held fundraising activities with their school or college or have organised litter picks or other local events.
+• Held fundraising activities with their school or college or have organised litter picks or other local events?
 
-You think this young volunteer deserves to be recognised for their hard work and commitment to their community.
+If so, do you think this young volunteer deserves to be recognised for their hard work and commitment to their community?

…wurde die Farbkodierung nicht übernommen.

Hast du diff verwendet? Vielleicht unterstützt dein E-Mail-Client es nicht?

- hier ist etwas Text
+ hier ist noch mehr Text

@Lilly, ja. Die Angabe von diff ist erforderlich, damit die Farbcodierung in Discourse korrekt dargestellt wird:

  1. ```
    @@ -1,11 +1,11 @@
    -Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
    +The Young Volunteer Award celebrates young volunteers, aged 16–24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
     
     Do you know a young person who:
     
    -Has been volunteering with Neighbourhood Watch and making a positive impact in their community.
    +• Has been volunteering with Neighbourhood Watch and making a positive impact in their community?
     
    -Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)
    +• Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)?
     
    -Held fundraising activities with their school or college or have organised litter picks or other local events.
    +• Held fundraising activities with their school or college or have organised litter picks or other local events?
     
    -You think this young volunteer deserves to be recognised for their hard work and commitment to their community.
    +If so, do you think this young volunteer deserves to be recognised for their hard work and commitment to their community?
    ```
    
  2. @@ -1,11 +1,11 @@
    -Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
    +The Young Volunteer Award celebrates young volunteers, aged 16–24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
     
     Do you know a young person who:
     
    -Has been volunteering with Neighbourhood Watch and making a positive impact in their community.
    +• Has been volunteering with Neighbourhood Watch and making a positive impact in their community?
     
    -Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)
    +• Gives up their time to support their local community (foodbanks, community hubs and groups, homeless, faith groups)?
     
    -Held fundraising activities with their school or college or have organised litter picks or other local events.
    +• Held fundraising activities with their school or college or have organised litter picks or other local events?
     
    -You think this young volunteer deserves to be recognised for their hard work and commitment to their community.
    +If so, do you think this young volunteer deserves to be recognised for their hard work and commitment to their community?
    

Beziehen Sie sich darauf, dass ich CommonMark in meinem Client verfasst habe?

Falls ja, wäre dies eine Angelegenheit für einen anderen Bereich:

Stattdessen beziehe ich mich auf das direkte Kopieren aus dem gerenderten Markup hier, wie zum Beispiel:

Ja, das weiß ich offensichtlich, deshalb habe ich dich gefragt.

@Lilly, du kannst in /1 sehen, dass ich es jedoch verwendet habe.

Oh, entschuldigung, ich dachte zunächst, das wäre ein Screenshot.

1 „Gefällt mir“

Heute hängt es davon ab, wie Sie kopieren.

Mit dem Kopier-Button:

werden unter anderem nur die Textversion in die Zwischenablage kopiert:

TIMESTAMP,TARGETS,SAVE_TARGETS,MULTIPLE,UTF8_STRING,STRING,TEXT,text/plain,text/plain;charset=utf-8,chromium/x-internal-source-rfh-token,chromium/x-source-url

Das direkte Kopieren des eigentlichen Textes funktioniert jedoch:

Da Sie den gerenderten HTML-Code über den Browser kopieren, anstatt dass Discourse mit der Zwischenablage interagiert, steht text/html als Format für Zwischenablagen-Empfänger zur Verfügung:

<span class="hljs-meta" style="color: rgb(133, 133, 133); font-style: italic; font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">@@ -1,11 +1,11 @@</span><span style="color: rgb(199, 199, 199); font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-style: normal; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; background-color: rgba(0, 0, 0, 0.25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">\n</span><span class="hljs-deletion" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(79, 24, 11); color: rgb(222, 113, 118); font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-style: normal; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.</span><span style="color: rgb(199, 199, 199); font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-style: normal; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; background-color: rgba(0, 0, 0, 0.25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">\n</span><span class="hljs-addition" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(11, 66, 32); color: rgb(118, 196, 144); font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-style: normal; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">+The Young Volunteer Award celebrates young volunteers, aged 16–24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.</span><span style="color: rgb(199, 199, 199); font-family: &quot;JetBrains Mono&quot;, Consolas, Monaco, monospace; font-size: 15.75px; font-style: normal; font-variant-ligatures: none; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; background-color: rgba(0, 0, 0, 0.25); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">\n</span><br class="Apple-interchange-newline">

Um dies über den Kopier-Button zu unterstützen, müssten wir die Möglichkeit hinzufügen, die gerenderte, farbig hervorgehobene Version (da sie durch eine Bibliothek eingefärbt wird) zu übernehmen und im text/html-Format in die Zwischenablage zu senden. Das ist wahrscheinlich möglich (vielleicht sogar als Theme-Komponente), aber bis dahin gibt es immer die Option, durch Markieren zu kopieren.

3 „Gefällt mir“

@supermathie, danke. Dann scheint das Problem mein Client zu sein (protonMail/webClients, 5.0.115.3 β):

Screencast20260522180439

Allerdings lässt sich die Farbgebung auch nicht in thunderbird-149.0.1-2.fc44 duplizieren, obwohl sie bei dir offenbar funktioniert:

Hast du eine Idee, was du eventuell anders machst?

Wenn du in ProtonMail kopierst, da es ein Webclient ist, sieht es so aus, als würde die reine Textversion verwendet. Beachte das Fehlen von Formatierungsunterscheidungen, obwohl es schwer zu erkennen ist, da du Schriftarten überschreibst.

Im Vergleich zum Einfügen in Thunderbird:

Es werden einige der Formatierungen übernommen, aber nicht alle.

Wenn ich kopiere, wird alles übernommen:

Um das herauszufinden, musst du wahrscheinlich unterscheiden, ob:

  • nicht alle Stile kopiert werden
  • nicht alle Stile eingefügt werden

Der Start mit einem sauberen Browser ohne Erweiterungen könnte helfen, das herauszufinden? Zum Beispiel erhalte ich, wenn ich einen privaten Browser ohne Erweiterungen usw. verwende:

Dieses Skript, das ich geschrieben habe, gibt dir auch Einblick in die Zwischenablage, was helfen könnte.

(oder vielleicht Arch » Fedora :face_with_tongue:)

1 „Gefällt mir“

@supermathie, das liegt daran, dass das Standard-Stylesheet von ProtonMail schrecklich ist.

Gemäß deiner Anleitung habe ich festgestellt, dass Firefox selbst (nicht einmal mein Profil, da das Problem auch bei einem neuen Eintrag in about:profiles auftritt) beim Kopieren versagt:

Ich bin sehr dankbar!

Ja genau! Ich erlebe das gleiche Verhalten.

Und streng genommen ist es kein Fehler. Firefox kopiert das HTML exakt so, wie angefordert:

<meta http-equiv="content-type" content="text/html; charset=utf-8">
<p dir="auto">Als ich den untenstehenden Text von Discourse in meinen E-Mail-Client kopierte:</p>
<pre data-code-wrap="diff" dir="auto" class="codeblock-buttons">
		<div class="codeblock-button-wrapper" style="right: 0px;"></div>
		<code class="lang-diff hljs language-diff" data-highlighted="yes">
			<span class="hljs-meta">@@ -1,11 +1,11 @@</span>
			<span class="hljs-deletion">-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.</span>
			<span class="hljs-addition">+The Young Volunteer Award celebrates young volunteers, aged 16–24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.</span>
		</code>
	</pre>

Der resultierende Unterschied nach dem Einfügen kommt daher, dass Chromium die Stile inline anwendet, während Firefox das nicht tut. Die Reduktion auf eine einzelne Zeile macht deutlich[1], was vor sich geht:

<span
  class="hljs-deletion">
-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
</span>
<span
  class="hljs-deletion"
  style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 224, 224); color: rgb(192, 45, 46);">
-Young volunteer award – celebrating young volunteers, aged 16-24, who go the extra mile in their local communities, demonstrating our values and the importance of connection and action.
</span>

(Zeilenumbrüche hinzugefügt)

Chromium fügt aus class="hljs-deletion" das Inline-CSS style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 224, 224); color: rgb(192, 45, 46);" zum Span hinzu, da das Ziel, in das eingefügt wird, diesen Stil wahrscheinlich nicht besitzt.


  1. heh ↩︎