Markdown语法基础Skill markdown-syntax-fundamentals

这个技能提供了Markdown语法的全面指南,涵盖标题、文本格式化、列表、链接、图像、代码块、引用等核心元素。适用于编写和编辑Markdown文件,帮助创建结构清晰、格式规范的文档,便于SEO搜索和文档管理。关键词:Markdown语法、文档编写、文本编辑、代码块、SEO优化。

文档编写 0 次安装 0 次浏览 更新于 3/25/2026

name: markdown-syntax-fundamentals user-invocable: false description: 用于编写或编辑markdown文件时使用。涵盖标题、文本格式化、列表、链接、图像、代码块和引用。 allowed-tools:

  • 读取
  • 写入
  • 编辑
  • Grep
  • Glob

Markdown语法基础

用于创建结构良好文档的核心Markdown语法。

标题

# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6

标题最佳实践

  • 每个文档使用单个H1(#)作为标题
  • 不要跳过标题级别(H2到H4)
  • 保持标题简洁和描述性
  • 一致使用句子大小写或标题大小写

文本格式化

强调

*italic* or _italic_
**bold** or __bold__
***bold italic*** or ___bold italic___
~~strikethrough~~

内联代码

Use `backticks` for inline code like `const x = 1`

列表

无序列表

- Item one
- Item two
  - Nested item
  - Another nested item
- Item three

* Alternative marker
+ Also works

有序列表

1. First item
2. Second item
   1. Nested numbered
   2. Another nested
3. Third item

任务列表(GitHub风格)

- [x] Completed task
- [ ] Incomplete task
- [ ] Another task

链接

基本链接

[Link text](https://example.com)
[Link with title](https://example.com "Title text")

引用链接

[Link text][reference-id]

[reference-id]: https://example.com "Optional title"

自动链接

<https://example.com>
<email@example.com>

内部链接(锚点)

[Jump to section](#section-heading)

锚点ID从标题自动生成:

  • 小写
  • 空格变为连字符
  • 特殊字符被移除

图像

基本图像

![Alt text](image.png)
![Alt text](image.png "Optional title")

引用图像

![Alt text][image-id]

[image-id]: path/to/image.png "Optional title"

链接图像

[![Alt text](image.png)](https://example.com)

代码块

围栏代码块

```javascript
function hello() {
  console.log("Hello, World!");
}
```

常见语言标识符

  • javascript / js
  • typescript / ts
  • python / py
  • bash / shell / sh
  • json / yaml
  • html / css
  • sql
  • markdown / md

缩进代码块

    // Four spaces or one tab
    function example() {
      return true;
    }

引用块

基本引用块

> This is a blockquote.
> It can span multiple lines.

> Blockquotes can contain
>
> Multiple paragraphs.

嵌套引用块

> Outer quote
>> Nested quote
>>> Deeply nested

引用块与其他元素

> ## Heading in blockquote
>
> - List item
> - Another item
>
> ```code block```

水平线

---
***
___

使用三个或更多连字符、星号或下划线。

转义字符

\* Not italic \*
\# Not a heading
\[Not a link\]
\`Not code\`

可以转义的字符:\ ` * _ { } [ ] ( ) # + - . ! |

换行

Line one with two trailing spaces
Line two (hard break)

Line one

Line two (paragraph break)

最佳实践

  1. 一致格式化:选择一种风格并坚持使用
  2. 空白行:在以下元素前后添加空白行:
    • 标题
    • 代码块
    • 列表
    • 引用块
  3. 行长度:考虑在80-120字符处换行以提高可读性
  4. 替代文本:始终为图像提供有意义的替代文本
  5. 链接文本:使用描述性链接文本,而不是“点击这里”
  6. 代码高亮:始终为围栏代码块指定语言