GitHub 在 Markdown 文件中应用颜色

Applying color in a Markdown file on GitHub

我可以用某种方式给 Markdown 内容上色吗?

我将它放在 GitHub 的要点中,想知道我是否可以通过某种方式为我的 .md 文件中的特定部分着色。我很确定 .md 文件确实支持一些 HTML,但我不完全确定。如果它确实支持使用 HTML 着色,那将如何完成?如果是这样,我也可以更改字体吗?

Markdown 不支持着色,尽管它支持 HTML。您可以使用 diff.

创建 red/green 文本
````diff
+ Green Text
- Red Text

您还可以使用 Unicode 创建彩色表情符号 Link

一般来说,您可以在 Markdown 中包含任意 HTML,但不能保证渲染器会全部遵守。例如:

Hi here is some text <span style="color: red">this is red</span>.

在 SO 上呈现为:

Hi here is some text this is red.

虽然包含了所有文本,但跨度被完全删除:

<p>Hi here is some text this is red.</p>

同样,看起来 GitHub 去掉了样式(它是 "sanitized, aggressively" - it leaves the span, at least, but removes the style attribute, see Gist):

<p>Hi here is some text <span>this is red</span>.</p>