我有一个自述文件。md文件用于我的项目underscore-cli,我想记录——color标志。

目前,做到这一点的唯一方法是截图(可以存储在项目存储库中):

但截图不是文本,防止读者复制/粘贴截图中的命令。创建/编辑/维护它们也很麻烦,而且浏览器加载速度较慢。现代网络使用文本样式,而不是一堆渲染的文本图像。

虽然一些Markdown解析器支持内联HTML样式,但GitHub不支持;这行不通:

<span style="color: green"> Some green text </span>

这行不通:

<font color="green"> Some green text </font>

当前回答

在问题、拉请求和讨论中,您可以使用反勾号在句子中显示颜色。反勾号内受支持的颜色模型将显示颜色的可视化。

参考:https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax # supported-color-models

其他回答

现在自2022年5月起,Github可以接受Markdown上的LATEX代码,所以你可以在$$$$块内使用\color{namecolor},如下例所示:

基本

Code Appearing
$${\color{red}Red}$$ $${\color{red}Red}$$
$${\color{green}Green}$$ $${\color{green}Green}$$
$${\color{lightgreen}Light \space Green}$$ $${\color{lightgreen}Light \space Green}$$
$${\color{blue}Blue}$$ $${\color{blue}Blue}$$
$${\color{lightblue}Light \space Blue}$$ $${\color{lightblue}Light \space Blue}$$
$${\color{black}Black}$$ $${\color{black}Black}$$
$${\color{white}White}$$ $${\color{white}White}$$

不止一种颜色

代码

$${\color{red}Welcome \space \color{lightblue}To \space \color{orange}Stackoverflow}$$

可视化

$${\color{红色}欢迎\space \color{浅蓝色}到\space \color{橙色}Stackoverflow}$$

这段代码在Github:

在GitHub README中为文本着色。md,可以使用SVG <text>

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 55 20" fill="none">
    <text x="0" y="15" fill="#4285f4">G</text>
    <text x="12" y="15" fill="#ea4335">o</text>
    <text x="21" y="15" fill="#fbbc05">o</text>
    <text x="30" y="15" fill="#4285f4">g</text>
    <text x="40" y="15" fill="#389738">l</text>
    <text x="45" y="15" fill="#ea4335">e</text>
</svg>

在使用自定义颜色制作自定义文本之后,保存SVG文件并按照以下步骤操作。

在GitHub上打开你的存储库。 单击README.md的“编辑”按钮 将SVG文件拖放到打开的在线编辑器中。GitHub将生成一个降价图像。大致如下。 (谷歌)! (https://user-images.githubusercontent.com/000/000-aaa.svg) 如果您想改变SVG的原始大小,可以使用生成的URL作为<img/>标记的src,并给出所需的大小。 <img height="100px" src="https://user-images.githubusercontent.com/000/000-aaa.svg" alt=""/> .

在撰写本文时,GitHub Markdown呈现了像“#ffffff”(注意反引号!)这样的颜色代码,并带有颜色预览。只需使用颜色代码,并用反刻度符号包围它。

例如:

就变成了

可以这样做:

! [] (https://img.shields.io/static/v1?label=&message=Ааи&color = green)

如果你想要着色超过1个词,那么我发现这是最方便的方法来着色文本在Github乳胶。

$\color{lightblue}{\textrm{Red Nimetaga 3 kõige suuremat pilveteenuste pakkujat}}$

示例Github可用在这里