Markdown基本格式语法

Markdown基本格式语法

网络上已经有不少Markdown格式语法的文档,本篇文章来源于网络,为了使用时寻找更为便捷。

本文基于以下文章整理而成

标题

结果

A first-level heading

A second-level heading

A third-level heading

语法

# A first-level heading
## A second-level heading
### A third-level heading

格式化文本

格式 语法 示例 输出
加粗 ** ** 或 __ __ **加粗文本** 加粗文本
斜体 * * 或 _ _ _斜体文本_ 斜体文本
中划线 ~~ ~~ 或 ~ ~ ~~中划线文本~~ 中划线文本
加粗内置倾斜 ** ** 或 _ _ **加粗_内置中划线_文本** 加粗_内置中划线_文本
全加粗倾斜 *** *** ***全加粗倾斜*** 全加粗倾斜
下表 <sub> </sub> 这是<sub>下表</sub>文本 这是下表文本
上标 <sup> </sup> 这是<sup>上标</sup>文本 这是上标文本
下划线 <ins> </ins> 这是<ins>下划线</ins>文本 这是下划线文本

引用文本

结果

Text that is not a quote

Text that is a quote

语法

Text that is not a quote

> Text that is a quote

引用代码

结果

Use git status to list all new or modified files that haven't yet been committed.

语法

Use `git status` to list all new or modified files that haven't yet been committed.

结果2

Some basic Git commands are:

git status
git add
git commit

语法2

Some basic Git commands are:
```
git status
git add
git commit
```
  • 备注
    • 如果在```内部需要包含```的话,可以外面一层是4个`,里面一层是3个`
    • 只要外面的`个数比里面的多就可以

支持的颜色模型(在github生效)

结果

The background color is #ffffff for light mode and #000000 for dark mode.

语法

The background color is `#ffffff` for light mode and `#000000` for dark mode.

链接

结果

This site was built using GitHub Pages.

语法

This site was built using [GitHub Pages](https://pages.github.com/).

章节链接

  • 原则
    • 字母转为小写
    • 空格替换为连字符(-)。其他的空白或符号都会移除
    • 首位空格移除
    • 标记格式也移除,只保留内容(如移除斜体)
    • 如果某个标题自动生成的锚点与之前的相同,则会按照自增的方式生成唯一标识符

语法


# Example headings

## Sample Section

## This'll be a _Helpful_ Section About the Greek Letter Θ!
A heading containing characters not allowed in fragments, UTF-8 characters, two consecutive spaces between the first and second words, and formatting.

## This heading is not unique in the file

TEXT 1

## This heading is not unique in the file

TEXT 2

# Links to the example headings above

Link to the sample section: [Link Text](#sample-section).

Link to the helpful section: [Link Text](#thisll-be-a-helpful-section-about-the-greek-letter-Θ).

Link to the first non-unique section: [Link Text](#this-heading-is-not-unique-in-the-file).

Link to the second non-unique section: [Link Text](#this-heading-is-not-unique-in-the-file-1).

相对链接

需要同级文档,先不展示这个结果

语法

[Contribution guidelines for this project](docs/CONTRIBUTING.md)

自定义锚点(在github生效)

语法

# Section Heading

Some body text of this section.

<a name="my-custom-anchor-point"></a>
Some text I want to provide a direct link to, but which doesn't have its own heading.

(… more content…)

[A link to that custom anchor](#my-custom-anchor-point)

换行符

结果

This example
Will span two lines

语法1

在第一行末包含两个空格

This example  
Will span two lines

语法2

在第一行末包含两个反斜线

This example\
Will span two lines

语法3

在第一行末包含html换行符

This example<br/>
Will span two lines

图片

结果

示例图片

语法

![示例图片](https://fastly.jsdelivr.net/gh/weimingwm86/weiming-pics@master/pics1/testpng.png)
  • 备注
    • 也可以使用相对路径

列表

结果

  • George Washington
  • John Adams
  • Thomas Jefferson

语法

- George Washington
* John Adams
+ Thomas Jefferson

有序列表

结果

  1. James Madison
  2. James Monroe
  3. John Quincy Adams

语法

1. James Madison
2. James Monroe
3. John Quincy Adams

嵌套列表

结果

  • First list item
    • First nested list item
      • Second nested list item

语法

- First list item
  - First nested list item
    - Second nested list item

任务列表

结果

语法

- [x] #739
- [ ] https://github.com/octo-org/octo-repo/issues/740
- [ ] Add delight to the experience when all tasks are complete :tada:

提及人员和团队(在github生效)

语法

@github/support What do you think about these updates?

使用emojis(在github生效)

语法

@octocat :+1: This PR looks great - it's ready to merge! :shipit:

附注(在github生效)

语法

Here is a simple footnote[^1].

A footnote can also have multiple lines[^2].

[^1]: My reference.
[^2]: To add line breaks within a footnote, add 2 spaces to the end of a line.  
This is a second line.

警告(在github生效)

语法

> [!NOTE]
> Useful information that users should know, even when skimming content.

> [!TIP]
> Helpful advice for doing things better or more easily.

> [!IMPORTANT]
> Key information users need to know to achieve their goal.

> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.

> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.

隐藏内容

结果

语法

<!-- This content will not appear in the rendered Markdown -->

无视markdown格式

结果

Let's rename *our-new-project* to *our-old-project*.

语法

Let's rename \*our-new-project\* to \*our-old-project\*.

tag

  • markdown
  • github
posted @ 2026-03-01 00:04  微明Studio  阅读(7)  评论(0)    收藏  举报