学习 Markdown
什么是 Markdown
什么是 Markdown?Markdown 是一种轻量级的「标记语言」,通常为程序员群体所用,目前它已是全球最大的技术分享网站 GitHub 和技术问答网站 StackOverFlow 的御用书写格式。
基本语法
这些是 John Gruber 的原始设计文档中列出的元素。所有 Markdown 应用程序都支持这些元素。
标题
1 | # 一级标题 |
渲染为
引用块(Blockquote)
1 | > Dorothy followed her through many of the beautiful rooms in her castle. |
渲染为
Dorothy followed her through many of the beautiful rooms in her castle.
Dorothy followed her through many of the beautiful rooms in her castle.
The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
带有标题的引用快:
1 | > ### The quarterly results look great! |
The quarterly results look great!
Revenue was off the chart.
Profits were higher than ever.
Everything is going according to plan.
代码(Code)
1 | `code` |
渲染为
code
Use `code` in your Markdown file.
要创建代码块,请将代码块的每一行缩进至少四个空格或一个制表符。
1 | <html> |
<html>
<head>
</head>
</html>
分隔线(Horizontal Rule)
至少一个以上的
1 | --- |
渲染结果:
链接(Link)
1 | [title](https://www.example.com)<br> |
渲染为
title
这是一个链接 Markdown 语法。
网址和 Email 地址:
https://markdown.com.cn
fake@example.com
图片(Image)
1 |  |
渲染为
表格(Table)
1 | | Syntax | Description | |
渲染结果:
Syntax | Description |
---|---|
Header | Title |
Paragraph | Text |
围栏代码块(Fenced Code Block)
渲染为:
1 | { |
删除线(Strikethrough)
1 | ~~The world is flat.~~ |
像这样
The world is flat.
段落
1 | I really like using Markdown. |
渲染为:
I really like using Markdown.
I think I’ll use it to format all of my documents from now on.
I think I’ll use
I think I’ll use it to format all of my documents from now on.
段落于段落之间添加一行空行就可以了
不要用空格(spaces)或制表符( tabs)缩进段落。
换行语法
目前换行语法存在争议,市面上流行的换行语法有三种
末尾空格
1 | This is the first line. |
末尾斜杠
1 | This is the first line.\ |
<br>标签
1 | This is the first line.<br> |
This is the first line.
And this is the second line.
兼容性最好的莫过于末尾
标签了
强调语法
粗体
斜体
粗斜体
1 | I **Love** You <br> |
I Love You
I Love You
This is really very important text.
有序列表(Ordered List)
1 | 1. First item |
渲染为
- First item
- Second item
- Third item
无序列表(Unordered List)
1 | - First item |
渲染为
- First item
- Second item
- Third item
任务列表(Task List)
1 | - [x] Write the press release |
渲染为
- [x] Write the press release
- [ ] Update the website
- [ ] Contact the media
通常列表之间可以嵌套
1 | 1. 一级条目 |
-
一级条目
-
一级条目
- 二级条目
- 二级条目
- [ ] 三级条目
- 三级条目
- 四级条目
- [ ] 四级条目
- [ ] 四级条目
- 四级条目
- 三级条目
- 二级条目
-
一级条目
-
一级条目
这里引用
-
一级条目
四个tab为一个块
-
一级条目
转义符
要显示原本用于格式化 Markdown 文档的字符,请在字符前面添加反斜杠字符\
1 | \*\*这行文字没有被加粗\*\* \ |
**这行文字没有被加粗**
* Without the backslash, this would be a bullet in an unordered list.
内嵌 HTML 标签
一般情况下,markdown 都支持内嵌 HTML 语法
如 <div>
、<table>
、<pre>
和 <p>
等,请在其前后使用空行(blank lines)与其它内容进行分隔。
扩展语法
这些元素通过添加额外的功能扩展了基本语法。但是,并非所有 Markdown 应用程序都支持这些元素。
脚注(Footnote)
1 | Here's a sentence with a footnote. [^1] |
渲染结果:
Here’s a sentence with a footnote. [^1]
[^1]: This is the footnote.
标题编号(Heading ID)
1 | ### My Great Heading {#custom-id} |
渲染出来的 html 像这样
1 | <h3 id="custom-id">My Great Heading</h3> |
工具与格式化
一般 Markdown 文件的后缀名为 .md
如 技术说明.md
我编写 markdown 时采用的是 VScode,非常强大\
再配合两款插件
markdown 的写作体验非常好
prettier 主要用作 markdown 的格式化问题
图床问题
个人史是白嫖七牛云的图片服务器,然后配合
写作的时候一边截图然后直接复制进图床,copy 链接到 Markdown 中就好了
推荐客户端
下载地址:
https://github.com/willnewii/qiniuClient
结束语
当掌握 Markdown 时,写作分享也可以是一种享受