Markdown的用法

前言

本文对markdown进行简要概述,以后把Markdown用起来!

一、Markdown 是什么?

Markdown 是一种轻量级的标记语言,可用于在纯文本文档中添加格式化元素。Markdown 由 John Gruber 于 2004 年创建,如今已成为世界上最受欢迎的标记语言之一。

  1. 专注于文字内容;

  2. 纯文本,易读易写,可以方便地纳入版本控制;

  3. 语法简单,没有什么学习成本,能轻松在码字的同时做出美观大方的排版。

二、Markdown 的编辑器

本地可以使用Visual Studio Code或者Typora。

也有许多在线的编辑器

  1. https://markdown.com.cn/editor/
  2. https://c.runoob.com/front-end/712/

三、基本语法

这些是 John Gruber 的原始设计文档中列出的元素。所有 Markdown 应用程序都支持这些元素。

1.标题(Heading)

# H1
## H2
### H3

H1

H2

H3

2.粗体(Bold)

**bold text**

bold text

3.斜体(Italic)

*italicized text*

italicized text

4.引用块(Blockquote)

> blockquote

blockquote

5.有序列表(Ordered List)

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

6.无序列表(Unordered List)

- First item
- Second item
- Third item
  • First item
  • Second item
  • Third item

7.代码(Code)

`code`

code

8.分隔线(Horizontal Rule)

---

8.链接(Link)

[title](https://www.example.com)

title

8.图片(Image)

![alt text](image.jpg)

在这里插入图片描述

四、扩展语法

这些元素通过添加额外的功能扩展了基本语法。但是,并非所有 Markdown 应用程序都支持这些元素。

1.表格(Table)

| Syntax      | Description |
| ----------- | ----------- |
| Header      | Title       |
| Paragraph   | Text        |
SyntaxDescription
HeaderTitle
ParagraphText

2.代码块(Fenced Code Block)

{
  "firstName": "John",
  "lastName": "Smith",
  "age": 25
}
{
  "firstName": "John",
  "lastName": "Smith",
  "age": 25
}

3.脚注(Footnote)

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

Here’s a sentence with a footnote. 1

4.标题编号(Heading ID)

### My Great Heading {#custom-id}

My Great Heading {#custom-id}

5.定义列表(Definition List)

term
: definition
term
definition

6.删除线(Strikethrough)

~~The world is flat.~~

The world is flat.

7.任务列表(Task List)

- [x] Write the press release
- [ ] Update the website
- [ ] Contact the media
  • Write the press release
  • Update the website
  • Contact the media

五、Markdown 高级技巧

1.Markdown 转义字符语法

要显示原本用于格式化 Markdown 文档的字符,请在字符前面添加反斜杠字符 \ 。

\* Without the backslash, this would be a bullet in an unordered list.

* Without the backslash, this would be a bullet in an unordered list.

  • Without the backslash, this would be a bullet in an unordered list.

2.Markdown 内嵌 HTML 标签

This **word** is bold. This <em>word</em> is italic.

This word is bold. This word is italic.

使用 <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Del</kbd> 重启电脑

使用 Ctrl+Alt+Del 重启电脑

3.Markdown 使用 Emoji 表情

去露营了! :tent: 很快回来。

真好笑! :joy:

去露营了! ⛺️ 很快回来。

真好笑! 😂

4.自动网址链接

许多Markdown处理器会自动将URL转换为链接。这意味着如果您输入http://www.example.com,即使您未使用方括号,您的Markdown处理器也会自动将其转换为链接。

禁用自动URL链接

如果您不希望自动链接URL,则可以通过将URL表示为带反引号的代码来删除该链接。

`http://www.example.com`

http://www.example.com

5.公式

Markdown Preview Enhanced 使用 KaTeX 或者 MathJax 来渲染数学表达式。

KaTeX 拥有比 MathJax 更快的性能,但是它却少了很多 MathJax 拥有的特性。你可以查看 KaTeX supported functions/symbols 来了解 KaTeX 支持那些符号和函数。

默认下的分隔符:

$...$ 或者 \(...\) 中的数学表达式将会在行内显示。
$$...$$ 或者 \[...\] 或者 ```math 中的数学表达式将会在块内显示。
$$
\begin{Bmatrix}
   a & b \\
   c & d
\end{Bmatrix}
$$

{ a b c d } \begin{Bmatrix} a & b \\ c & d \end{Bmatrix} {acbd}

typora 甚至可以画 流程图、时序图(顺序图)、甘特图

六、总结

Markdown 无处不在。StackOverflow、CSDN、掘金、简书、GitBook、有道云笔记、V2EX、光谷社区等。主流的代码托管平台,如 GitHub、GitLab、BitBucket、Coding、Gitee 等等,都支持 Markdown 语法,很多开源项目的 README、开发文档、帮助文档、Wiki 等都用 Markdown 写作。

我们可以在网站、文件资料、笔记、书籍、演示文稿、邮件、文档中使用它


  1. This is the footnote. ↩︎

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值