跳到主要内容

Markdown 语法演示

本站支持的 Markdown 语法效果一览:文字样式、列表、引用、代码、表格、公式与 Mermaid 图。

这篇文章演示豈風支持的全部 Markdown 语法。写新文章前可以 对照这里确认渲染效果,写完即可删除本页。

标题层级

一级标题是文章标题本身,正文从二级开始。右侧目录会展示所有层级。

三级标题

三级标题通常是二级标题下的子话题。

四级标题

四级标题用来细分更具体的点,右侧目录里也会显示。

文字样式

加粗、斜体、删除线、行内代码、站内链接、 站外链接,上标与下标用行内公式表示:x2+y2x^2 + y_2。 直接写 URL 也会自动变成链接:https://www.qifeng.xyz/

列表

无序列表:

  • 第一项
  • 第二项
    • 嵌套项
    • 再嵌套
  • 第三项

有序列表:

  1. 第一步
  2. 第二步
  3. 第三步

任务列表:

  • 已完成的任务
  • 待办的任务

引用

一级引用:学习是唯一的捷径。

二级引用演示:

嵌套引用。

多个段落也可以放在同一个引用里。

代码块

Python:

def fibonacci(n: int) -> list[int]:
    a, b = 0, 1
    seq = []
    for _ in range(n):
        seq.append(a)
        a, b = b, a + b
    return seq

CUDA:

__global__ void saxpy(int n, float a, float *x, float *y) {
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    if (i < n) y[i] = a * x[i] + y[i];
}

Shell:

nvidia-smi --query-gpu=utilization.gpu,memory.used --format=csv -l 1

表格

对齐左对齐右对齐居中
默认内容内容内容
---:------::---:

分割线

上面是分割线。


下面是分割线。

数学公式

行内公式 E=mc2E = mc^2 与块级公式:

Attention(Q,K,V)=softmax ⁣(QK⊤dk)V\mathrm{Attention}(Q, K, V) = \mathrm{softmax}\!\left(\frac{QK^\top}{\sqrt{d_k}}\right) V

多行对齐:

∇θJ(θ)=E[∇θlog⁡πθ(a∣s) Q(s,a)]=1N∑i=1N∇θlog⁡πθ(ai∣si) Ri\begin{aligned} \nabla_\theta J(\theta) &= \mathbb{E}\left[ \nabla_\theta \log \pi_\theta(a \mid s)\, Q(s, a) \right] \\ &= \frac{1}{N} \sum_{i=1}^{N} \nabla_\theta \log \pi_\theta(a_i \mid s_i)\, R_i \end{aligned}

Mermaid 图

流程图:

flowchart TD
    A[开始] --> B{判断条件}
    B -->|是| C[执行分支一]
    B -->|否| D[执行分支二]
    C --> E[结束]
    D --> E

时序图:

sequenceDiagram
    participant 用户
    participant 服务器
    participant 数据库
    用户->>服务器: 发起请求
    服务器->>数据库: 查询数据
    数据库-->>服务器: 返回结果
    服务器-->>用户: 响应

饼图:

pie title 时间分配
    "写代码" : 40
    "读论文" : 30
    "写博客" : 20
    "摸鱼" : 10

甘特图:

gantt
    dateFormat  YYYY-MM-DD
    title       Adding GANTT diagram functionality to mermaid
    excludes    weekends
    %% (`excludes` accepts specific dates in YYYY-MM-DD format, days of the week ("sunday") or "weekends", but not the word "weekdays".)

    section A section
    Completed task            :done,    des1, 2014-01-06,2014-01-08
    Active task               :active,  des2, 2014-01-09, 3d
    Future task               :         des3, after des2, 5d
    Future task2              :         des4, after des3, 5d

    section Critical tasks
    Completed task in the critical line :crit, done, 2014-01-06,24h
    Implement parser and jison          :crit, done, after des1, 2d
    Create tests for parser             :crit, active, 3d
    Future task in critical line        :crit, 5d
    Create tests for renderer           :2d
    Add to mermaid                      :until isadded
    Functionality added                 :milestone, isadded, 2014-01-25, 0d

    section Documentation
    Describe gantt syntax               :active, a1, after des1, 3d
    Add gantt diagram to demo page      :after a1  , 20h
    Add another diagram to demo page    :doc1, after a1  , 48h

    section Last section
    Describe gantt syntax               :after doc1, 3d
    Add gantt diagram to demo page      :20h
    Add another diagram to demo page    :48h

混合示例

正文中插入公式与代码:损失函数 L=12∥y−y^∥2L = \frac{1}{2} \| y - \hat{y} \|^2, 实现只有一行 loss = 0.5 * ((y - y_hat) ** 2).sum()。

提示:所有语法都可以互相嵌套,例如在引用里写列表或代码。

  1. 有序列表里也可以有公式 a2+b2=c2a^2 + b^2 = c^2
  2. 以及行内代码 print("hello")

完。

评论