Markdown文档编写指南

摘要

  本文介绍Markdown的语法,明确如何使用各语法编写Markdown文档。


提示:以下是本篇文章正文内容,下面命令及案例可供参考

一、基本语法

1. 标题

  1. 创建标题,在单词或短语前添加井号(#);#的数量便是标题的级别。
  2. 用一个空格在#和标题之间进行分隔。
Do thisDo not do this
# Here 's a heading#Here’s a heading

2. 段落

  1. 不用空格(space)和制表符(Tab)缩进段落;空格使用&nbsp,制表符使用&emsp
Do thisDo not do this

Do not put space and tabs in front of your paragraphs.

Keep lines left-alighed like this.

 Do not put space and tabs in front of your paragraphs.

Keep lines left-alighed like this.

  1. 使用空白行将一行或多行文本进行分隔。

3. 格式

  1. 使用回车键或HTML中的 <br>
  2. 空格符:&nbsp
  3. Tab符:&emsp
  4. 转义字符:\

4. 强调

  1. 使用* 设为斜体
  • 在需要设为斜体 的单词或短语的前后各添加一个型号
  • 格式:*斜体*斜体
  1. 使用** 进行加粗
  • 在需要加粗部分的单词或短语的前后各添加加两个星号
  • 格式:**加粗**加粗
  1. 使用***设为斜体并加粗
  • 在需要加粗部分的单词或短语的前后各添加加三个星号
  • 格式:***斜体并加粗***斜体并加粗

5. 引用

  1. 使用 >进行引用表示。

6. 分隔线

  1. 在单独一行使用三个或多个星号(***)、破折号(—)、下划线(___),且不能包含其他内容。格式:***

7. 链接

  1. 第一种写法:使用尖括号表示链接地址。格式:<超链接地址>
    https://www.csdn.net

  2. 第二种写法:链接文本放在中括号内,链接地址放在括号内,链接title可写可不写。格式: [超链接显示名](超链接地址 "超链接title")

   CSDN

  1. 第三种写法:引用类型链接;引用类型的链接的第一部分使用两组括号进行格式设置。第一组方括号包围应显示为链接的文本。第二组括号显示了一个标签,该标签用于指向您存储在文档其他位置的链接,即第二组“ [?]:???” 可以编写在文章中其他位置。 格式:[CSDN][1] [1]: https://www.csdn.net

   CSDN

  1. 第四种写法:使用星号,使链接带格式(星号和反引号前后需要用空格与其他文本分隔开)。格式:**[CSDN](https://www.csdn.net) ***[CSDN](https://www.csdn.net) *

   这是一个 CSDN 上的文章。
   这是一个 CSDN 上的文章。

8. 列表

8.1 无序列表

格式:

- First item
- Second item
- Third item

Markdown中显示:

  • First item
  • Second item
    • Second 1
    • Second 2
    • Second 3
  • Third item

8.2 有序列表

格式:

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

Markdown中显示:

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

二、扩展语法

1. 代码块

  1. 在代码块的前后各添加三个反引号(```),形成围栏代码块;在受防护的代码块之前的反引号旁边指定一种语言。
    格式:

     ```cpp
     	#include <iostream>
     	using namespace std;
     	int main(){
     	&emsp;&emsp;cout << "hello world!" << endl;
     	&emsp;&emsp;retrun 0;
     	}
     ```
    

Markdown中显示:

#include <iostream>
using namespace std;
int main(void){
	cout << "hello world!" << endl;
	retrun 0;
}
  1. 常用的代码块语言:
  • Javascript:js
  • C:c
  • C++:cpp
  • Python:python
  • HTML:html
  • Bash:bash
  • Shell:shell
  • PowerShell:ps
  • JSON:json

2. 表格

  1. 使用三个或多个连字符(—)创建每列标题,并使用管道(|)分隔每列。
  2. 表格中内容的对齐方式。
  • |:---|表示左对齐;
  • |:---:|表示居中对齐;
  • |---:|表示右对齐。
| 第一列 | 第二列 | 第三列|
|:---|:---:|---:|
| 左对齐 | 居中对齐 | 右对齐 |

Markdown中显示:

第一列第二列第三列
左对齐居中对齐右对齐

3. 定义列表

格式:

First Term 
: This is the definition of the first term.

Second Term
: This is one definition of the second term.
: This is another definition of the second term.

Markdown中显示:

First Term
This is the definition of the first term.
Second Term
This is one definition of the second term.
This is another definition of the second term.

4. 删除线

格式:

~~文本~~

Markdown中显示:
文本

5. 任务列表

格式:

- [x] The first element
- [ ] The second element
- [ ] The third element

Markdown中显示:

  • Write the press release
  • Update the website
  • Contact the media

6. 脚注

格式:

Here's a sentence with a footnote. [^1]
[^1]: This is the footnote.

Markdown中显示:
Here’s a sentence with a footnote. 1

三、参考文献

1 Markdown官方教程
[2] Matt Cone. 《The Markdown Guide》. 2020.6


  1. This is the footnote. ↩︎

  • 18
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值