# 复制粘贴到支持彩色文本的地方时，语法高亮不会被复制

**URL:** <https://meta.discourse.org/t/syntax-highlighting-when-copying-and-pasting-to-somewhere-that-supports-coloured-text-is-not-copied/403639>\
**Category:** Feature\
**Tags:** markdown\
**Created:** [2026年五月22日 16:06 UTC](https://meta.discourse.org/t/syntax-highlighting-when-copying-and-pasting-to-somewhere-that-supports-coloured-text-is-not-copied/403639 "2026-05-22T16:06:29Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)\
**Post date:** [2026年五月22日 18:34 UTC](https://meta.discourse.org/t/syntax-highlighting-when-copying-and-pasting-to-somewhere-that-supports-coloured-text-is-not-copied/403639/11 "2026-05-22T18:34:30Z")

</div>

> [@rokejulianlockhart](#):
>
> Firefox 本身

没错！我也遇到了同样的行为。

严格来说，这并非一个缺陷。Firefox 只是完全按照请求复制了 HTML：

```html
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<p dir="auto">当我从 Discourse 复制以下内容到我的邮件客户端时：</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>

```

粘贴后产生的差异源于 Chromium 将样式内联，而 Firefox 则没有。将其简化为单行可以突显\[1\] 正在发生的情况：

```html
<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>

```

```html
<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>

```

（已添加换行符）

Chromium 会将来自 `class="hljs-deletion"` 的内联 CSS `style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 224, 224); color: rgb(192, 45, 46);"` 内联到 span 标签中，因为它粘贴到的目标可能没有该样式。

* * *

1. 哈哈

---

_[View the full topic](https://meta.discourse.org/t/syntax-highlighting-when-copying-and-pasting-to-somewhere-that-supports-coloured-text-is-not-copied/403639)._
