Markdown常用语法
一、基本语法
参考来源:https://www.markdownguide.org/cheat-sheet/
1.1 大纲级别
句首:若干个"#"+一个空格,后接文本。如: "### level 3"
示例
level 1
level 2
level 3
level 4
level 5
对应写法:
# level 1
## level 2
### level 3
#### level 4
##### level 5
1.2 分行及分段
分行,在行尾:增加两个空格,或者"<br>" 。 不太人性化,要养成习惯!
分段,在行尾:打两个换行就可以。
示例及写法
The first line with 2 spaces. 后面有两个空格
The second line with <br> 后面有一个<br>
The third line.后面有两个换行
Next paragragh.
1.3 粗体和斜体
文本前后:增加1-3个"*"
示例
italic text
bold text
bold and italic text
对应写法:
*italic text*
**bold text**
***bold and italic text***
1.4 块引用
段前或者行前:加">"
示例
>
Begin with a >, you can see.(此处两个空格)
The second line is still working.(此处两个换行)
这是两个换行形成的新block,已经超出第一个">"的作用域了
下面看嵌套效果:
>
if you want to nest,
>>
just make it ,
>>>
still works.
1.5 列表
有序列表,句首 : 加 "1."+空格,后接文本。
无序列表,句首 : 加 "- "+空格,后接文本。
缩进:可以用四个空格或一个tab。
有序列表
- this is the first line ordered list
rendered - the second line
- bababa
- lalala
对应写法:
1. this is the first line ordered list
rendered
1. the second line
1. bababa
1. lalala
无序列表
- this is the first line of unordered list
rendered - the second line of unordered list
- bababa
- lalala
对应写法:
- this is the first line of unordered list
rendered
- the second line of unordered list
- bababa
- lalala
1.6 编码形式的引用
句中文本的前后:加"`" 或者 "``" (如果文本中已经包含"`"的话)
对句中的文本
this is code
this is `code` with `
对应写法:
this is `code`
this is `` `code` with ` ``
文本块首: 加四个空格,或者一个tab
对整个文本块block
This is text. (两个换行)
this is code block
对应写法:
This is text. (两个换行)
this is code block
1.7 图片和链接
图片: ![文字描述](图片的本地存储位置或图片自身的链接地址)
链接: [文字描述](链接地址)
带链接的图片: 同理,在“链接”的文字描述部分,写“图片”信息即可。
示例
- 图片:
- 链接:
Hello from xingzipss
对应写法:
- 图片:
![xingzipss.logo](../assets/logo.png)
- 链接:
[Hello from xingzipss](../index.md)
1.8 水平分割线
整行写: "***" 或 "---" 或 "___" ,注意行前行后要加空行。
示例
block 1 ( blank line after)
(blank line before) block 2
对应写法:
block 1 ( blank line after)
---
(blank line before) block 2
1.9 让Url和邮件自带链接的方便对应写法
用尖括号括起来: "<"url/email地址">"
二、扩展语法
在Material for MkDocs主题中可用,这里的绝大部分需要在mkdocs.yml里的markdown_extensions:增加如下相应的配置项。
- pymdownx.tasklist
示例
- item 1
- item A
- item B
more text
- item a
- item b
- item c
- item C
- item 2
- item 3
对应写法:
- [X] item 1
* [X] item A
* [ ] item B
more text
+ [x] item a
+ [ ] item b
+ [x] item c
* [X] item C
- [ ] item 2
- [ ] item 3
- pymdownx.caret
示例
This was inserted
H2O
对应写法:
^^This was inserted^^
H^2^O
- pymdownx.mark
示例
This was marked
对应写法:
==This was marked==
- pymdownx.tilde
示例
This was deleted
text a subscript (注意下标中的空格前要加上\
)
对应写法:
~~This was deleted~~
text ~a\ subscript~ (注意下标中的空格前要加上`\`)
- pymdownx.critic
示例及写法
{-- delete --}
{++ add ++}
{~~ one~>a single~~}
{== highlight==}
{>> comments<<}
- abbr
示例
The HTML specification is maintained by the W3C.
对应写法:
The HTML specification is maintained by the W3C.
*[HTML]: Hyper Text Markup Language
*[W3C]: World Wide Web Consortiumi
- footnotes
脚注,需要分别做两件事:
1. 插标注:在要插入脚注数字标注的地方,写上[^数字]
2. 写注解:在文件正文上下任何位置都可以添加对应的注解,有多寡两种写法。
点击->脚注示例查看。
- admonition
!!! type "title",如
note or anything
(四个空格)里面的文字
Abstract
(四个空格)里面的文字
对应写法:
!!! note "note or anything"
(四个空格)里面的文字
!!! abstract
(四个空格)里面的文字
下面是其他的type
Info
Success
Question
Warning
Failure
Danger
Tip
Bug
Example
到底了,将来有需要再添~~