本文总结了Markdown中一些基本的语法和经常使用的组件环境,方便在写作过程中随时复制使用。
基本语法
标题
- # Heading level 1
- ## Heading level 2
- ### Heading level 3
- #### Heading level 4
- ##### Heading level 5
- ###### Heading level 6
复制代码 段落
要创建段落,请使用空白行将一行或多行文本进行分隔。- I really like using Markdown.
- I think I'll use it to format all of my documents from now on.
复制代码 换行
在一行的末尾添加两个或多个空格,然后按回车键,即可创建一个换行(
)。- This is the first line.
- And this is the second line.
复制代码 强调
粗体
斜体
粗斜体
引用
要创建块引用,请在段落前添加一个 > 符号。- > 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.
列表
要在保留列表连续性的同时在列表中添加另一种元素(段落,引用块、代码块、图片、列表),请将该元素缩进四个空格或一个制表符,如下例所示:- 1. First item
- 2. Second item
- 3. Third item
- - Indented item
- - Indented item
- 4. Fourth item
复制代码
- First item
- Second item
- Third item
- Indented item
- Indented item
- Fourth item
行中代码
要将单词或短语表示为代码,请将其包裹在反引号 (`) 中。转义反引号可以通过将单词或短语包裹在双反引号(``)中。- At the command prompt, type `nano`.
- ``Use `code` in your Markdown file.``
复制代码 At the command prompt, type nano.
Use `code` in your Markdown file.
分隔线
为了兼容性,请在分隔线的前后均添加空白行。- Try to put a blank line before...
- ---
- ...and after a horizontal rule.
复制代码 链接
基本语法
- 这是一个链接 [Markdown语法](https://markdown.com.cn)。
复制代码 这是一个链接 Markdown语法。
给链接增加 Title
链接title是当鼠标悬停在链接上时会出现的文字,这个title是可选的,它放在圆括号中链接地址后面,跟链接地址之间以空格分隔。- 这是一个链接 [Markdown语法](https://markdown.com.cn "最好的markdown教程")。
复制代码 这是一个链接 Markdown语法。
网址和Email地址
使用尖括号可以很方便地把URL或者email地址变成可点击的链接。- [/code]https://markdown.com.cn
- fake@example.com
- [size=3]带格式化的链接[/size]
- [code]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.
图片
要添加图像,请使用感叹号 (!), 然后在方括号增加替代文本,图片链接(可以是本地或网页图片)放在圆括号里,括号里的链接后可以增加一个可选的图片标题文本。
插入图片Markdown语法代码:。- 
复制代码 转义字符
要显示原本用于格式化 Markdown 文档的字符,请在字符前面添加反斜杠字符 \。- \* Without the backslash, this would be a bullet in an unordered list.
复制代码 渲染效果如下:
* Without the backslash, this would be a bullet in an unordered list.
可做转义的字符
CharacterName\backslash`backtick*asterisk_underscore{}curly braces[]brackets()parentheses#pound sign+plus sign-minus sign (hyphen).dot!exclamation mark|pipe特殊字符自动转义
在 HTML 文件中,有两个字符需要特殊处理: |