markdown语法汇总
This post is originated from here and is used for testing markdown style. This post contains nearly every markdown usage. Make sure all the markdown elements below show up correctly.
Color
1 | 这是默认颜色的文本,而这是<span style="color: red;">红色</span>的文本。 |
这是默认颜色的文本,而这是红色的文本。
Headers标题字体
1 | # H1 |
H1
H2
H3
H4
H5
H6
Alternatively, for H1 and H2, an underline-ish style:
Alt-H1
Alt-H2
Emphasis 强调
1 | # 单个 * 或者 下划线 表示*斜体* |
Emphasis, aka italics, with asterisks or underscores.
Strong emphasis, aka bold, with asterisks or underscores.
Combined emphasis with asterisks and underscores.
Strong emphasis, aka bold italics, with asterisks or underscores.
Strikethrough uses two tildes. Scratch this.
This is the eg.
Lists
1 | 1. First ordered list item |
- First ordered list item
- Another item
- Unordered sub-list.
Actual numbers don’t matter, just that it’s a number
Ordered sub-list
And another item.
You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we’ll use three here to also align the raw Markdown).
To have a line break without a paragraph, you will need to use two trailing spaces.
Note that this line is separate, but within the same paragraph.
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
- Unordered list can use asterisks
- Or minuses
- Or pluses
Paragraph In unordered list
For example like this.
Common Paragraph with some text.
And more text.
Inline HTML
1 | <p>To reboot your computer, press <kbd>ctrl</kbd>+<kbd>alt</kbd>+<kbd>del</kbd>.</p> |
To reboot your computer, press ctrl+alt+del.
1 | <dl> |
- Definition list
- Is something people use sometimes.
<dt>Markdown in HTML</dt>
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
Links((下划线)
1 | [I'm an inline-style link](https://www.google.com) |
I’m an inline-style link with title
I’m a relative reference to a repository file
You can use numbers for reference-style link definitions
Or leave it empty and use the link text itself
Some text to show that the reference links can follow later.
Images(图片插入)
1 | hover to see the title text: |
hover to see the title text:
Inline-style:
Reference-style:
Code and Syntax Highlighting(代码块高亮)
Inline code
has back-ticks around
it.
1 | var s = "JavaScript syntax highlighting"; |
1 | s = "Python syntax highlighting" |
1 | No language indicated, so no syntax highlighting. |
Tables
1 | | |ASCII |HTML | |
ASCII | HTML | |
---|---|---|
Single backticks | 'Isn't this fun?' |
‘Isn’t this fun?’ |
Quotes | "Isn't this fun?" |
“Isn’t this fun?” |
Dashes | -- is en-dash, --- is em-dash |
– is en-dash, — is em-dash |
Colons can be used to align columns.
1 | | Tables | Are | Cool | |
Tables | Are | Cool |
---|---|---|
col 3 is | right-aligned | |
col 2 is | centered | |
zebra stripes | are neat |
The outer pipes (|) are optional, and you don’t need to make the raw Markdown line up prettily. You can also use inline Markdown.
1 | Markdown | Less | Pretty |
Markdown | Less | Pretty |
---|---|---|
Still | renders |
nicely |
1 | 2 | 3 |
You can find more information about LaTeX mathematical expressions here.
Blockquotes
Blockquotes are very handy in email to emulate reply text.
This line is part of the same quote.
Quote break.
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.
Horizontal Rule 分割线
1 | *** |
示例: *** --- - - - * * * ------ ______
Three or more…
1 | --- |
Hyphens
Asterisks
Underscores
Line Breaks
1 | Here's a line for us to start with. |
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.
1 | This is a regular paragraph. |
This is a regular paragraph.
Foo |
This is another regular paragraph.
HTML 标签
1 | <br> 换行 |
示例:
换
行
分
割
使用 Ctrl+C 复制, 使用 Ctrl+V 粘贴。
转义字符
Markdown 使用了很多特殊符号来表示特定的意义,如果需要显示特定的符号则需要使用转义字符,Markdown 使用反斜杠转义特殊字符。
1 | **两个星号是加粗文本** |
示例:
两个星号是加粗文本
** 使用转义字符后正常显示星号 **
Markdown 支持以下这些符号前面加上反斜杠来帮助插入普通的符号:
1 | \ 反斜线 |
公式
Markdown Preview Enhanced 使用 KaTeX
或者 MathJax
来渲染数学表达式。
KaTeX 拥有比 MathJax 更快的性能,但是它却少了很多 MathJax 拥有的特性。你可以查看 KaTeX supported functions/symbols 来了解 KaTeX 支持那些符号和函数。默认下的分隔符:
$...$
或者 \(...\)
中的数学表达式将会在行内显示。$$...$$
或者 \[...\]
或者 ```
math 中的数学表达式将会在块内显示。
示例代码:
1 | $ f(x) = sin(x) + 12 $ |
显示效果:
$$ f(x) = sin(x) + 12 $$
$$ \sum_{n=1}^{100} n $$
$$
\begin{Bmatrix}
a & b \
c & d
\end{Bmatrix}
$$
$$
\begin{CD}
A @>a>> B \
@VbVV @AAcA \
C @= D
\end{CD}
$$
sup & sub | 上标 & 下标
用法:
1 | 上标:<sup>内容</sup> |
示例:
mm2
平方毫米: mm2
y = log2 x
对数: y = log2 x
div - - align | 各种对齐
用法
1 | <div align="center">奇怪的知识增加了!</div> |
示例:
- 横向流程图格式:显示效果
1
2
3
4
5
6
7
8```mermaid
graph LR
A[方形] -->B(圆角)
B --> C{条件a}
C -->|a=1| D[结果1]
C -->|a=2| E[结果2]
F[横向流程图]
``` # end显示效果1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19graph LR
A[方形] -->B(圆角)
B --> C{条件a}
C -->|a=1| D[结果1]
C -->|a=2| E[结果2]
F[横向流程图]
```
**竖向流程图格式**:
```markdown
```mermaid
graph TD
A[方形] --> B(圆角)
B --> C{条件a}
C --> |a=1| D[结果1]
C --> |a=2| E[结果2]
F[竖向流程图]
``` # end1
2
3
4
5
6graph TD
A[方形] --> B(圆角)
B --> C{条件a}
C --> |a=1| D[结果1]
C --> |a=2| E[结果2]
F[竖向流程图]
UML标准时序图样例:
1 | ```mermaid |
显示效果
1 | %% 时序图例子,-> 直线,-->虚线,->>实线箭头 |
甘特图样例:
1 | ```mermaid |
显示效果:
1 | %% 语法示例 |
注脚
1 | 使用 [^keyword] 表示注脚。 |
示例:
我是主体[^我是注脚]
列表
Markdown 支持有序列表和无序列表。
无序列表
格式:
无序列表使用星号(*)、加号(+)或是减号(-)作为列表标记,这些标记后面要添加一个空格,然后再填写内容:
1 | * aa |
有序列表
格式:
使用数字并加上 . 号来表示:1+.+空格
1 | 1. aa |
示例:
- aa
- bb
列表嵌套
格式:
列表嵌套只需在子列表中的选项前面添加四个空格即可:
1 | 1. aa |
- aa
- bb
图片
Markdown图片语法格式是: 
或 
示例代码:
1 |  |
显示效果:
Youtube videos
1 | <a href="https://www.youtube.com/watch?feature=player_embedded&v=ARted4RniaU |
HEXO 专有
TAB页
1 | {% tabs `tabsname` %} |
效果如下:
内容1
内容2
NOTES
1 | {% note info %} |
效果如下:
升級方法:在 Hexo 根目錄下,運行 npm update hexo-theme-butterfly
1 | > **注意:** text.... |
效果如下:
注意: 不要把主題目錄的
_config.yml
刪掉
推荐阅读
1 | {% btn '/posts/dc584b87/',text,far fa-hand-point-right,block right larger %} |
效果如下:
📑 Butterfly 安裝文檔(二) 主題頁面