当前位置: 首页 > news >正文

Markdown写作常用组件 - Invinc

本文总结了Markdown中一些基本的语法和经常使用的组件环境,方便在写作过程中随时复制使用。


基本语法

标题

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

段落

要创建段落,请使用空白行将一行或多行文本进行分隔。

I really like using Markdown.I think I'll use it to format all of my documents from now on.

换行

在一行的末尾添加两个或多个空格,然后按回车键,即可创建一个换行(<br>)。

This is the first line.  
And this is the second line.

强调

**粗体**
*斜体*
***粗斜体***

粗体

斜体

粗斜体

引用

要创建块引用,请在段落前添加一个 > 符号。

> 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.

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.

嵌套块引用

> 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.

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. First item
2. Second item
3. Third item- Indented item- Indented item
4. Fourth item
  1. First item
  2. Second item
  3. Third item
    • Indented item
    • Indented item
  4. Fourth item

行中代码

要将单词或短语表示为代码,请将其包裹在反引号 (`) 中。转义反引号可以通过将单词或短语包裹在双反引号(``)中。

At the command prompt, type `nano`.``Use `code` in your Markdown file.``

At the command prompt, type nano.

Use `code` in your Markdown file.

分隔线

为了兼容性,请在分隔线的前后均添加空白行。

Try to put a blank line before...---...and after a horizontal rule.

链接

基本语法

这是一个链接 [Markdown语法](https://markdown.com.cn)。

这是一个链接 Markdown语法。

给链接增加 Title

链接title是当鼠标悬停在链接上时会出现的文字,这个title是可选的,它放在圆括号中链接地址后面,跟链接地址之间以空格分隔。

这是一个链接 [Markdown语法](https://markdown.com.cn "最好的markdown教程")。

这是一个链接 Markdown语法。

网址和Email地址

使用尖括号可以很方便地把URL或者email地址变成可点击的链接。

<https://markdown.com.cn>
<fake@example.com>

https://markdown.com.cn

fake@example.com

带格式化的链接

I love supporting the **[EFF](https://eff.org)**.
This is the *[Markdown Guide](https://www.markdownguide.org)*.

I love supporting the EFF.

This is the Markdown Guide.

图片

要添加图像,请使用感叹号 (!), 然后在方括号增加替代文本,图片链接(可以是本地或网页图片)放在圆括号里,括号里的链接后可以增加一个可选的图片标题文本。

插入图片Markdown语法代码:![图片alt](图片链接 "图片title")

![这是图片](/assets/img/philly-magic-garden.jpg "Magic Gardens")

转义字符

要显示原本用于格式化 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.

可做转义的字符

Character Name
\ backslash
` backtick
* asterisk
_ underscore
{} curly braces
[] brackets
() parentheses
# pound sign
+ plus sign
- minus sign (hyphen)
. dot
! exclamation mark
| pipe

特殊字符自动转义

在 HTML 文件中,有两个字符需要特殊处理: <&< 符号用于起始标签,& 符号则用于标记 HTML 实体,如果你只是想要使用这些符号,你必须要使用实体的形式,像是 &lt;&amp;,对应的 >&gt;

在 Markdown 的块级元素和内联元素中, <& 两个符号都会被自动转换。

在 HTML 语法(包括在 Markdown 文件中使用的 HTML 语法)中,要手动把所有的 <& 都转换为 HTML 实体。

Markdown 内嵌 HTML 标签

行级內联标签

HTML 的行级內联标签如 <span><cite><del> 不受限制,可以在 Markdown 的段落、列表或是标题里任意使用。HTML 行级內联标签和区块标签不同,在內联标签的范围内, Markdown 的语法是可以解析的。

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

渲染效果如下:
This word is bold. This word is italic.

区块标签

区块元素──比如 <div><table><pre><p> 等标签,必须在前后加上空行,以便于内容区分。而且这些标签的开始与结尾标签,不可以用 tab 或是空白来缩进。Markdown 会自动识别这区块元素,避免在区块标签前后加上没有必要的 <p> 标签。
例如,在 Markdown 文件里加上一段 HTML 表格:.

This is a regular paragraph.<table><tr><td>Foo</td></tr>
</table>This is another regular paragraph.

请注意,Markdown 语法在 HTML 区块标签中将不会被进行处理。


扩展语法

表格

要添加表,请使用三个或多个连字符(---)创建每列的标题,并使用管道(|)分隔每列。您可以选择在表的任一端添加管道。

| Syntax      | Description |
| ----------- | ----------- |
| Header      | Title       |
| Paragraph   | Text        |

呈现的输出如下所示:

Syntax Description
Header Title
Paragraph Text

可以在表格中设置文本格式。例如,您可以添加链接,代码(仅反引号(`)中的单词或短语,而不是代码块)和强调。
您不能添加标题,块引用,列表,水平规则,图像或HTML标签。

若想在表格中打出(|)字符,可以使用表格的HTML字符代码(&#124;)来转义管道字符(|)。

围栏代码块

```c
#include <stdio.h>int main(){printf("Hello,World!\n");return0;
}
```
#include <stdio.h>int main(){printf("Hello,World!\n");return0;
}

脚注

要创建脚注参考,请在方括号([^1])内添加插入符号和标识符。标识符可以是数字或单词,但不能包含空格或制表符。
在括号内使用另一个插入符号和数字添加脚注,并用冒号和文本([^1]: My footnote.)。不必在文档末尾添加脚注。可以将它们放在除列表,块引号和表之类的其他元素之外的任何位置。

Here's a simple footnote,[^1] and here's a longer one.[^bignote][^1]: This is the first footnote.[^bignote]: Here's one with multiple paragraphs and code.Indent paragraphs to include them in the footnote.`{ my code }`Add as many paragraphs as you like.

呈现的输出效果如下:

Here's a simple footnote,[1] and here's a longer one.[2]

删除线

~~世界是平坦的。~~ 我们现在知道世界是圆的。

世界是平坦的。 我们现在知道世界是圆的。

任务列表

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

使用 Emoji 表情

有两种方法可以将表情符号添加到Markdown文件中:

  • 将表情符号复制并粘贴到Markdown格式的文本中
  • 或者键入表情简码

表情包来源:

  • Emojipedia
  • 表情符号简码列表
  • Windows下快捷键Win + .来选择想要添加的Emoji表情

高级操作

Markdown 作为轻量级标记语言,有一定的局限性,但借助 HTML 和 CSS,可以实现许多 Markdown 不支持的功能。

下划线

如果你的 Markdown 处理器支持 HTML,可以使用 <ins><u>标签:

一些文字 <ins>将被加下划线</ins>。
一些文字 <u>将被加下划线</u>。

一些文字 将被加下划线

一些文字 将被加下划线

文字居中

<p style="text-align:center">这段文字居中显示。</p>

这段文字居中显示。

文字颜色

Markdown 不支持更改文字颜色,但 HTML 可以:

<font color="red">这段文字是红色的!</font>
<p style="color:blue">这段文字是蓝色的。</p>

这段文字是红色的!

这段文字是蓝色的。

符号(特殊字符)

Markdown 不能直接插入特殊符号,但可以复制粘贴,或者使用 HTML 实体:

版权 (©) — &copy;
注册商标 (®) — &reg;
商标 (™) — &trade;
欧元 (€) — &euro;
左箭头 (←) — &larr;
上箭头 (↑) — &uarr;
右箭头 (→) — &rarr;
下箭头 (↓) — &darr;
度数 (°) — &#176;
圆周率 (π) — &#960;

渲染效果:

版权 (©) — ©

注册商标 (®) — ®

商标 (™) — ™

欧元 (€) — €

左箭头 (←) — ←

上箭头 (↑) — ↑

右箭头 (→) — →

下箭头 (↓) — ↓

度数 (°) — °

圆周率 (π) — π

插入视频

Markdown 不能直接嵌入视频,但可以使用 HTML,或变通方式(图片+链接)
点击B站的分享图标,然后选择嵌入链接,会获得如下代码:

<iframe src="//player.bilibili.com/player.html?isOutside=true&aid=114980686925459&bvid=BV1y1twzqE9n&cid=31548313549&p=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe>

或者

[![视频预览](https://img.youtube.com/vi/YOUTUBE-ID/0.jpg)](https://www.youtube.com/watch?v=YOUTUBE-ID)

渲染效果:

代码块折叠

Show Code
这里填充代码 

HTML语法:

<details> 
<summary><font size="4" color="orange">Show Code</font></summary> 
<pre><code class="language-cpp">这里填充代码</code>
</pre> </details>

标签解释:

details:折叠语法
summary:折叠语法展示的摘要
pre:以原有格式显示元素内的文字是已经格式化的文本
code:指定代码块

注意事项:

  • 对于代码块中的 <>的特殊符号应该用 \&lt; \&gt;代替,不然会显示错误。比如<stdio.h>要写成\&lt;stdio.h\&gt;
  • <code>必须紧贴代码开头(避免多出首行),\</code>需单独一行(避免少了尾行)
  • 代码块内部不能有空行

图片居中

单向链表结构-示意图

实现语法如下:

<div align=center><img src="https://invinc-z-drawing-bed.oss-cn-shanghai.aliyuncs.com/img/202311161556943.png" alt="单向链表结构-示意图" style="zoom: 33%;" /></div>

Markdown 表格单元格合并(跨行、跨列)及文本换行

参考解决方案

示例

选择排序冒泡排序插入排序
时间复杂度最佳情况 O(n^2) O(n) O(n)
平均情况 O(n^2) O(n^2) O(n^2)
最坏情况 O(n^2) O(n^2) O(n^2)
空间复杂度 O(1) O(1) O(1)
稳定性 不稳定 稳定 稳定
实现语法如下:
<div align=center>
<table><tr><th> </th><th> </th><th>选择排序</th><th>冒泡排序</th><th>插入排序</th></tr><tr><td rowspan="3">时间复杂度</td><td>最佳情况</td><td> O(n^2) </td><td> <b>O(n)</b> </td><td> <b>O(n)</b> </td></tr><tr><td>平均情况</td><td> O(n^2) </td><td> O(n^2) </td><td> O(n^2) </td></tr><tr><td>最坏情况</td><td> O(n^2) </td><td> O(n^2) </td><td> O(n^2) </td></tr><tr><td colspan="2">空间复杂度</td><td> O(1) </td><td> O(1) </td><td> O(1) </td></tr><tr><td colspan="2">稳定性</td><td> 不稳定 </td><td> 稳定 </td><td> 稳定 </td></tr>
</table>
</div>

添加键盘按键图标

使用 <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Esc</kbd> 打开任务管理器

渲染效果:

使用 Ctrl + Shift + Esc 打开任务管理器

内部锚点跳转

标题自动生成锚点

Markdown 的标题会自动生成一个锚点,链接格式如下:

[要显示的文字](#锚点)

锚点的规则:

原标题 锚点
# 我的标题 #我的标题 → 中英文都直接写
空格会变为 - 例如 我的 标题#我的-标题
全部转换为小写(英文)

点击跳转到基本语法

## 基本语法
...
[点击跳转到基本语法](#基本语法)

自定义锚点(HTML 写法,通用)

适用于:

  • 标题太复杂
  • 标题有特殊字符无法准确匹配
  • 知乎、Typora、Hexo 等平台

写法如下(注意空行要保留):

<a id="sec2"></a>## 扩展语法...
[跳转到扩展语法](#sec2)

点击跳转到扩展语法


参考博文

  1. Markdown 教程
  2. 为博客园markdown代码块添加折叠

  1. This is the first footnote. ↩︎

  2. Here's one with multiple paragraphs and code.

    Indent paragraphs to include them in the footnote.

    { my code }

    Add as many paragraphs as you like. ↩︎

http://www.jsqmd.com/news/78998/

相关文章:

  • 2025妈妈杯大材料竞赛A题mathorcup大素材:集装箱智能破损检测问题手把手思路代码文章教学大学生数学建模
  • 功耗网路签核工具大盘点
  • Krita架构解密:开源绘画软件如何实现商业级性能?
  • 19.redis之缓存击穿
  • 2025.12.12
  • 极市平台 | NeurlPS‘25开源 | 中科院新作AutoSeg3D:在线分割一切3D物体,超越ESAM!
  • APC001F
  • #题解#洛谷P1120 小木棍#搜索#剪枝
  • 云服务器的核心优势
  • 2025安全婴儿面霜测评:华西珐玛领衔,敏宝护理指南 - 资讯焦点
  • PyCausalSim:基于模拟的因果发现的Python框架
  • 爬youtube视频笔记
  • 使用vscode运行python,解释器为anaconda的虚拟环境,使用pip命令安装库失败解决方案
  • 某游戏大厂的常用面试问题解析:Netty 与 NIO - 指南
  • 软件工程学习日志2025.12.12
  • 云端算力:数字时代的核心引擎与创新基石
  • 家乐事净水器加盟费多少?0加盟费+装修补贴+区域保护,全程扶持解读 - 资讯焦点
  • 病毒学研究的关键工具:重组病毒蛋白的技术解析与应用实践
  • zz深入了解LlamaIndex实现Agent代码和原理
  • 搜维尔科技:Xsens独立项目-面向独立工作室的高端动作捕捉
  • 2025年度活动板房厂家TOP5实力评测:资质口碑场景适配全维度选型指南 - 资讯焦点
  • 解码智能指针
  • 毕业设计实战:基于SSM+MySQL的药店管理系统设计与实现,从需求到测试轻松通关!
  • linux: gdb调试器
  • 6 个最佳开源 AI 仪表盘工具
  • 红队日记 --- W1R3S
  • 深夜炸场!GPT-5.2发布;Meta被曝用阿里千问优化新模型;马斯克点赞腾讯游戏业务:他们的品味非常好 | 极客头条
  • 毕业设计实战:基于SSM+MySQL的图书商城管理系统设计与实现,从需求到测试全流程拆解,新手也能轻松通关!
  • springboot基于vue的承德市养老院智慧健康检测系统_ 用药提醒 一键呼叫 1f16uvca
  • Kate 高级文本编辑器 v26.03.70 官方中文版