Skip to content

Markdown Syntax Reference API

Markdown 语法参考,用于以纯文本格式编写可转换为 HTML 的富文本。

1 class · 10 methods

Markdown Elements

10 methods

Markdown 元素参考,涵盖标题、列表、链接、代码块等书写语法。

# Heading

标题,以 1-6 个 # 表示 H1 到 H6 级标题。

Returns

渲染为对应级别的 HTML <h1>-<h6> 标题元素。

Example

markdown
# 一级标题
## 二级标题
### 三级标题
#### 四级标题
##### 五级标题
###### 六级标题
paragraph

段落,以空行分隔的连续文本行组成一个段落。

Returns

渲染为 <p> 段落元素,段落间默认有间距。

Example

markdown
这是第一段,延续同一行。

这是第二段。

第三段开始。
*italic* / **bold**

强调,单星号/下划线表示斜体,双星号/下划线表示粗体。

Returns

渲染为 <em>(斜体)或 <strong>(粗体)元素。

Example

markdown
*斜体文本* 或 _斜体_
**粗体文本** 或 __粗体__
***粗斜体***
- item / 1. item

列表,- 或 * 表示无序列表,数字加点表示有序列表。

Returns

渲染为 <ul> 无序或 <ol> 有序列表及其 <li> 项。

Example

markdown
- 苹果
- 香蕉
  - 黄色
  - 弯曲

1. 第一步
2. 第二步
3. 第三步
[text](url)

链接,将文本链接到指定 URL,可附加 title。

Parameters

NameTypeDescription
textstring链接显示文字
urlstring (URL)链接目标地址
titlestring悬停提示文字(可选)

Returns

渲染为 <a> 锚元素超链接。

Example

markdown
[示例站点](https://example.com "提示文字")

[引用式链接][ref]

[ref]: https://example.com
![alt](src)

图片,在文档中嵌入图像,并指定替代文本。

Parameters

NameTypeDescription
altstring图片替代文本
srcstring (URL)图片资源地址

Returns

渲染为 <img> 图像元素。

Example

markdown
![Logo](/assets/logo.png "公司标识")

![引用图][img1]

[img1]: /assets/banner.jpg
`code` / ```block```

行内代码与代码块,反引号包裹行内代码,三个反引号包裹多行代码块。

Parameters

NameTypeDescription
languagestring代码块语言标识(如 js、ts),用于语法高亮

Returns

渲染为 <code> 行内代码或 <pre><code> 代码块。

Example

markdown
行内代码: `const x = 1;`

代码块:
```js
function add(a, b) {
  return a + b;
}
```
> quote

引用块,以 > 开头表示引用内容,可嵌套。

Returns

渲染为 <blockquote> 引用块元素。

Example

markdown
> 这是一段引用。
> 引用可跨多行。
>
> > 嵌套引用。
| a | b |

表格,以 | 分隔列,以分隔行区分表头与数据行。

Returns

渲染为 <table> 表格结构。

Example

markdown
| 姓名 | 年龄 |
| --- | --- |
| 张三 | 20 |
| 李四 | 25 |

对齐:
| 左 | 中 | 右 |
| :-- | :-: | --: |
| a  | b  | c  |
---

水平分割线,由三个或更多 -、* 或 _ 组成。

Returns

渲染为 <hr> 水平分割线元素。

Example

markdown
上文内容

---

下文内容

***

___