简介
Markdown有两层意思:一是轻量级、纯文本语法格式的标记语言;二是编辑并解析markdown语法,展示最终文字排版效果的客户端。markdown使得文字排版标准化,可以轻松转换成HTML或其他格式。让你专注于文字内容,而无需浪费时间在文字排版上。
标题
语法:#
-
markdown写法:
# Heading level 1 ## Heading level 2 ### Heading level 3 #### Heading level 4 ##### Heading level 5 ###### Heading level 6
段落
语法:空行分割,形成段落
-
markdown写法:
段落1。 段落2。
-
实际效果:
段落1。
段落2。
换行
语法:正常段落换行用 2空格+回车
;表格中换行用<br>
。
-
markdown写法:
This is the first line. And this is the second line. This is the first line.<br> And this is the second line.
-
实际效果:
This is the first line.
And this is the second line.This is the first line.
And this is the second line.
斜体
语法:用*
或者_
包含斜体内容
-
markdown写法:
Italicized text is the *cat's meow*. Italicized text is the _cat's meow_.
-
实际效果:
Italicized text is the cat’s meow.
Italicized text is the cat’s meow.
粗体
用**
或者__
包含加粗内容;
-
markdown写法:
I just love **bold text**. I just love __bold text__.
-
实际效果:
I just love bold text.
I just love bold text.
粗体+斜体
用***
或___
包含内容
-
markdown写法:
This text is ***really important***. This text is ___really important___. This text is __*really important*__. This text is **_really important_**.
-
实际效果:
This text is really important.
This text is really important.
This text is really important.
This text is really important.
段落引用
-
段落开始处加上
>
-
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写法
> 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写法
> 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.
-
列表
-
有序列表
-
Markdown写法
1. First item 2. Second item 3. Third item 4. Fourth item
-
***实际效果:***(因为缩进下面本应该显示1,2,3这样的序列)
- First item
- Second item
- Third item
- Fourth item
-
-
无序列表(
-
、+
、*
用这三种符号实现)-
Markdown写法(下面只用
-
说明)- First item - Second item - Third item - Indented item - Indented item - Fourth item
-
实际效果:
- First item
- Second item
- Third item
- Indented item
- Indented item
- Fourth item
-
-
列表中插入段落
- Markdown写法
* 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.
-
- Markdown写法
-
列表中插入块引用
- Markdown写法
* 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.
-
- Markdown写法
代码块
-
用 `包括一个词或短语
-
Markdown写法
At the command prompt, type `nano`.
-
实际效果:
At the command prompt, type
nano
.
-
-
用 ```包含代码块
-
Markdown写法
``` <head> <title>Test</title> </head> ```
-
实际效果:
<head> <title>Test</title> </head>
-
分割线
语法:***
、---
、___
-
Markdown写法
*** --- ___
-
实际效果:
链接
-
格式:
[链接名](URL)
-
Markdown写法
My favorite search engine is [Duck Duck Go](https://duckduckgo.com).
-
实际效果:
My favorite search engine is Duck Duck Go.
-
-
格式:
[链接名](URL "Title")
增加链接Title(鼠标悬浮时显示)-
Markdown写法
My favorite search engine is [Duck Duck Go](https://duckduckgo.com "The best search engine for privacy").
-
实际效果:
My favorite search engine is Duck Duck Go.
-
-
链接配合其他元素使用
-
Markdown写法
I love supporting **[EFF](https://eff.org)**. This is the *[Markdown Guide](https://www.markdownguide.org)*.
-
实际效果:
I love supporting EFF.
This is the Markdown Guide.
-
-
链接嵌套
-
Markdown写法
[[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ucsmywwD-1637021353647)(www.baidu.com/img/baidu_jgylogo3.gif "百度首页")]](www.baidu.com)
-
实际效果:
-
-
原文加链接优化
-
Markdown写法
In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends of worms and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to eat: it was a [hobbit-hole](https://en.wikipedia.org/wiki/Hobbit#Lifestyle "Hobbit lifestyles"), and that means comfort. 上面的写法和下面的写法,展示效果是一样的,但是上面把链接插入在原文中很不好阅读,可以用下面方式,方便修改阅读: In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends of worms and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to eat: it was a [hobbit-hole][1], and that means comfort. [1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> "Hobbit lifestyles"
-
实际效果:
In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends
of worms and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to
eat: it was a hobbit-hole, and that means comfort.
-
URL变链接
语法:<URL>
-
Markdown写法
<https://www.markdownguide.org> <fake@example.com>
-
实际效果:
图片
语法:![图片名](URL)
-
Markdown写法
1. Open the file containing the Linux mascot. 2. Marvel at its beauty. ![Tux, the Linux mascot](https://i-blog.csdnimg.cn/blog_migrate/1d0c4a9b57d5fa34918e4c4f5ea4500d.png) 3. Close the file.
-
实际效果:
- Open the file containing the Linux mascot.
- Marvel at its beauty.
- Close the file.
特殊字符反引用
语法:\
用反斜杠可以反引用下面特殊字符
-
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.
-
实际效果:
-
Without the backslash, this would be a bullet in an unordered list.
* Without the backslash, this would be a bullet in an unordered list.
-
-
可以处理的特殊字符
\`*-{}[]()#+-·!
兼容 HTML
Markdown中可以直接插入HTML,解析库默认是不开放的,需要参考对应库文档,markdown-it设置html: true
1、 Markdown 文件里加上 HTML 表格:
-
markdown写法:
这是一个普通段落。 <table> <tr> <td>Foo</td> </tr> </table> 这是另一个普通段落。
-
实际效果
这是一个普通段落。
这是另一个普通段落。Foo
2、Markdown嵌入视频
-
markdown写法:
1. 插入视频 <video src="视频链接" width="320" height="180" controls="controls"></video>
-
实际效果:
表格
语法:使用 |
来分隔不同的单元格,使用 -
来分隔表头和其他行。
-
markdown写法:
| 左对齐 | 右对齐 | 居中对齐 | | :-----| ----: | :----: | | 单元格 | 单元格 | 单元格 | | 单元格 | 单元格 | 单元格 | -: 设置内容和标题栏居右对齐。 :- 设置内容和标题栏居左对齐。 :-: 设置内容和标题栏居中对齐。
-
实际效果:
左对齐 右对齐 居中对齐 单元格 单元格 单元格 单元格 单元格 单元格