gpt4 book ai didi

markdown - 如何在 Markdown 中的文本上应用颜色

转载 作者:行者123 更新时间:2023-12-03 04:01:19 24 4
gpt4 key购买 nike

我想使用 Markdown 来存储文本信息。但快速谷歌搜索显示 Markdown 不支持颜色。另外 Stack Overflow 不支持颜色。与 GitHub markdown 的情况相同。

是否有允许彩色文本的 Markdown 风格?

最佳答案

TL;DR

Markdown 不支持颜色,但您可以在 Markdown 中内联 HTML,例如:

<span style="color:blue">some *blue* text</span>.

更长的答案

原件/官方syntax rules状态(强调):

Markdown’s syntax is intended for one purpose: to be used as a format for writing for the web.

Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a publishing format; Markdown is a writing format. Thus, Markdown’s formatting syntax only addresses issues that can be conveyed in plain text.

For any markup that is not covered by Markdown’s syntax, you simply use HTML itself.

由于它不是“发布格式”,因此提供一种为文本着色的方法超出了 Markdown 的范围。也就是说,这并非不可能,因为您可以包含原始 HTML(HTML 是一种发布格式)。例如,以下 Markdown 文本(如 @scoa 在评论中建议的):

Some Markdown text with <span style="color:blue">some *blue* text</span>.

将生成以下 HTML:

<p>Some Markdown text with <span style="color:blue">some <em>blue</em> text</span>.</p>

现在,StackOverflow(可能还有 GitHub)将剥离原始 HTML(作为安全措施),因此您会丢失此处的颜色,但它应该适用于任何标准 Markdown 实现。

另一种可能性是使用最初由Markuru引入的非标准属性列表。 Markdown 的实现,后来被 few 采用others (同一想法可能有更多或略有不同的实现,例如 div and span attributes in pandoc )。在这种情况下,您可以将类分配给段落或内联元素,然后使用 CSS 为类定义颜色。但是,您绝对必须使用实际支持非标准功能的少数实现之一,并且您的文档不再可移植到其他系统。

关于markdown - 如何在 Markdown 中的文本上应用颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35465557/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com