Kanade's Dev Journal

Markdown 语法快速入门

Published on
Published on
/4 mins read/---

什么是 Markdown

Markdown 是一种轻量级标记语言,用于格式化文本内容。它通过简单的标记符号(如 #*)来控制文本的显示方式,例如加粗、斜体、插入图片或创建列表等。

语法指南

以下是常见 Markdown 语法的总结,适用于 GitHub 或任何支持 Markdown 的平台。

标题

# This is a h1 tag

## This is a h2 tag

#### This is a h4 tag

This is a h1 tag

This is a h2 tag

This is a h4 tag

强调文本

你可以通过 _** 来使文本斜体或加粗:

_This text will be italic_

**This text will be bold**

_You **can** combine them_

This text will be italic

This text will be bold

You can combine them

列表

无序列表

- Item 1
- Item 2
  - Item 2a
  - Item 2b
  • Item 1
  • Item 2
    • Item 2a
    • Item 2b

有序列表

1. Item 1
1. Item 2
1. Item 3
   1. Item 3a
   1. Item 3b
  1. Item 1
  2. Item 2
  3. Item 3
    1. Item 3a
    2. Item 3b

插入图片

使用 ![Alt Text](url) 格式插入图片:

![GitHub Logo](https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png)

GitHub Logo

超链接

插入链接时可以使用纯 URL 或 Markdown 链接格式:

http://github.com - automatic!
[GitHub](http://github.com)

http://github.com - automatic! GitHub

块引用

使用 > 来创建引用文本:

As Kanye West said:

> We're living the future so
> the present is our past.

As Kanye West said:

We're living the future so the present is our past.

行内代码

使用反引号 包裹代码:

I think you should use an `<addr>` element here instead.

I think you should use an <addr> element here instead.

语法高亮

使用 GitHub Flavored Markdown 配合 mdx-prism 插件,实现代码高亮:

```js:fancyAlert.js
function fancyAlert(arg) {
  if (arg) {
    $.facebox({ div: '#foo' })
  }
}
```

效果如下——带有样式代码标题的漂亮颜色!

fancyAlert.js
function fancyAlert(arg) {
  if (arg) {
    $.facebox({ div: '#foo' })
  }
}

脚注

可以通过 1 插入脚注并进行引用:

Here is a simple footnote[^1]. With some additional text after it.

[^1]: My reference.

Here is a simple footnote1. With some additional text after it.

任务列表

创建任务列表时,你可以通过 - [ ] 和 - [x] 来标记任务的完成状态:

- [x] list syntax required (any unordered or ordered list supported)
- [x] this is a complete item
- [ ] this is an incomplete item
  • list syntax required (any unordered or ordered list supported)
  • this is a complete item
  • this is an incomplete item

表格

通过 | 来创建表格,分隔不同的列:

| First Header                | Second Header                |
| --------------------------- | ---------------------------- |
| Content from cell 1         | Content from cell 2          |
| Content in the first column | Content in the second column |
First HeaderSecond Header
Content from cell 1Content from cell 2
Content in the first columnContent in the second column

删除线

~~ 包裹文本,实现删除线效果:

crossed out.

Happy reading!

Footnotes

  1. My reference. 2