Markdown链接语法
链接文本放在中括号内,链接地址放在后面的括号中,链接title可选。
超链接Markdown语法代码:[超链接显示名](超链接地址 “超链接title”)
对应的HTML代码:<a href=“超链接地址” title=“超链接title”>超链接显示名
……Internet is awesome,but you can't download love.
链接文本放在中括号内,链接地址放在后面的括号中,链接title可选。
超链接Markdown语法代码:[超链接显示名](超链接地址 “超链接title”)
对应的HTML代码:<a href=“超链接地址” title=“超链接title”>超链接显示名
……要创建分隔线,请在单独一行上使用三个或多个星号 (***)、破折号 (—) 或下划线 (___) ,并且不能包含其他内容。
***
---
_________________
以上三个分隔线的渲染效果看起来都一样:
为了兼容性,请在分隔线的前后均添加空白行。
| ❌Don’t do this | ⭕Do this |
|---|---|
| Without blank lines, this would be a heading. — Don’t do this! |
Try to put a blank line before… — …and after a horizontal rule. |
要将单词或短语表示为代码,请将其包裹在反引号 (`) 中。
| Markdown语法 | HTML | 预览效果 |
|---|---|---|
| At the command prompt, type `nano`. | At the command prompt, type <code>nano</code>. | At the command prompt, type nano. |
如果你要表示为代码的单词或短语中包含一个或多个反引号,则可以通过将单词或短语包裹在双反引号(``)中。
| Markdown语法 | HTML | 预览效果 |
|---|---|---|
``Use `code in your Markdown file.\` |
<code>Use `code` in your Markdown file.</code> | Use |
要创建代码块,请将代码块的每一行缩进至少四个空格或一个制表符。
……要创建块引用,请在段落前添加一个 > 符号。
> 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.
……
可以将多个条目组织成有序或无序列表。
要创建有序列表,请在每个列表项前添加数字并紧跟一个英文句点。数字不必按数学顺序排列,但是列表应当以数字 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 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 5. Second item 9. Third item 0. 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 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> </il> <li>Fourth item</li> </ol> |
|
普通标记和其他一些轻量级标记语言允许您使用括号( ) )半角符号,作为划界器(例如:1) First item ), ,但并非所有 Markdown 应用程序都支持这一点,因此从兼容性的角度来看,这不是一个好的选择。所以应当只使用( . )
……通过将文本设置为粗体或斜体来强调其重要性。
要加粗文本,请在单词或短语的前后各添加两个星号(asterisks)或下划线(underscores)。如需加粗一个单词或短语的中间部分用以表示强调的话,请在要加粗部分的两侧各添加两个星号(asterisks)。
| 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 |
Markdown 应用程序在如何处理单词或短语中间的下划线上并不一致。为兼容考虑,在单词或短语中间部分加粗的话,请使用星号(asterisks)。
……在一行的末尾添加两个或多个空格,然后按回车键,即可创建一个换行(<br>)。
| 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. |
几乎每个 Markdown 应用程序都支持两个或多个空格进行换行,称为 结尾空格(trailing whitespace) 的方式,但这是有争议的,因为很难在编辑器中直接看到空格,并且很多人在每个句子后面都会有意或无意地添加两个空格。由于这个原因,你可能要使用除结尾空格以外的其它方式来换行。幸运的是,几乎每个 Markdown 应用程序都支持另一种换行方式:HTML 的 <br> 标签。
……要创建段落,请使用空白行将一行或多行文本进行分隔。
| 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. |
不要用空格(spaces)或制表符( tabs)缩进段落。
| ❌Don’t do this | ⭕Do this |
|---|---|
| This can result in unexpected formatting problems. Don’t add tabs or spaces in front of paragraphs. |
Don’t put tabs or spaces in front of your paragraphs. Keep lines left-aligned like this. |
要创建标题,请在单词或短语前面添加井号 (#) 。# 的数量代表了标题的级别。例如,添加三个 # 表示创建一个三级标题 (<h3>) (例如:### My Header)。
| Markdown语法 | HTML | 预览效果 |
|---|---|---|
| # Heading level 1 | <h1>Heading level 1 | Heading level 1 |
| ## Heading level 2 | <h2>Heading level 2 | Heading level 2 |
| ### Heading level 3 | <h3>Heading level 3 | Heading level 3 |
| #### Heading level 4 | <h4>Heading level 4 | Heading level 4 |
| ##### Heading level 5 | <h5>Heading level 5 | Heading level 5 |
| ###### Heading level 6 | <h6>Heading level 6 | Heading level 6 |
还可以在文本下方添加任意数量的 == 号来标识一级标题,或者 – 号来标识二级标题。
……