在markedown中,你可以简单的理解为markedown是html和css的结合的plus版本,用于能够快速的生成你想要的页面文章。开玩笑的讲,我们不可能用html标签在上面写文章吧哈哈哈哈哈哈,写段话加<p>
、写标题又要加<h>
,因此这样做会非常麻烦,所以促成了Typora这类markdown工具的诞生。本章是介绍简单的Markdown基础语法,旨在能够帮你快速入门。
标题
标题有1-6级标题。语法:#
+空格
段落
除非段落在列表中,否则不要用空格或制表符缩进段落,列表会在下面讲解。
# this is a test <!--不显示一级标签,因为会打乱目录结构,请自行复制测试 -->
## this is a test
### this is a test
#### this is a test
#### this is a test
##### this is a test
###### this is a test
this is a paragraph
this is a paragraph
效果:
this is a test
this is a test
this is a test
this is a test
this is a test
this is a test
this is a paragraph
this is a paragraph
粗体和斜体
语法:
粗体**文字**
斜体*文字*
**粗体**
*斜体*
***粗体斜体***
效果:
粗体
斜体
粗体斜体
块引用
块引用顾名思义就是一行或一列来引用名言或者关键代码等,突出其重要性。语法:>
+空格
> 这是一个块引用
> 这是一个多个段落块引用
>
> 这是一个多个段落块引用
> 这是一个嵌套块引用
>
> >这是嵌套
> ### 带有其它元素的块引用
>
> - 这是一个列表1
>
> - 这是一个列表2
>
> *这个*列表表现的非常**好**
效果:
这是一个块引用
这是一个多个段落块引用
这是一个多个段落块引用
这是一个嵌套块引用
这是嵌套
带有其它元素的块引用
这是一个列表1
这是一个列表2
这个列表表现的非常好
列表
列表分为有序和无序。
语法:
有序列表1.
+空格
无序列表+
or -
or *
+空格
有序列表
要创建有序列表,数字不必按数学顺序排列,但是列表应当以数字 1 起始。缩进一个或多个列表项可创建嵌套列表。1)
一般不推荐使用,因为这种格式可能不会在其它makedown编辑器中显示并且可能在网站上显示列表时出现异常。
1. First item
2. Second item
3. Third item
4. Fourth item
1) First item
2) Second item
3) Third item
1. Indented item
2. Indented item
4) Fourth item
效果:
- First item
- Second item
- Third item
- Fourth item
- First item
- Second item
- Third item
- Indented item
- Indented item
- Fourth item
无序列表
要创建无序列表,请在每个列表项前面添加破折号 (-
)、星号 (*
) 或加号 (+
) 。要注意的是最好使用+
、-
、*
其中的一个来创建无序列表,否则可能会造成页面异常。
* 1
+ 2
- 3
* 1
* 2
* 1
* 2
* 3
效果:
- 1
- 2
- 3
- 1
- 2
- 1
- 2
- 3
以数字开头的无序列表项
如果你需要以数字开头并且紧跟一个英文句号(也就是 .
)的无序列表项,则可以使使用反斜线(\
)来 转义这个英文句号。
* 2023\.12\.8
* 2023\.12\.8 a great year
效果:
- 2023.12.15
- 2023.12.15 a great year
在列表中添加列表项
要在保留列表连续性的同时在列表中添加另一种元素,请将该元素缩进四个空格或一个制表符。
段落
* this is the fist list
* here is the second list item
this is a paragraph
* and here's the third list item
效果:
-
this is the fist list
-
here is the second list item
this is a paragraph
-
and here’s the third list item
引用块
* this is the fist list
* here is the second list item
> this is a block
* and here's the third list item
效果:
-
this is the fist list
-
here is the second list item
this is a block
-
and here’s the third list item
无序列表嵌套有序列表中,反之亦然。
1. fist
2. second
* index
效果:
- fist
- second
- index
在列表中嵌入代码块
代码块通常采用四个空格或一个制表符缩进。当它们被放在列表中时,请将它们缩进八个空格或两个制表符。
1. open the file.
2. find the fllowing code block on line 21:
```html
<html>
<head>
<title>Test</title>
</head>
</html>
```
3. update the title to match the name of your websit
效果:
- open the file.
- find the fllowing code block on line 21:
<html>
<head>
<title>Test</title>
</head>
</html>
- update the title to match the name of your websit
图片
要添加图片。全部语法:[![显示失败会出现这句话!](图片资源的路径或 URL '提示语句')](跳转目标URL)
如果只想显示图片,那么![显示失败会出现这句话!](图片资源的路径或 URL)
就够了。
![If the display fails, this sentence will appear!](https://ooo.0x0.ooo/2023/12/15/OKOeiC.th.png 'Click on the image to go to Eli's blog')
效果:
带链接的图片
要为图片添加链接,请先为图片的 Markdown 标记添加一个方括号,然后紧跟着一个圆括号,并在圆括号中添加链接地址。
[![If the display fails, this sentence will appear!](https://ooo.0x0.ooo/2023/12/15/OKOr4L.jpg)](http://b-s-x.com)
效果:
代码
要将单词或短语表示为代码,请将其包裹在反引号`````中。
语法:
普通代码:
`code`
or ``code``
Use `code` in your Markdown file.
代码块:
`code block`
普通代码
I work `very` hard
``Use code in your Markdown file.``
``Use `code` in your Markdown file.``
效果:
I work very
hard
Use code in your Markdown file.
Use `code` in your Markdown file.
代码块
```c
include <stdio.h>
int main (void)
{
printf('I work very hard\n');
return 0;
}
```
效果:
include <stdio.h>
int main (void)
{
printf('I work very hard\n');
return 0;
}
分隔线
要创建分隔线,请在单独一行上使用三个或多个星号 (***
)、破折号 (---
) 或下划线 (___
) ,并且不能包含其他内容。于我而言,我个人倾向使用***
,当然没有什么好坏之分,仅仅为个人习惯。
---
***
___
分隔线用法最佳实践
为了兼容性,请在分隔线的前后均添加空白行。
this is a paragraph
this is a paragraph
链接
要创建链接。全部语法:[链接名称](跳转目标URL '链接提示')
链接时增加提示
这是bsx的[博客](http://b-s-x.com 'The best blog web')链接
效果:
这是bsx的博客链接
网址和电子邮件地址
要将 URL 或电子邮件地址快速转换为链接。语法:<跳转目标URL或电子邮件地址>
<http://b-s-x.com >
**<http://b-s-x.com>**
*<http://b-s-x.com>*
***<http://b-s-x.com>***
效果:
引用式链接
可用于论文等引用导向类地址(效果不能正常显示,原因可能是因为Butterfly主题渲染失败,语法是正确的)。
语法:
[名称][标记]
[标记]: url "description" this paragraph will appear last.
[Eli][1]
[1]: http://b-s-x.com "这是链接描述"
效果:
链接的最佳使用实践
不同的 Markdown 应用程序在处理 URL 中间的空格方面是不一样的。为了兼容起见,请尽量使用 %20
(空格的编码形式)来代替空格。
[link](https://www.example.com/my%20great%20page) **✅**
[link](https://www.example.com/my great page)**❌**
效果:
link ✅
[link](https://www.example.com/my great page)❌
转义字符
\* 如果没有开头的反斜杠字符`\`的话,这一行将显示为无序列表。
效果:
* 如果没有开头的反斜杠字符\
的话,这一行将显示为无序列表。
不足与反馈
笔者深感个人知识有限,希望文章中出现的各种错误能够在留言区告知我,我会立刻修改,学习如逆水行舟,不进则退。
写在最后
笔者现在使用的是Typora
这款超棒的markdown编辑器来书写博客,当然它上面也支持不使用markedown语法的相应的功能键,不懂语法盆友也可以简单上手,附上Typora下载链接:https://pan.baidu.com/s/12iShCkQ0hEyCeG6IN_PmvQ?pwd=eeli提取码eeli
如果您觉得这篇文章对您有帮助,不妨打赏一下Eli的这篇文章哟~~