虽然最不平衡的争论(Discord)之一可能是在其深色和浅色主题(Dark and Light themes)之间进行选择,但基于颜色的自定义(customization doesn)并没有超出这种选择和设置自定义角色颜色的范围。
但是,Discord支持降价。如果您不熟悉 markdown,您可以将其应用于消息以添加粗体和斜体(bolding and italicization)等效果的简单的基于符号的格式。
在Discord(Discord)支持的所有 markdown 中,代码块可能是最通用的。您不必成为编码人员即可使用代码块,而且许多用户并不知道这些块状框实际上允许用户为其文本添加颜色。
使困惑?在本文中,让我们讨论一下代码块以及如何使用它们来创建Discord 颜色(Discord color)消息。
Discord 上的代码块是什么?(What Are Code Blocks On Discord?)
代码块,有时称为代码框或简称为框,是 Discord 渲染引擎支持的一种降价形式。
如果您不确定什么是降价,一些最常用的技巧是用单星号(*like this*)包围您的文本以使文本变为斜体或将双星号(**like this**)包围为粗体文本。
Discord支持 markdown 以及下划线(__like this__)、删除线(~~like this~~)、剧透标签(||like this||)、引号(> like this)和单行代码块(like这)。
但是,除了单行代码块(code block)之外,Discord还支持多行代码(multi-line code)块。单行代码块(code block)为白色等宽文本添加了深色背景(dark background),使Discord用户可以轻松共享简短的代码片段,这是一种可读的格式。多行代码块(code block)允许用户共享跨多行的更复杂的代码。
要创建多行代码块(code block),请将您的文本用三个反引号(“like this”)括起来。它将在您的文本周围创建一个大而黑的框,将其格式化为等宽字体,并保留所有缩进。
真正将多行代码块与其他标记区分开来的一件事是它们支持语法突出显示。
Discord 代码块中的语法高亮是什么?(What Is Syntax Highlighting In Code Blocks On Discord?)
语法高亮是文本编辑器和(Syntax highlighting)Notepad Notepad++ and Sublime Text等记事本替代品中常见的功能。它允许编码人员定义文档的编程语言,以便对代码的重要元素进行着色,以便于阅读和理解(reading and understanding)。
由于 Discord 的多行代码块标记(code block markup)旨在用于此目的,因此您可以利用一些巧妙的方法为您的消息添加颜色。
要将语法高亮添加到多行代码块,您必须在第一组三重反引号后输入关键字。这是一个例子:
“MD
<md> is the keyword to format your code blocks with basic markdown.
< Other syntax highlighting includes JSON and Python. >“`
当在Discord(Discord)上写为消息时,将如下所示:
除非您有涵盖所有内容的指南,否则要知道哪种格式样式会带出哪种颜色是在黑暗中的尝试,我们会这样做。
Discord 代码块语法高亮样式(Discord Code Block Syntax Highlighting Styles)
以下(Below)是Discord 的多行代码块标记(code block markup)支持的所有已知语法高亮关键字的列表。(syntax highlighting)
asciidoc
自动热键(autohotkey)
重击(bash)
咖啡脚本(coffeescript)
cpp
CS
css
差异(diff)
使固定(fix)
gsl(glsl)
初始化(ini)
json
MD
毫升(ml)
序言(prolog)
py
XL
xml
随着时间的推移,Discord可能会继续添加新的语法高亮选项。
虽然使用 Discord 的语法突出显示可能不如只更改文本颜色(text color)的选项那么干净,但它仍然非常有用,并且是目前创建Discord 颜色(Discord color)消息的最佳解决方案。
有很多选项,因此,如果您需要对大量文本进行格式化以便于阅读(例如Discord 音乐(Discord music)机器人的(bot –)命令列表(command list)),请务必尝试使用代码块。
How To Add Color To Messages On Discord
While one of the moѕt lopsided Discord debates may be choosing between its Dark and Lіght themes, color-based customization doesn’t reach far outside of this choice and setting custom role colors.
However, Discord supports markdown. If you’re unfamiliar with markdown, it’s the simple symbol-based formatting you apply to messages to add effects like bolding and italicization.
Of all markdown supported by Discord, code blocks may be the most versatile. You don’t have to be a coder to use code blocks, and many users aren’t aware that these blocky boxes actually allow users to add color to their text.
Confused? In this article, let’s talk about code blocks and how you can use them to create Discord color messages.
What Are Code Blocks On Discord?
Code blocks, sometimes referred to as code boxes or simply boxes, are a form of markdown supported by Discord’s rendering engine.
If you’re not sure what markdown is, some of the most commonly-used tricks are to surround your text in single asterisks (*like this*) to italicize text or double asterisks (**like this**) to bold text.
Discord supports markdown for these, along with underlines (__like this__), strikethroughs (~~like this~~), spoiler tags (||like this||), quotes (> like this), and single-line code blocks (`like this`).
However, along with single-line code blocks, Discord also supports multi-line code blocks. A single-line code block adds a dark background to white, monospaced text, making it easy for Discord users to share brief snippets of code is a readable format. Multi-line code blocks allow users to share more complex code that spans across several lines.
To create a multi-line code block, surround your text in triple backticks (“`like this“`). It will create a large, dark box around your text, format it in a monospaced font, and preserve all indentations.
One thing that really sets multi-line code blocks apart from other markdown is that they support syntax highlighting.
What Is Syntax Highlighting In Code Blocks On Discord?
Syntax highlighting is a feature commonly found in text editors and Notepad alternatives like Notepad++ and Sublime Text. It allows coders to define the programming language of a document so that important elements of the code will be colorized, for easier reading and understanding.
As Discord’s multi-line code block markup is intended to be used for this purpose, there are clever ways that you can take advantage of it to add color to your messages.
To add syntax highlighting to your multi-line code blocks, you have to enter a keyword after the first set of triple backticks. Here’s an example:
“`md
<md> is the keyword to format your code blocks with basic markdown.
< Other syntax highlighting includes JSON and Python. >“`
When written as a message on Discord, that will appear like this:
Knowing which formatting styles bring out which colors is a shot in the dark unless you’ve got a guide covering them all, which we do.
Discord Code Block Syntax Highlighting Styles
Below is a list of all of the known syntax highlighting keywords that Discord’s multi-line code block markup supports.
asciidoc
autohotkey
bash
coffeescript
cpp
cs
css
diff
fix
glsl
ini
json
md
ml
prolog
py
xl
xml
As time passes, Discord may continue to add new syntax highlighting options.
While using Discord’s syntax highlighting may not be as clean an implementation as having the option to just change your text color, it’s still very useful and the best solution available right now to create Discord color messages.
There are plenty of options, so if you ever have a large chunk of text that you need to be formatted for easier reading—such as a command list for your Discord music bot – be sure to try code blocks out.