1. Markdown 简介
- Markdown 是一种轻量级标记语言。
- 创始人: John Gruber, Aaron Swartz
2. Markdown 历史与发展
3. Markdown 基本语法
3.1 标题语法
要创建标题,请在单词或短语前面添加井号 (#) 。# 的数量代表了标题的级别。
注意:不同的Markdown应用程序处理#和标题之间的空格方式并不一致。为了兼容考虑,请用一个空格在 #和标题之间进行分隔。
3.2 段落语法
要创建段落,使用空白行将一行或多行文本进行分隔。
注意:不要用空格(spaces)或制表符( tabs)缩进段落。因为白搭。
I really like using Markdown.
I think I’ll use it to format all of my documents from now on.
3.3 强调语法
斜体显示文本,请在单词或短语前后添加一颗星
粗体显示文本,请在单词或短语前后添加两颗星
斜体粗体显示文本,请在单词或短语前后添加三颗星
Italicized text is the cat’s meow.
I just love bold text.
This is really very important text.
3.4 引用语法
3.4.1 要创建块引用,请在段落前添加一个 > 符号。
Dorothy followed her through many of the beautiful rooms
3.4.2 多个段落的块引用
块引用可以包含多个段落。为段落之间的空白行添加一个 > 符号
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.
3.4.3 嵌套块引用
块引用可以嵌套。在要嵌套的段落前添加一个 >> 符号。
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.
3.4.4 带有其它元素的块引用
The quarterly results look great!
- Revenue was off the chart.
- Profits were higher than ever.
Everything is going according to plan.
3.5 列表语法
可以将多个条目组织成有序或无序列表。
3.5.1 有序列表
要创建有序列表,请在每个列表项前添加数字并紧跟一个英文句点。数字不必按数学顺序排列,但是列表应当以数字 1 起始。
- First item
- Second item
- Third item
- Fourth item
3.5.2 无序列表
要创建无序列表,请在每个列表项前面添加破折号 (-)、星号 (*) 或加号 (+) 。缩进一个或多个列表项可创建嵌套列表。
- First item
- Second item
- Third item
- Fourth item
3.5.3 在列表中嵌套其他元素
要在保留列表连续性的同时在列表中添加另一种元素,请将该元素缩进四个空格或一个制表符,如下例所示:
-
This is the first list item.
-
Here’s the second list item.
I need to add another paragraph below the second list item.
-
And here’s the third list item.
3.5.4 引用块
-
This is the first list item.
-
Here’s the second list item.
A blockquote would look great below the second list item.
-
And here’s the third list item.
3.5.5 代码块
代码块通常采用四个空格或一个制表符缩进。当它们被放在列表中时,请将它们缩进八个空格或两个制表符。
-
Open the file.
-
Find the following code block on line 21:
int a=0; for(int b=0;b<100; b++) a+=b;
-
Update the title to match the name of your website.
3.5.6 图片
-
Open the file containing the Markdown logo.
-
Yeah.
-
Close the file.
3.5.7 列表
可以在有序列表中添加无序列表,反之亦可。
- First item
- Second item
- Third item
- Indented item
- Indented item
- Fourth item
3.6 Markdown 表格
Markdown 制作表格使用 | 来分隔不同的单元格,使用 - 来分隔表头和其他行。
表头1 | 表头2 |
---|---|
单元格1 | 单元格3 |
单元格2 | 单元格4 |
3.6.1 我们可以设置表格的对齐方式:
- -: 设置内容和标题栏居右对齐。
- :- 设置内容和标题栏居左对齐。
- :-: 设置内容和标题栏居中对齐。
左对齐 | 右对齐 | 居中对齐 |
---|---|---|
单元 | 单元 | 单 |
单元 | 单元 | 单 |
3.7 代码语法
要将单词或短语表示为代码,请将其包裹在反引号 (`) 中。
At the command prompt, type printf()
函数.
3.7.1 代码区块
代码区块使用 4 个空格或者一个制表符(Tab 键)。
#include <stdio.h>
int main() {
int i,j; // i, j控制行或列
for(i=1;i<=9;i++) {
for(j=1;j<=9;j++)
// %2d 控制宽度为两个字符,且右对齐;如果改为 %-2d 则为左对齐
// \t为tab缩进
printf("%d*%d=%2d\t", i, j, i*j);
printf("\n");
}
return 0;
}
·
注意: 反引号怎么输入,Esc 键下方的键 !
3.8 Markdown 分隔线语法
要创建分隔线,请在单独一行上使用三个或多个星号 (***)、破折号 (—) 或下划线 (___) ,并且不能包含其他内容。
3.9 链接语法
链接文本放在中括号内,链接地址放在后面的括号中,链接title可选。
超链接Markdown语法代码:超链接显示名
这是一个链接 Markdown语法。
3.10 图片语法
要添加图像,请使用感叹号 (!),然后在方括号增加替代文本,图片链接放在圆括号里,括号里的链接后可以增加一个可选的图片标题文本。
插入图片Markdown语法代码:](https://markdown.com.cn)