记一些Markdown的基础标签写法

由于很久没有写博客了,很多Markdown的写法已经忘得差不多了。再加上最近又发现自己记忆力下降非常严重,学习新的东西不做点笔记实在是不行了,做笔记的话看了一下还是直接用md写比较方便,毕竟md用熟了以后玩GitHub的时候也能稍微写点像模像样的README。

所以在这里记录一下方便我以后要用了但想不起来时有地方找。

标题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 一级标题
## 二级标题
### 三级标题
#### 四级标题
##### 五级标题
###### 六级标题


也可以用下面这样的方式:(仅限一二级标题)

一级标题foo
===

二级标题bar
---

段落

Markdown中段落与段落之间用一个空行隔开,没有隔开的都属于同一个段落。

1
2
3
4
5
6
7
Here's a line for us to start with.

This line is separated from the one above by two newlines, so it will be a *separate paragraph*.

This line is also a separate paragraph, but...
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.

Markdown文字段落会自动换行,所以按回车默认是一个新段落,也就是在之前的内容下面自动加上了一个空行。
如果想强制换行,就要在文字末尾加上两个空格再按回车<spcae><space> + <enter>
Typora中使用的是<shift> + <enter>

区块引用

段落的每行或者在段落的第一行前加上>

1
2
3
> 区块引用
>> 嵌套引用
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.

区块引用效果

嵌套引用效果

引用中可以使用markdown语法,加粗斜体

内容很长会换行:This is a very long line that will still be quoted properly when it wraps. Oh boy let’s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can put Markdown into a blockquote.

代码区块和语法高亮

1
2
3
行内的代码块需要用 `...` 包裹起来。
Inline `code` has `back-ticks around` it.
这也可以仅仅作为一个标记来用,内容不必须为代码。

Inline code has back-ticks around it.

如果想要语法高亮的效果需要用到段落代码块。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
```
never gonna let you down
```

语法高亮要在代码块开头标记上加上语言名称

```javascript
var s = "JavaScript syntax highlighting";
alert(s);
```

```python
s = "Python syntax highlighting"
print s
```

```
No language indicated, so no syntax highlighting.
But let's throw in a <b>tag</b>.
```
1
2
var s = "JavaScript syntax highlighting";
alert(s);
1
2
s = "Python syntax highlighting"
print s
1
2
No language indicated, so no syntax highlighting. 
But let's throw in a <b>tag</b>.

也可以直接在段落每行前加上4个空格(1个Tab制表符),但是需要和前一个段落间有一个空行。

1
2
using namespace std;
cout << "但是没有语法高亮" << endl;

强调

1
2
3
4
5
6
7
8
9
斜体: *斜体* 或者 _斜体_
加粗:**加粗** 或者 __加粗__
中划线: ~~中划线~~

可以嵌套使用:
**比如一段加粗的话中有 _几个斜体_ **

反斜杠:\
转义,显示特殊字符

Emphasis, aka italics, with asterisks or underscores.

Strong emphasis, aka bold, with asterisks or underscores.

Combined emphasis with asterisks and underscores.

Strikethrough uses two tildes. Scratch this.

列表

无序列表在列表项前加上 * 或者 - 或者 +。需要与前一个段落有一个空行。
在符号和列表标题间需要加上一个空格或者制表符。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
无序列表:

* (注意左边有一个空格)第一项
* 第二项

填写子内容前用空格隔开相应的距离
段落中换行也需要在前面添上空格

可以有很多段落

* 第三项
* 第一子项
* 第二子项
- 第四项
+ 第五项
  • Unordered list can use asterisks

  • Or minuses

  • Or pluses

有序列表就是把符号换成数字 + .

1
2
3
4
5
6
有序列表:

1. First ordered list item
2. Another item
3. 不同列表可以嵌套
* hello world
  1. First ordered list item
  2. Another item
  3. 不同列表可以嵌套
    • hello world

表格

1
2
3
4
5
|表格		|很		  |好用	|
|---------|:--------:|------:|
| col 3 is|:---:中对齐| $160 |
| col 2 is|:---左对齐 | $12 |
| zebra |---:右对齐 | $1 |
表格 好用
col 3 is :—:中对齐 $160
col 2 is :—左对齐 $12
zebra —:右对齐 $1

表格头下面表示表格对齐方式的短横线-至少要三个。
外侧的竖线|是可有可无的。

1
2
3
4
5
6
7
表格中也可以使用md标签
表格边线不必对整齐

Markdown | Less | Pretty
--- | --- | ---
*Still* | `renders` | **nicely**
1 | 2 | 3
Markdown Less Pretty
Still renders nicely
1 2 3

分割线

分割线最常使用就是三个或以上*,还可以使用-_

1
2
3
4
5
6
7
8
9
10
11
12
13
Three or more...

---

Hyphens

***

Asterisks

___

Underscores

Hyphens


Asterisks


Underscores

链接

1
2
3
4
5
6
7
8
9
10
行内链接:

[I'm an inline-style link](https://www.google.com)

链接加上标题,鼠标悬浮可以看到
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")

可以用相对路径
[I'm a relative reference to a repository file](../blob/master/LICENSE)

百度

方括号内写名称,圆括号内写url

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
参考式链接:

[You can use numbers for reference-style link definitions][1]


可以给链接加一个序号来使用参考
[1]: http://slashdot.org

可以直接用给定的链接名字
[link text itself]: http://www.reddit.com

也可以先在后面给链接一个相对的名字
[I'm a reference-style link][Arbitrary case-insensitive reference text]
[arbitrary case-insensitive reference text]: https://www.mozilla.org

百度是什么

图片

图片的形式和链接相似,只要在最前面加上一个!

1
2
3
4
5
6
7
Inline-style: 
![alt text](https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png "Logo Title Text 1")

Reference-style:
![alt text][logo]

[logo]: https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png "Logo Title Text 2"

Inline-style:
alt text

Reference-style:
alt text

HTML

可以在md中直接使用HTML写法

1
2
3
4
5
6
<dl>
<dt>Definition list</dt>
<dd>Is something people use sometimes.</dd>
<dt>Markdown in HTML</dt>
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
</dl>
Definition list
Is something people use sometimes.
Markdown in HTML
Does *not* work **very** well. Use HTML tags.
作者

Jhuoer Yen

发布于

2021-11-01

更新于

2023-09-18

许可协议

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×