Markdown语法

65 阅读4分钟

Markdown语法

标题语法

要创建标题,请在单词或短语前面添加井号 (#) 。# 的数量代表了标题的级别。例如,添加三个 # 表示创建一个三级标题 (<h3>) (例如:### My Header)。

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

##### 这是五级标题
这是什么东西
==
这个呢
--
这是五级标题

这是什么东西

这个呢

段落语法

就是每段之间多空一行或多行用于分隔,类似于HTML的<p></p>

注意不要用制表符tab和空格space缩进段落

换行

段落后边加两个空格再加enter 或者使用<br>

粗体

在单词和短语两侧加上两个星号或者两个下划线,类似于HTML中的<strong>标签

**bold**  __bold__

bold bold

如果是在单词或者短语之间部分加粗,建议使用星号而不使用下划线,因为不同markdown程序在处理单词或短语下划线上的并不一致。

Love**is**bold 

Loveisbold

斜体

用法同粗体,不过斜体是只加一个星号或下划线,类似于HTML中的<em>标签。如果要同时实现粗体加斜体,那么就是1+2=3了!

*bold*  _bold  Love*is*bold  ***bold***

bold bold Loveisbold bold

引用

如果要创建块引用,在段落前加上 > 符号。

>In a storm in my best dress fearless~

In a storm in my best dress fearless~

多个段落的块引用
> In a storm in my best dress fearless
>
> So baby drive slow 'til we run out of road in this one horse town

In a storm in my best dress fearless

So baby drive slow 'til we run out of road in this one horse town

嵌套块引用
>In a storm in my best dress fearless
>>So baby drive slow 'til we run out of road in this one horse town

In a storm in my best dress fearless

So baby drive slow 'til we run out of road in this one horse town

带有其他元素的块引用,也就是前边包括后边要提到的标识
>### Title
>
>- first line`
>
>*everying* __will__ ***be*** ok !

Title

  • first line

everying will be ok !

列表

将多个条目组成有序或无序列表

有序列表

每个列表项前添加数字后紧跟英文句号 . 。数字不必按照自然数顺序,但是列表显示第一个应当是 1. 开始。每个列表项下可创建子项,按回车切到下一项时按制表符 tab 即可创建子项。另外数字不影响列表显示数字(除了第一项),不论数字多少,列表显示仍是从第一个数字开始按照自然数顺序。


1. 吃饭
	1. 早饭
	3. 午饭
	2. 晚饭
2. 睡觉
	1. 晚上睡觉
	2. 中午睡觉
3. 学习  
	1. 学习英语
	2. 学习数学
4. 运动
  1. 吃饭
    1. 早饭
    2. 午饭
    3. 晚饭
  2. 睡觉
    1. 晚上睡觉
    2. 中午睡觉
  3. 学习
    1. 学习英语
    2. 学习数学
  4. 运动
无序列表

创建无序列表,在每项前添加破折号 - 、星号 * 或 加号 + ,可使用嵌套。

  • 这行是 - ,创建的
  • 这行也是 - ,创建的
  • 这行是 + ,创建的
    • 这行也是 + ,创建的
  • 这行是 * ,创建的

注意到了前两项近一点,还有三四项近一点,但是二三项,四五项远一点了吗?因为使用不同符号创建的无序列表是相互不兼容的,所以最好使用同一种字符来创建无序列表。

列表中嵌套

列表后按两次回车后再加两次 tab 键,即可输入代码块,不过接后续的列表需要重新手动建表

1. Open a file 

		vi file1
		
2. close

		:wq
		
3. that is all
	- there is what?
	- I dont know.
1. dd

  1. Open a file

     vi file1
     
    
  2. close

     :wq
     
    
  3. that is all

    • there is what?
    • I dont know.
  4. dd

代码语法

将单词或者代码包裹在两个单引号里面,来表示代码。HTML中用 <code> 标签表示。如果给代码块内的某些单词或者字符加引号,就给全部代码两边加两个单引号,dads`dd`dd

`At the command prompt, type `nano`.`

`At the command prompt, type <code>nano</code>.`

`At the command prompt, type `nano`.`

At the command prompt, type nano.

At the command prompt, type <code>nano</code>.

At the command prompt, type nano.

分割线

使用 --- *** ___ 来构成分割线,不过上下需要空开一行。

上边

***
---
___

下边

上边




下边

链接

超链接

显示名

这是一个链接

网站和email地址

www.baidu.com

fake@example.com

带格式化的链接
I love supporting the *[EFF](https://eff.org).
This is the ***[Markdown Guide](https://www.markdownguide.org)***.
See the section on [`code`](#code).

I love supporting the EFF.

This is the Markdown Guide.

See the section on code.

表格输入

| 第一行 | 第二列 |
| --- | --- |
|第二行|第二列 |

| 第一行 | 第二列 |
| :--- | ---: |        //左对齐和右对齐
|第二行|第二列 |

第一行第二列
第二行第二列
第一行第二列
第二行第二列