如何在Markdown中应用颜色? [英] How to apply color in Markdown?

查看:152
本文介绍了如何在Markdown中应用颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Markdown来存储文本信息.但是快速搜索表明Markdown不支持颜色.另外,StackOverflow不支持颜色.与GitHub markdown情况相同.

I want to use Markdown to store textual information. But quick googling says Markdown does not support color. Also StackOverflow does not support color. Same as in case of GitHub markdown.

是否有允许彩色文本的降价标记?

Is there any flavor of markdown that allows colored text?

推荐答案

简短回答

Markdown不支持颜色!

Markdown doesn't support color!

TL; DR

作为原始/官方的语法规则状态(加了强调):

As the original/official syntax rules state (emphasis added):

Markdown的语法仅用于一个目的:用作网络写作的格式.

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

Markdown不能替代HTML,甚至不能替代HTML.它的语法非常小,仅对应于很小的HTML标签子集.这个想法不是要创建一种使插入HTML标记更容易的语法.我认为HTML标记已经很容易插入. Markdown的想法是使其易于阅读,编写和编辑散文. HTML是一种发布格式; Markdown是一种书写格式.因此, Markdown的格式语法仅解决可以以纯文本格式传达的问题 .

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.

对于Markdown语法未涵盖的任何标记,只需使用HTML本身即可.

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

由于它不是发布格式",因此Markdown无法提供为文本着色的方法.也就是说,您可以包括原始HTML(并且HTML是一种发布格式),这并非没有可能.例如,以下Markdown文本(由@scoa在评论中建议):

As it is not a "publishing format," providing a way to color your text is out-of-scope for Markdown. That said, it is not impossible as you can include raw HTML (and HTML is a publishing format). For example, the following Markdown text (as suggested by @scoa in a comment):

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实现中使用.

Now, StackOverflow (and probably GitHub) will strip the raw HTML out (as a security measure) so you lose the color here, but it should work on any standard Markdown implementation.

另一种可能性是使用最初由 Markuru 引入的非标准属性列表.实施Markdown,后来被很少

Another possibility is to use the non-standard Attribute Lists originally introduced by the Markuru implementation of Markdown and later adopted by a few others (there may be more, or slightly different implementations of the same idea, like div and span attributes in pandoc). In that case, you could assign a class to a paragraph or inline element, and then use CSS to define a color for a class. However, you absolutely must be using one of the few implementations which actually support the non-standard feature and your documents are no longer portable to other systems.

这篇关于如何在Markdown中应用颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