Markdown基本语法

Markdown标题语法

要创建标题请在单词或短语前面添加井号(#)

  • 例如:

       # Heading level1
  • 预览效果

    Heading level1

或者在文本下方添加任意数量的 == 号来标识以及标题,或者 -- 号来标识二级标题.

  • 例如

    Heading level1  
    ====
  • 预览效果

Heading level1

Markdown段落

要创建段落,使用空白行将一行或多行文本进行分隔。

  • 例如

    I really like using
    
    Markdown.
  • 预览效果

I really like using

Markdown.

Markdown换行语法

在一行的末尾添加两个或多个空格,然后按回车键,即可创建一个换行。

  • 例如

    This is the first line.  
    And this is the second line. 
  • 预览效果

This is the first line.

And this is the second line.

Markdown强调语法

粗体

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

  • 例如

    I just love **bold text**.
    I just love __bold text__.
  • 预览效果

I just love bold text.

斜体

要用斜体显示文本,请在单词或短语前后添加一个星号(*)或下划线(_)。

  • 例如

    Italicized text is the *cat's meow*.
    Italicized text is the _cat's meow_.
  • 预览效果

Italicized text is the _cat's meow_.

粗体和斜体

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

  • 例如

    This text is ***really important***.
    This text is ___really important___.
    This text is __*really important*__.
    This text is **_really important_**.
    This is really***very***important text.
  • 预览效果

This text is really important.
This is reallyveryimportant text.

Markdown 引用语法

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

  • 例如

    > Dorothy followed her through many of the beautiful rooms in her castle.
  • 预览效果

    Dorothy followed her through many of the beautiful rooms in her castle.

    多个段落的块引用

    块引用可以包含多个段落。为段落之间的空白行添加一个 > 符号。

    嵌套块引用

    块引用可以嵌套。在要嵌套的段落前添加一个 >> 符号。

    带有其它元素的块引用

    块引用可以包含其他 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.

Markdown 列表语法

可以将多个条目组织成有序或无序列表。

有序列表

要创建有序列表,请在每个列表项前添加数字并紧跟一个英文句点。(数字不必按数学顺序排列,但是列表应当以数字 1 起始.)

  • 例如

    1. First item
    2. Second item
    3. Third item
    4. Fourth item 
1. First item
1. Second item
1. Third item
1. Fourth item 

1. First item
8. Second item
3. Third item
5. Fourth item 

1. First item
2. Second item
3. Third item
    1. Indented item
    2. Indented item
4. Fourth item 
  • 预览效果
  1. First item
  2. Second item
  3. Third item

    1. Indented item
    2. Indented item
  4. Fourth item

无序列表

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

Markdown 代码语法

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

  • 例如

    At the command prompt, type `nano`.
  • 预览效果

At the command prompt, type nano.

转义反引号

如果你要表示为代码的单词或短语中包含一个或多个反引号,则可以通过将单词或短语包裹在双反引号(``)中。

  • 例如

     ``Use `code` in your Markdown file.``
  • 预览效果

Use `code` in your Markdown file.

代码块

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

Markdown 分隔线语法

要创建分隔线,请在单独一行上使用三个或多个星号 (*)、破折号 (---) 或下划线 (___) ,并且不能包含其他内容。

  • 例如

     Try to put a blank line before...
     
     ---
     
     ...and after a horizontal rule.
  • 预览效果

Try to put a blank line before...


...and after a horizontal rule.

Markdown 链接语法

链接文本放在中括号内,链接地址放在后面的括号中,链接title可选。

  • 例如

     [超链接显示名](超链接地址 "超链接title")
  • 预览效果

超链接显示名

给链接增加 Title

链接title是当鼠标悬停在链接上时会出现的文字,这个title是可选的,它放在圆括号中链接地址后面,跟链接地址之间以空格分隔。

这是一个链接 Markdown语法

网址和Email地址

使用尖括号可以很方便地把URL或者email地址变成可点击的链接。

  • 例如

     <https://markdown.com.cn>
     <fake@example.com>
  • 预览效果

https://markdown.com.cn
mailto:fake@example.com

带格式化的链接

强调链接, 在链接语法前后增加星号。 要将链接表示为代码,请在方括号中添加反引号。
I love supporting the EFF.
This is the Markdown Guide.
See the section on code.

引用类型链接

链接的第一部分格式

引用类型的链接的第一部分使用两组括号进行格式设置。第一组方括号包围应显示为链接的文本。第二组括号显示了一个标签,该标签用于指向您存储在文档其他位置的链接。
尽管不是必需的,可以在第一组和第二组括号之间包含一个空格。第二组括号中的标签不区分大小写,可以包含字母,数字,空格或标点符号。
以下示例格式对于链接的第一部分效果相同:

[hobbit-hole][1]
[hobbit-hole] [1]

链接的第二部分格式

引用类型链接的第二部分使用以下属性设置格式:
1.放在括号中的标签,其后紧跟一个冒号和至少一个空格(例如[label]:)
2.链接的URL,可以选择将其括在尖括号中。
3.链接的可选标题,可以将其括在双引号,单引号或括号中。
以下示例格式对于链接的第二部分效果相同

[1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle  
[1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle "Hobbit lifestyles"  
[1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle 'Hobbit lifestyles'  
[1]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle (Hobbit lifestyles)  
[1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> "Hobbit lifestyles"  
[1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> 'Hobbit lifestyles'  
[1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> (Hobbit lifestyles)   
  • 预览效果

link

Markdown 图片语法

要添加图像,请使用感叹号 (!), 然后在方括号增加替代文本,图片链接放在圆括号里,括号里的链接后可以增加一个可选的图片标题文本。

  • 例如

     ![图片alt](图片链接 "图片title")
  • 预览效果

 title=

链接图片

给图片增加链接,请将图像的Markdown 括在方括号中,然后将链接添加在圆括号中。
 title=

Markdown 转义字符语法

要显示原本用于格式化 Markdown 文档的字符,请在字符前面添加反斜杠字符 \ 。
* Without the backslash, this would be a bullet in an unordered list.

markdown扩展语法

Markdown 表格

要添加表,请使用三个或多个连字符(---)创建每列的标题,并使用管道(|)分隔每列。您可以选择在表的任一端添加管道。

  • 例如

     | Syntax      | Description |
     | ----------- | ----------- |
     | Header      | Title       |
     | Paragraph   | Text        |
  • 预览效果
SyntaxDescription
HeaderTitle
ParagraphText

对齐

您可以通过在标题行中的连字符的左侧,右侧或两侧添加冒号(:),将列中的文本对齐到左侧,右侧或中心。

  • 例如

     | Syntax      | Description | Test Text     |
     | :---        |    :----:   |          ---: |
     | Header      | Title       | Here's this   |
     | Paragraph   | Text        | And more      |
  • 预览效果
SyntaxDescriptionTest Text
HeaderTitleHere's this
ParagraphTextAnd more

Markdown 围栏代码块

Markdown基本语法允许您通过将行缩进四个空格或一个制表符来创建代码块。如果发现不方便,请尝试使用受保护的代码块。根据Markdown处理器或编辑器的不同,您将在代码块之前和之后的行上使用三个反引号(`)或三个波浪号(~~~)。

  • 例如

    {
      "firstName": "John",
      "lastName": "Smith",
      "age": 25
    }
  • 预览效果
{
  "firstName": "John",
  "lastName": "Smith",
  "age": 25
}

语法高亮

许多Markdown处理器都支持受围栏代码块的语法突出显示。使用此功能,您可以为编写代码的任何语言添加颜色突出显示。要添加语法突出显示,请在受防护的代码块之前的反引号旁边指定一种语言。

  • 例如

    {
      "firstName": "John",
      "lastName": "Smith",
      "age": 25
    }
  • 预览效果
{
  "firstName": "John",
  "lastName": "Smith",
  "age": 25
}

Markdown 删除线

您可以通过在单词中心放置一条水平线来删除单词。结果看起来像这样。此功能使您可以指示某些单词是一个错误,要从文档中删除。若要删除单词,请在单词前后使用两个波浪号~~。

  • 例如

     ~~世界是平坦的。~~ 我们现在知道世界是圆的。
  • 预览效果
    世界是平坦的。 我们现在知道世界是圆的。

Markdown 任务列表语法

任务列表使您可以创建带有复选框的项目列表。在支持任务列表的Markdown应用程序中,复选框将显示在内容旁边。要创建任务列表,请在任务列表项之前添加破折号-和方括号[ ],并在[ ]前面加上空格。要选择一个复选框,请在方括号[x]之间添加 x 。

  • 例如

     [x] Write the press release
     [ ] Update the website
     [ ] Contact the media
  • 预览效果
  • [x] Write the press release
  • [ ] Update the website
  • [ ] Contact the media

Markdown 使用 Emoji 表情

复制和粘贴表情符号

在大多数情况下,您可以简单地从Emojipedia
等来源复制表情符号并将其粘贴到文档中。许多Markdown应用程序会自动以Markdown格式的文本显示表情符号。从Markdown应用程序导出的HTML和PDF文件应显示表情符号。
Tip: 如果您使用的是静态网站生成器,请确保将HTML页面编码为UTF-8。

  • 例如

     去露营了! :tent: 很快回来。
     真好笑! :joy:
  • 预览效果

去露营了! :tent: 很快回来。
真好笑! :joy: