1011 字
5 分钟
测试文章

这里是一些在 Astro 中编写 Markdown 内容时可使用的基本 Markdown 语法示例。
标题
以下 HTML <h1>
—<h6>
元素代表了六个级别的章节标题。<h1>
是最高章节级别,而 <h6>
是最低的。
H1
H2
H3
H4
H5
H6
图片
语法

输出
块引用
块引用元素代表引自其他来源的内容,可以选择性地包含一个必须位于 footer
或 cite
元素内的引用,并且可以选择性地包含内联更改,例如注释和缩写。
无归属的块引用
语法
> Tiam, ad mint andaepu dandae nostion secatur sequo quae.> **注意**,你可以在块引用中使用 _Markdown 语法_。
输出
Tiam, ad mint andaepu dandae nostion secatur sequo quae. 注意,你可以在块引用中使用 Markdown 语法。
带归属的块引用
语法
> 不要通过共享内存来通信,而要通过通信来共享内存。<br>> — <cite>罗布·派克[^1]</cite>
输出
不要通过共享内存来通信,而要通过通信来共享内存。
— 罗布·派克1
表格
语法
| 斜体 | 粗体 | 代码 || --------- | ---------- | --------- || _斜体_ | **粗体** | `代码` |
输出
斜体 | 粗体 | 代码 |
---|---|---|
斜体 | 粗体 | 代码 |
代码块
语法
我们可以使用 3 个反引号 ``` 在新的一行开始,编写代码片段,并在新的一行用 3 个反引号结束。若要高亮特定语言的语法,可以在开头的 3 个反引号后写上语言名称,例如 html、javascript、css、markdown、typescript、txt、bash。
```cfloat Q_rsqrt( float number ){ long i; float x2, y; const float threehalfs = 1.5F;
x2 = number * 0.5F; y = number; i = * ( long * ) &y; // evil floating point bit level hacking i = 0x5f3759df - ( i >> 1 ); // what the fuck? y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;}```
输出
float Q_rsqrt( float number ){ long i; float x2, y; const float threehalfs = 1.5F;
x2 = number * 0.5F; y = number; i = * ( long * ) &y; // evil floating point bit level hacking i = 0x5f3759df - ( i >> 1 ); // what the fuck? y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;}
Mermaid 图表
Mermaid 是一个基于 JavaScript 的图表绘制工具,它使用 Markdown 风格的语法来创建各种图表。许多支持 Markdown 的平台(如 Astro、GitHub、Obsidian 等)都集成了 Mermaid,可以直接渲染。
语法
使用三个反引号代码块,并将语言标记为 mermaid
。
```mermaid// 你的 Mermaid 语法在这里graph TD; A[开始] --> B{判断}; B -->|是| C[执行操作]; B -->|否| D[结束]; C --> D;```
示例:流程图 (Flowchart)
```mermaidgraph LR A[方形] --> B(圆角方形) B --> C{条件} C -->|选项1| D[结果一] C -->|选项2| E[结果二] F[\非标准形状/] --> D```
输出
graph LR
A[方形] --> B(圆角方形)
B --> C{条件}
C -->|选项1| D[结果一]
C -->|选项2| E[结果二]
F[\非标准形状/] --> D
示例:序列图 (Sequence Diagram)
```mermaidsequenceDiagram 参与者 Alice->>John: 你好 John,最近怎么样? John-->>Alice: 很好! Alice->>John: 你确定? Note right of John: John 想了想<br/>他很好 John-->>Alice: 当然! Alice->>John: 好的!```
输出
sequenceDiagram
参与者 Alice->>John: 你好 John,最近怎么样?
John-->>Alice: 很好!
Alice->>John: 你确定?
Note right of John: John 想了想<br/>他很好
John-->>Alice: 当然!
Alice->>John: 好的!
列表类型
有序列表
语法
1. 第一项2. 第二项3. 第三项
输出
- 第一项
- 第二项
- 第三项
无序列表
语法
- 列表项- 另一个项- 还有一个项
输出
- 列表项
- 另一个项
- 还有一个项
嵌套列表
语法
- 水果 - 苹果 - 橙子 - 香蕉- 奶制品 - 牛奶 - 奶酪
输出
- 水果
- 苹果
- 橙子
- 香蕉
- 奶制品
- 牛奶
- 奶酪