Markdown Basic Syntax
Markdown Extended Syntax
几个#就是第几级标题

基础用法

标题“#

Markdown语法 HTML语法 预览效果
# 一级标题 <h1>Heading level 1</h1>

Heading level 1

## 二级标题 <h2>Heading level 2</h2>

Heading level 2

### 三级标题 <h3>Heading level 3</h3>

Heading level 3

#### 四级标题 <h4>Heading level 4</h4>

Heading level 4

##### 五级标题 <h5>Heading level 5</h5>
Heading level 5
###### 六级标题 <h6>Heading level 6</h6>
Heading level 6

段落

Markdown语法 HTML语法 预览效果

I really like using Markdown.

I think I’ll use it to format all of my documents from now on.

<p>I really like using Markdown.</p>

<p>I think I'll use it to format all of my documents from now on.</p>

I really like using Markdown.

I think I’ll use it to format all of my documents from now on.

需要注意的是段落前不要有空格和制表符(tab)

换行

Markdown语法 HTML语法 预览效果
This is the first line.
And this is the second line.
<p>This is the first line.<br>
And this is the second line.</p>
This is the first line.
And this is the second line.

为了兼容性,请在行尾添加“结尾空格”或 HTML 的 <br> 标签来实现换行。CommonMark 和其它几种轻量级标记语言支持在行尾添加反斜杠 (\) 的方式实现换行,但是并非所有 Markdown 应用程序都支持此种方式,因此从兼容性的角度来看,不推荐使用。并且至少有两种轻量级标记语言支持无须在行尾添加任何内容,只须键入回车键(return)即可实现换行。

强调

加粗(Blod)”**

要加粗文本,请在单词或短语的前后各添加两个星号或下划线。

Markdown语法 HTML语法 预览效果
I just love **bold text**. I just love <strong>bold text</strong>. I just love bold text.
I just love __bold text__. I just love <strong>bold text</strong>. I just love bold text.
Love**is**bold Love<strong>is</strong>bold Loveisbold

为兼容考虑,在单词或短语中间部分加粗的话,请使用星号。

斜体(Italic)”*

要用斜体显示文本,请在单词或短语前后添加一个星号或下划线。要斜体突出单词的中间部分,请在字母前后各添加一个星号,中间不要带空格。

Markdown语法 HTML语法 预览效果
Italicized text is the *cat's meow*. Italicized text is the <em>cat's meow</em>. Italicized text is the cat’s meow.
Italicized text is the _cat's meow_ Italicized text is the <em>cat's meow</em>. Italicized text is the cat’s meow.
A*cat*meow A<em>cat</em>meow Acatmeow

为兼容考虑,在单词或短语中间部分斜体的话,请使用星号。

粗体(Bold)和斜体(Italic)”***

要同时用粗体和斜体突出显示文本,请在单词或短语的前后各添加三个星号或下划线。要加粗并用斜体显示单词或短语的中间部分,请在要突出显示的部分前后各添加三个星号,中间不要带空格。

Markdown语法 HTML语法 预览效果
This text is ***really important***. This text is <strong><em>really important</em></strong>. This text is really important.
This text is ___really important___ This text is <strong><em>really important</em></strong>. This text is really important.
This text is __*really important*__ This text is <strong><em>really important</em></strong>. This text is really important.
This text is **_really important_** This text is <strong><em>really important</em></strong>. This text is really important.
This is really***very***important text. This is really<strong><em>very</em></strong>important text. This is reallyveryimportant text.

为兼容考虑,在单词或短语中间部分加粗+斜体的话,请使用星号。

引用”>

要创建块引用,请在段落前添加一个 > 符号。

> 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.

带有其它元素的块引用

块引用可以包含其他 Markdown 格式的元素。并非所有元素都可以使用,你需要进行实验以查看哪些元素有效。

> #### 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 起始。

Markdown语法 HTML 预览效果
1. First item
2. Second item
3. Third item
4. Fourth item
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
<li>Fourth item</li>
</ol>
  1. First item
  2. Second item
  3. Third item
  4. Fourth item
1. First item
1. Second item
1. Third item
1. Fourth item
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
<li>Fourth item</li>
</ol>
  1. First item
  2. Second item
  3. Third item
  4. Fourth item
1. First item
1. Second item
1. Third item
1. Fourth item
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
<li>Fourth item</li>
</ol>
  1. First item
  2. Second item
  3. Third item
  4. Fourth item
1. First item
2. Second item
3. Third item
    1. Indented item
    2. Indented item
4. Fourth item
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item
<ol>
<li>Indented item</li>
<li>Indented item</li>
</ol>
</li>
<li>Fourth item</li></ol>
  1. First item
  2. Second item
  3. Third item
    1. Indented item
    2. Indented item
  4. Fourth item

无序列表

要创建无序列表,请在每个列表项前面添加破折号 (-)、星号 (*) 或加号 (+) 。缩进一个或多个列表项可创建嵌套列表。

Markdown语法 HTML 预览效果
- First item
- Second item
- Third item
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
  • First item
  • Second item
  • Third item
* First item
* Second item
* Third item
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
  • First item
  • Second item
  • Third item
+ First item
+ Second item
+ Third item
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
  • First item
  • Second item
  • Third item
- First item
- Second item
    - Indented item
    - Indented item
- Third item
<ul>
<li>First item</li>
<li>Second item</li>
<ul>
<li>Indented item</li>
<li>Indented item</li>
</ul>
<li>Third item</li>
</ul>
  • First item
  • Second item
    • Indented item
    • Indented item
  • Third item

在列表中嵌套其他元素

要在保留列表连续性的同时在列表中添加另一种元素,请将该元素缩进四个空格或一个制表符,如下例所示:

段落

-   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.

渲染效果如下:

  • 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.

引用块

   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.

渲染效果如下:

  • 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.

代码块

代码块通常采用四个空格或一个制表符缩进。当它们被放在列表中时,请将它们缩进八个空格两个制表符,同时记得引用代码块前换行。

1. Open the file.
2. Find the following code block on line 21:

        xxx

3. Update the title to match the name of your website.

渲染效果如下:

  1. Open the file.

  2. Find the following code block on line 21:

     xxx
    
  3. Update the title to match the name of your website.

图片

1. loli可爱
2. 416可爱
![黑猫](/img/nav.jpg)
3. loli416真可爱w
渲染效果如下:

  1. loli可爱
  2. 416可爱
    这本来是张图的
  3. loli416真可爱w

代码”`

要将单词或短语表示为代码,请将其包裹在反引号 (`) 中。

Markdown语法 HTML 预览效果
At the command prompt, type `nano`. At the command prompt, type <code>nano</code>. At the command prompt, type nano.

转义反引号请使用(``)

代码块

要创建代码块,请将代码块的每一行缩进至少四个空格或一个制表符。

Quoting a codeblock…
    I’m the code
Succeed!

渲染效果如下:

Quoting a codeblock…

I'm the code

Succeed!

围栏代码块

如若上述用法带来不便,根据Markdown处理器或编辑器的不同,您可在代码块之前和之后的行上使用三个反引号((```)或三个波浪号(~~~)。同时,许多Markdown处理器都支持受围栏代码块的语法突出显示。使用此功能,您可以为编写代码的任何语言添加颜色突出显示。要添加语法突出显示,请在受防护的代码块之前的反引号旁边指定一种语言。。

``` markdown
{
    "firstName": "John",
    "lastName": "Smith",
    "age": 25
}
```

呈现的输出如下所示:

1
2
3
4
5
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}