Markdown的使用语法

Markdown的使用语法

Markdown介绍

Markdown是一种轻量级标记语言,排版语法简洁,让人们更多地关注内容本身而非排版。它使用易读易写的纯文本格式编写文档,可与HTML混编,可导出 HTML、PDF 以及本身的 .md 格式的文件。因简洁、高效、易读、易写,Markdown被大量使用,如Github、Wikipedia、简书等。

1. 标题语法

// 总共有6级标题,书写形式如下(注意#后要有空格):
#  一级标题
## 二级标题
### 三级标题
#### 四级标题
##### 五级标题
###### 六级标题

2. 字体语法

(1) 粗体写法
**hello world**  

效果:hello world

(2) 斜体写法
*hello*

效果:hello

(3) 粗体+斜体
***hello world***

效果:hello world

(4) 删除线
~~hello world~~

效果:hello world

(5) 突出显示
==hello world==

效果:hello world

3. 引用语法

//引用书写语法如下:
>hello world
>>hello world
>>>hello world
块引用可包含多个段落。块引用可包含其他 Markdown 格式的元素。具体用法还需不断尝试。
例如:
>## hello world
>how are you
>>**hello world**
>>*hello world*
>>>- hello world

效果:

hello world

hello world

hello world
hello world

  • hello world

4. 列表语法

有序列表

在每个列表项前添加数字并紧跟一个英文句点。
数字不必按数学顺序排列,但是应当以1起始。
1. First item
2. Second item
3. Third item
4. Fourth item

效果:

  1. First item
  2. Second item
  3. Third item
  4. Fourth item

无序列表

在每个列表项前面添加 (-)、 (*) 或 (+) 。
- First item
- Second item
- Third item
- Fourth item

效果:

  • First item
  • Second item
  • Third item
  • Fourth item

在列表中嵌套其他元素

缩进一个或多个列表项可创建嵌套列表。
经过实验,CSDN内好像做不到有序和无序混合。
例如:
1. First item
2. Second item
3. Third item
    1. Indented item
    2. Indented item
4. Fourth item

效果:

  • First item
  • Second item
  • Third item
    • Indented item
    • Indented item
  • Fourth item

5. 代码语法

