markdown语法
标题
要创建标题,请在单词或短语前面添加井号 (#) 。# 的数量代表了标题的级别。
段落
要创建段落,请使用空白行将一行或多行文本进行分隔。
换行
在一行的末尾添加两个或多个空格,然后按回车键,也可再末尾增加,即可创建一个换行()。
强调
粗体(Bold)
要加粗文本,请在单词或短语的前后各添加两个星号(asterisks)或下划线(underscores)。不要带空格。如:
增加**粗体**。 和 增加__粗体__。 显示效果为:增加粗体。增加__粗体__。
斜体(Italic)
要用斜体显示文本,请在单词或短语前后添加一个星号(asterisk)或下划线(underscore)。不要带空客。如:
增加*斜体*。 和 增加_斜体_。 显示效果为:增加斜体。增加_斜体_。
粗体(Bold)和斜体(Italic)
要同时用粗体和斜体突出显示文本,请在单词或短语的前后各添加三个星号或下划线。不要带空格。如:
增加***粗斜体***。 和 增加___粗斜体___。 显示效果为:增加粗斜体。增加___粗斜体___。
引用
单个段落的块引用
要创建块引用,请在段落前添加一个 > 符号。如:
> Dorothy followed her through many of the beautiful rooms in her castle.
Dorothy followed her through many of the beautiful rooms in her castle.
多个段落的块引用
> Dorothy followed her through many of the beautiful rooms in her castle.
>
> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
Dorothy followed her through many of the beautiful rooms in her castle.
The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
嵌套块引用
> Dorothy followed her through many of the beautiful rooms in her castle.
>
>> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
Dorothy followed her through many of the beautiful rooms in her castle.
The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
带有其它元素的块引用
> #### The quarterly results look great!
>
> - Revenue was off the chart.
> - Profits were higher than ever.
>
> *Everything* is going according to **plan**.
The quarterly results look great!
- Revenue was off the chart.
- Profits were higher than ever.
Everything is going according to plan.
列表
有序列表
要创建有序列表,请在每个列表项前添加数字并紧跟一个英文句点。数字不必按数学顺序排列,但是列表应当以数字 1 起始。
1. First item
1. Second item
2. Third item
2. Fourth item
-
First item
- Second item
- Third item
-
Fourth item
无序列表
要创建无序列表,请在每个列表项前面添加破折号 (-)、星号 ( * ) 或加号 (+) 。缩进一个或多个列表项可创建嵌套列表。
- First item
* Second item
+ Third item
- Fourth item
-
First item
-
Second item
-
Third item
-
-
Fourth item
在列表中嵌套其他元素
要在保留列表连续性的同时在列表中添加另一种元素,请将该元素缩进四个空格或一个制表符,
- This is the first list item.
1. first list
2. second
- Here's the second list item.
> A blockquote would look great below the second list item.
- And here's the third list item.
-
This is the first list item.
- first list
- second
-
Here’s the second list item.
A blockquote would look great below the second list item.
-
And here’s the third list item.
代码
单行代码
要将单词或短语表示为代码,请将其包裹在反引号 (`)中。
At the command prompt, type `nano`. 显示为:At the command prompt, type nano.
如果你要表示为代码的单词或短语中包含一个或多个反引号,则可以通过将单词或短语包裹在双反引号(``)中。
``At the command prompt, type `nano`.``
At the command prompt, type `nano`.
代码块
要创建代码块,请将代码块的每一行缩进至少四个空格或一个制表符。
<html>
<head>
</head>
</html>
<html>
<head>
</head>
</html>
如果发现不方便,请尝试使用受保护的代码块。根据Markdown处理器或编辑器的不同,您将在代码块之前和之后的行上使用三个反引号(```)或三个波浪号(~~~)。
```
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}
```
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}
语法高亮
要添加语法突出显示,请在受防护的代码块之前的反引号旁边指定一种语言。
```json
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}
```
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}
分隔线
要创建分隔线,请在单独一行上使用三个或多个星号 ( *** )、破折号 ( — ) 或下划线 ( ___ ) ,并且不能包含其他内容。
链接
链接
基本链接
要创建链接,请将链接文本放在方括号内,后面紧跟链接URL放在圆括号内。如:
text
[Markdown教程](https://www.markdownguide.org)
显示效果为:Markdown教程
带标题的链接
可以为链接添加标题,当用户悬停在链接上时会显示。标题放在URL后面的引号内。
text
[Markdown教程](https://www.markdownguide.org "访问Markdown指南网站")
显示效果为:Markdown教程
网址和电子邮件地址
要将URL或电子邮件地址快速转换为链接,请将其括在尖括号中。
text
<https://www.markdownguide.org>
<[email protected]>
显示效果为:
https://www.markdownguide.org
[email protected]
格式化链接
可以强调链接,即用星号包围链接文本。
text
I love supporting the **[EFF](https://eff.org)**.
This is the *[Markdown Guide](https://www.markdownguide.org)*.
显示效果为:
I love supporting the **EFF*.
This is the Markdown Guide*.
引用式链接
引用式链接是一种更高级的链接方式,它可以让链接更易于阅读和维护。引用式链接包含两部分:
- 链接文本部分的标签(可选的)
- 文档其他位置的链接定义
第一部分:链接文本
text
[文本][标签]
[文本][]
[文本]
第二部分:链接定义
text
[标签]: URL "可选标题"
示例:
text
这是一个[引用式链接][google]的例子。
[google]: https://www.google.com "访问Google"
这是一个[自动识别链接][]的例子。
[自动识别链接]: https://www.example.com
这是一个[直接链接]的例子。
[直接链接]: https://www.markdownguide.org
显示效果为:
这是一个[引用式链接][google]的例子。
[google]: https://www.google.com “访问Google”
这是一个[自动识别链接][]的例子。
[自动识别链接]: https://www.example.com
这是一个[直接链接]的例子。
[直接链接]: https://www.markdownguide.org
图片
既然已经补充了链接,我可以继续为您添加图片章节。图片语法与链接非常相似,只是在开头添加了一个感叹号。
基本图片
要添加图片,请添加感叹号 (!),然后在方括号中提供替代文本,图片路径或URL放在圆括号中。
text

https://markdown-here.com/img/icon256.png
带标题的图片
可以为图片添加标题,当用户悬停在图片上时会显示。
text

https://markdown-here.com/img/icon256.png
带链接的图片
要使图片成为链接,请将图片的Markdown放在链接的方括号内。
text
[](https://www.markdownguide.org)
https://markdown-here.com/img/icon256.png
引用式图片
与引用式链接类似,也可以使用引用式图片。
text
![Markdown图标][logo]
[logo]: https://markdown-here.com/img/icon256.png "Markdown Logo"
![Markdown图标][logo]
[logo]: https://markdown-here.com/img/icon256.png “Markdown Logo”
完整指南补充
根据您的需求,您可能还希望补充以下章节:
表格
要创建表格,请使用竖线 (|) 分隔各列,并使用连字符 (-) 创建表头。
text
| 语法 | 描述 |
| -------- | ----- |
| 标题 | 使用# |
| 段落 | 使用空白行 |
| 粗体 | 使用** ** |
| 语法 | 描述 |
|---|---|
| 标题 | 使用# |
| 段落 | 使用空白行 |
| 粗体 | 使用** ** |
任务列表
任务列表允许您创建带有复选框的列表。
text
- [x] 完成第一章节
- [ ] 完成第二章节
- [ ] 完成第三章节
- 完成第一章节
- 完成第二章节
- 完成第三章节
转义字符
要显示原本用于格式化Markdown文档的字符,请在字符前面添加反斜杠 (\)。
text
\* 如果没有反斜杠,这将成为无序列表项。
\# 如果没有反斜杠,这将成为标题。
显示效果为:
- 如果没有反斜杠,这将成为无序列表项。