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

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 ↩︎

1 „Gefällt mir“