要将单词或短语表示为代码,请将其包裹在反引号 (`) 中。
如果要表示为代码的单词或短语中包含一个或多个反引号,则可以通过将单词或短语包裹在双反引号(``)中。
Markdown基本语法通过将行缩进四个空格或一个制表符来创建代码块。若不方便,可在代码块前后的行上使用三个((```)或三个(~~~)。
可以为编写代码的代码块前的反引号旁边指定一种语言以添加语法颜色突出显示。
例如:
`hello world`
''hello world 'and' hello you''
'''java
hello world
hello you
```

hello world
hello world `and` hello you

hello world
hello you

6. 分割线

创建分隔线,即在单独一行上使用三个或多个星号 (***)、破折号 (---) 或下划线 (___) ,并且不能包含其他内容。(三种效果一样)
***
---
——————

效果:




7. 链接语法

链接文本放在中括号内,链接地址放在后面的括号中,链接title可选。
超链接语法:[超链接显示名](超链接地址 "超链接title")。
链接title是当鼠标悬停在链接上时会出现的文字,这个title是可选的,它放在圆括号中链接地址后面,跟链接地址之间以空格分隔。
例如:
这是一个链接 [Markdown语法](https://markdown.com.cn "最好的markdown教程")。

效果:
这是一个链接 Markdown语法

网址和Email地址

使用尖括号把URL或者email地址变成可点击的链接。
例如:<https://markdown.com.cn>

效果:
https://markdown.com.cn

8. 图片语法

添加图像时使用感叹号 (!), 在方括号增加替代文本,图片链接放在圆括号里,括号里的链接后可加一个可选的图片标题文本。
插入图片语法:![图片alt](图片链接 "图片title")。
图片alt:图片链接下的名称。
若要给图片增加链接,将图像的Markdown 括在方括号中,然后将链接添加在圆括号中。
链接图片语法:[![图片alt](图片链接 "图片title")](https://markdown.com.cn)。

9. 表格语法

要添加表,则使用三个或多个连字符(---)创建每列的标题,并使用(|)分隔每列。可以在表的任一端添加(|)。
例如:
| Syntax      | Description |
| ----------- | ----------- |
| Header      | Title       |
| Paragraph   | Text        |

效果:

SyntaxDescription
HeaderTitle
ParagraphText
可以通过在标题行中的连字符的左侧,右侧或两侧添加冒号(:),将列中的文本对齐到左侧,右侧或中心。例如:
| Syntax      | Description | Test Text     |
| :---        |    :---:   |          ---: |
| Header      | Title       | Here's this   |
| Paragraph   | Text        | And more      |

效果:

SyntaxDescriptionTest Text
HeaderTitleHere’s this
ParagraphTextAnd more

可以在表格中设置文本格式。例如,可以添加链接,代码(仅反引号(`)中的单词或短语,而不是代码块)和强调。
不能添加标题,块引用,列表,水平规则,图像或HTML标签。

10. 数学公式写法

Markdown亦可用于编辑LaTex公式,可跨平台编辑、跨环境显示。
LaTex公式语法举例:

运算符说明举例代码
+ x + y x+y x+y$x+y$
- x − y x-y xy$x-y$
\times x × y x \times y x×y$x \times y$
\ast x ∗ y x \ast y xy$x \ast y$
\div x ÷ y x \div y x÷y$x \div y$
\frac分数 x y \frac{x} {y} yx$\frac{x} {y}$
^上标 x y x^y xy$x^y$
_下标 x y x_y xy$x_y$
\sqrt开二次方 x \sqrt x x $\sqrt x$
\sqrt开方 y 4 + 3 y − 1 x \sqrt[x]{y^4+3y-1} xy4+3y1 $\sqrt[x]{y^4+3y-1}$
\pm加减 x ± y x\pm y x±y$x\pm y$
\mp减加 x ∓ y x\mp y xy$x\mp y$
\log对数 log ⁡ 2 ( x ) \log_2(x) log2(x)$\log_2(x)$
\lim极限 lim ⁡ x → 3 \lim_{x\to3} limx3$\lim_{x\to3}$
\displaystyle块公式格式 lim ⁡ x → ∞ \displaystyle \lim_{x\to\infty} xlim$\displaystyle \lim_{x\to\infty}$
\sum求和 ∑ 1 ∞ \sum_1^\infty 1$\sum_1^\infty$
\int积分 ∫ 0 ∞ x 2 × t a n x d x \int_0^\infty x^2\times tanx {\rm d}x 0x2×tanxdx$\int_0^\infty x^2\times tanx {\rm d}x$
\sinsin sin ⁡ x \sin x sinx$\sin x$
\arctanarctan arctan ⁡ x \arctan x arctanx$\arctan x$
\expexp exp ⁡ ( x ) \exp(x) exp(x)$\exp(x)$
\bigtriangleup △ \bigtriangleup △ θ \bigtriangleup \theta θ$\bigtriangleup \theta$

例如:
lim ⁡ x → ∞ x 2 [ arctan ⁡ ( 1 + 1 x ) − arctan ⁡ ( 1 + 1 x + 1 ) ] \displaystyle \lim_{x\to\infty} x^2[\arctan(1+\frac{1}{x})-\arctan(1+\frac{1}{x+1})] xlimx2[arctan(1+x1)arctan(1+x+11)]
$\displaystyle \lim_{x\to\infty} x^2[\arctan(1+\frac{1}{x})-\arctan(1+\frac{1}{x+1})]$

之后会在学习过程中不断更新补充语法。

参考资料

[1] Markdown官方网站:https://markdown.com.cn/
[2] B站视频:https://www.bilibili.com/video/BV1hJ411X75X?from=search&seid=2518490397593523170&spm_id_from=333.337.0.0
[3] CSDN:https://blog.csdn.net/weixin_44879900/article/details/104561781
[4] CSDN:https://blog.csdn.net/LCCFlccf/article/details/89643585

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值