产品周报
本周发布了 FluxMark 0.1,详见发布说明。
| 模块 | 负责人 | 状态 |
|---|---|---|
| 解析器 | Lin | 已完成 |
| 渲染器 | Chen | 进行中 |
const ready = true
console.log(ready)
类型检查
发布文档
FluxMark 以物理缩进表达块级层级,以管道修饰符表达行内属性。它不是 Markdown 的兼容层:代码块、数据表、任务和链接都有自己的语法。
标记为 实时结果 的示例会在浏览器内真实编译,可在渲染结果、格式化 HTML 与转换后 AST 之间切换,底部会显示解析与渲染耗时。
# 产品周报
本周发布了 [FluxMark 0.1|b,#3451b2],详见[发布说明|https://example.com/releases,?在新窗口查看]。
> [tip] 评审提示
表格字段与代码内容必须相对父节点缩进。
@ 发布状态
- 模块: 解析器 | 负责人: Lin | 状态: 已完成
- 模块: 渲染器 | 负责人: Chen | 状态: 进行中
$ ts
const ready = true
console.log(ready)
* [x] 类型检查
* [ ] 发布文档
---本周发布了 FluxMark 0.1,详见发布说明。
| 模块 | 负责人 | 状态 |
|---|---|---|
| 解析器 | Lin | 已完成 |
| 渲染器 | Chen | 进行中 |
const ready = true
console.log(ready)
类型检查
发布文档
{
"type": "Document",
"line": 1,
"column": 1,
"indent": -1,
"range": {
"start": 0,
"end": 295
},
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 295
},
"type": "Section",
"level": 1,
"title": [
{
"type": "text",
"content": "产品周报",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
],
"children": [
{
"line": 2,
"column": 3,
"indent": 2,
"range": {
"start": 7,
"end": 86
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "本周发布了 ",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "style",
"content": "FluxMark 0.1",
"style": {
"bold": true,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": "#3451b2",
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "text",
"content": ",详见",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "style",
"content": "发布说明",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": "https://example.com/releases",
"tooltip": "在新窗口查看",
"customModifiers": []
},
"attributes": {}
},
{
"type": "text",
"content": "。",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
},
{
"line": 4,
"column": 3,
"indent": 2,
"range": {
"start": 88,
"end": 127
},
"type": "Callout",
"variant": "tip",
"title": [
{
"type": "text",
"content": "评审提示",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
],
"children": [
{
"line": 5,
"column": 5,
"indent": 4,
"range": {
"start": 103,
"end": 126
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "表格字段与代码内容必须相对父节点缩进。",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
]
},
{
"line": 7,
"column": 3,
"indent": 2,
"range": {
"start": 128,
"end": 208
},
"type": "DataTable",
"title": [
{
"type": "text",
"content": "发布状态",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
],
"columns": [
"模块",
"负责人",
"状态"
],
"rows": [
{
"line": 8,
"cells": {
"模块": {
"line": 8,
"tokens": [
{
"type": "text",
"content": "解析器",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
},
"负责人": {
"line": 8,
"tokens": [
{
"type": "text",
"content": "Lin",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
},
"状态": {
"line": 8,
"tokens": [
{
"type": "text",
"content": "已完成",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
}
},
{
"line": 9,
"cells": {
"模块": {
"line": 9,
"tokens": [
{
"type": "text",
"content": "渲染器",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
},
"负责人": {
"line": 9,
"tokens": [
{
"type": "text",
"content": "Chen",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
},
"状态": {
"line": 9,
"tokens": [
{
"type": "text",
"content": "进行中",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
}
}
]
},
{
"line": 11,
"column": 3,
"indent": 2,
"range": {
"start": 209,
"end": 262
},
"type": "CodeBlock",
"language": "ts",
"lines": [
"const ready = true",
"console.log(ready)",
""
],
"code": "const ready = true\nconsole.log(ready)\n"
},
{
"line": 15,
"column": 3,
"indent": 2,
"range": {
"start": 263,
"end": 288
},
"type": "List",
"ordered": false,
"start": 1,
"children": [
{
"line": 15,
"column": 3,
"indent": 2,
"range": {
"start": 263,
"end": 275
},
"type": "ListItem",
"marker": "*",
"ordinal": null,
"checked": true,
"taskMarkerOffset": 268,
"children": [
{
"line": 15,
"column": 3,
"indent": 2,
"range": {
"start": 263,
"end": 275
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "类型检查",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
]
},
{
"line": 16,
"column": 3,
"indent": 2,
"range": {
"start": 276,
"end": 288
},
"type": "ListItem",
"marker": "*",
"ordinal": null,
"checked": false,
"taskMarkerOffset": 281,
"children": [
{
"line": 16,
"column": 3,
"indent": 2,
"range": {
"start": 276,
"end": 288
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "发布文档",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
]
}
]
},
{
"line": 17,
"column": 3,
"indent": 2,
"range": {
"start": 289,
"end": 294
},
"type": "HorizontalRule"
}
]
}
],
"issues": []
}空白行用于分隔段落和其他结构;块级嵌套由物理缩进决定,不依赖闭合标记。
子块必须比父块多至少一列缩进。空格的缩进宽度为 1,制表符的缩进宽度固定为 2。解析器同时记录缩进宽度和缩进占用的源码字符数。
# 父章节
第一段仍属于父章节。
> [note] 同级的提示块
这一段属于提示块。
离开父章节的内容第一段仍属于父章节。
离开父章节的内容
{
"type": "Document",
"line": 1,
"column": 1,
"indent": -1,
"range": {
"start": 0,
"end": 60
},
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 50
},
"type": "Section",
"level": 1,
"title": [
{
"type": "text",
"content": "父章节",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
],
"children": [
{
"line": 2,
"column": 3,
"indent": 2,
"range": {
"start": 6,
"end": 18
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "第一段仍属于父章节。",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
},
{
"line": 3,
"column": 3,
"indent": 2,
"range": {
"start": 19,
"end": 50
},
"type": "Callout",
"variant": "note",
"title": [
{
"type": "text",
"content": "同级的提示块",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
],
"children": [
{
"line": 4,
"column": 5,
"indent": 4,
"range": {
"start": 37,
"end": 50
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "这一段属于提示块。",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
]
}
]
},
{
"line": 5,
"column": 1,
"indent": 0,
"range": {
"start": 51,
"end": 59
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "离开父章节的内容",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
],
"issues": []
}同级块通常使用相同缩进。缩进回到父块或更浅位置时,当前容器结束。不要依赖 Tab 与空格的视觉宽度混排;统一使用空格更易于维护。
使用 1 至 6 个 #,后接空白与标题:
# 一级标题
## 二级标题
### 三级标题章节的实际层级还受嵌套深度影响:实际级别为当前章节深度与井号数量之和,最大为 6。章节标题会解析为行内 token,正文是 Section.children。
# 外层
# 内层
内层章节的级别由外层深度加上自身井号数量计算。> 创建提示块。默认变体是 quote,也可以显式指定变体和标题:
> 普通引用
> [note] 说明
> [tip] 建议
> [warn] 注意
> [danger] 危险操作
此段属于 danger 提示块。普通引用
{
"type": "Document",
"line": 1,
"column": 1,
"indent": -1,
"range": {
"start": 0,
"end": 77
},
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 6
},
"type": "Callout",
"variant": "quote",
"title": [
{
"type": "text",
"content": "普通引用",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
],
"children": []
},
{
"line": 2,
"column": 1,
"indent": 0,
"range": {
"start": 7,
"end": 18
},
"type": "Callout",
"variant": "note",
"title": [
{
"type": "text",
"content": "说明",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
],
"children": []
},
{
"line": 3,
"column": 1,
"indent": 0,
"range": {
"start": 19,
"end": 29
},
"type": "Callout",
"variant": "tip",
"title": [
{
"type": "text",
"content": "建议",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
],
"children": []
},
{
"line": 4,
"column": 1,
"indent": 0,
"range": {
"start": 30,
"end": 41
},
"type": "Callout",
"variant": "warn",
"title": [
{
"type": "text",
"content": "注意",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
],
"children": []
},
{
"line": 5,
"column": 1,
"indent": 0,
"range": {
"start": 42,
"end": 77
},
"type": "Callout",
"variant": "danger",
"title": [
{
"type": "text",
"content": "危险操作",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
],
"children": [
{
"line": 6,
"column": 3,
"indent": 2,
"range": {
"start": 58,
"end": 76
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "此段属于 danger 提示块。",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
]
}
],
"issues": []
}内置变体为 quote、note、tip、warn、danger。变体名不区分大小写,AST 中保存为小写。未注册的 [name] 不会被当作变体,而会保留在默认引用标题中;可通过解析器选项或插件的 calloutVariants 注册更多名称。
单独一行的 $ 开始代码块,可附加语言标识。后续缩进内容都是代码,不需要结束围栏:
$ ts
function greet(name: string): string {
return `Hello ${name}`
}function greet(name: string): string {
return `Hello ${name}`
}
{
"type": "Document",
"line": 1,
"column": 1,
"indent": -1,
"range": {
"start": 0,
"end": 77
},
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 77
},
"type": "CodeBlock",
"language": "ts",
"lines": [
"function greet(name: string): string {",
" return `Hello ${name}`",
"}",
""
],
"code": "function greet(name: string): string {\n return `Hello ${name}`\n}\n"
}
],
"issues": []
}无语言标识时使用 $。解析器会移除所有非空代码行共有的最小缩进,保留其余相对缩进与空行;缩进回到 $ 所在层级或更浅时,代码块结束。代码内容不会再做行内解析。
@ 开始数据表,可附标题。字段固定的记录推荐把第一项写成管道分隔的表头,后续行只写值:
@ 项目进度
- 模块 | 状态 | 覆盖率
- Parser | Stable | 95%
- 渲染器 | Beta | 88%| 模块 | 状态 | 覆盖率 |
|---|---|---|
| Parser | Stable | 95% |
| 渲染器 | Beta | 88% |
{
"type": "Document",
"line": 1,
"column": 1,
"indent": -1,
"range": {
"start": 0,
"end": 72
},
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 72
},
"type": "DataTable",
"title": [
{
"type": "text",
"content": "项目进度",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
],
"columns": [
"模块",
"状态",
"覆盖率"
],
"rows": [
{
"line": 3,
"cells": {
"模块": {
"line": 3,
"tokens": [
{
"type": "text",
"content": "Parser",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
},
"状态": {
"line": 3,
"tokens": [
{
"type": "text",
"content": "Stable",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
},
"覆盖率": {
"line": 3,
"tokens": [
{
"type": "text",
"content": "95%",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
}
},
{
"line": 4,
"cells": {
"模块": {
"line": 4,
"tokens": [
{
"type": "text",
"content": "渲染器",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
},
"状态": {
"line": 4,
"tokens": [
{
"type": "text",
"content": "Beta",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
},
"覆盖率": {
"line": 4,
"tokens": [
{
"type": "text",
"content": "88%",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
}
}
]
}
],
"issues": []
}当表格的第一项包含多个字段且不含 键: 时,它会被识别为表头。列名只声明一次,不必在每个记录中重复。
列不固定、记录较稀疏时,可以改用显式的键值记录。同一行的多个字段以 | 分隔:
@ 联系信息
- 姓名: Ada | 角色: 维护者
- 姓名: Lin | 站点: [个人主页|https://example.com]键值记录的后续字段也可以写在仍位于表格作用域内的行中。续行可以与记录同级缩进,也可以更深;当缩进回到 @ 行同级或更浅时,表格结束。表格作用域内的空白行会被跳过。
列按首次出现的顺序保存在 DataTable.columns 中;每条值记录是 DataTable.rows 中的一项,单元格通过列名索引。位置记录与键值记录缺失的单元格都保持缺失,渲染时显示为空。
只有不被反引号代码或方括号包住的 | 才分隔字段。表头模式要求第一行至少有两个非空标签;键值模式要求每个字段有非空列名、冒号和可选值。格式错误的字段会产生解析警告并被忽略。这不是 Markdown 的横排管道表格,没有表头分隔行。
无序列表使用 - 或 *。多个连字符表示更深的大纲级别:
- 一级项目
-- 二级项目
--- 三级项目
* 另一个一级项目有序列表使用数字和句点。分段序号表示嵌套层级:
1. 准备
2. 构建
2.1. 编译 SDK
2.2. 构建文档
3. 发布List.start 取首个项目的末段序号,ListItem.ordinal 保存完整序号段,例如 [2, 1]。列表项的附加块也可以相对列表标记行缩进。
任务使用 -、+ 或 * 列表标记和状态框,状态字符只能是空格、x 或 X:
- [ ] 待办
+ [x] 已完成
* [X] 同样表示已完成待办
已完成
同样表示已完成
{
"type": "Document",
"line": 1,
"column": 1,
"indent": -1,
"range": {
"start": 0,
"end": 33
},
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 32
},
"type": "List",
"ordered": false,
"start": 1,
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 8
},
"type": "ListItem",
"marker": "-",
"ordinal": null,
"checked": false,
"taskMarkerOffset": 3,
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 8
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "待办",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
]
},
{
"line": 2,
"column": 1,
"indent": 0,
"range": {
"start": 9,
"end": 18
},
"type": "ListItem",
"marker": "+",
"ordinal": null,
"checked": true,
"taskMarkerOffset": 12,
"children": [
{
"line": 2,
"column": 1,
"indent": 0,
"range": {
"start": 9,
"end": 18
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "已完成",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
]
},
{
"line": 3,
"column": 1,
"indent": 0,
"range": {
"start": 19,
"end": 32
},
"type": "ListItem",
"marker": "*",
"ordinal": null,
"checked": true,
"taskMarkerOffset": 22,
"children": [
{
"line": 3,
"column": 1,
"indent": 0,
"range": {
"start": 19,
"end": 32
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "同样表示已完成",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
]
}
]
}
],
"issues": []
}AST 中,ListItem.checked 对普通项目为 null,对未选和已选任务分别为 false、true。taskMarkerOffset 指向源码中的状态字符,便于精确切换任务而不重排文档。参见快速上手。
单独一行至少三个连字符,且没有其他非空白内容,会创建分隔线:
---
-----不属于其他块级规则的内容会形成段落。同一段落中的连续物理行以换行连接,行内解析后产生 break token;HTML 渲染器将其输出为换行语义。
第一行
第二行仍属于同一段落。
空行之后是新的段落。| 语法 | 效果 | 对应样式字段 |
|---|---|---|
*文本* 或 **文本** | 粗体 | bold |
_文本_ | 斜体 | italic |
=文本= | 高亮 | mark |
~文本~ | 删除线 | strike |
`文本` | 行内代码 | code |
未配对的定界符按普通文本处理,反引号中的内容不再解释其他样式。下划线不通过定界符创建,而是通过管道修饰符 u 或 underline 启用。
定界符配对要求开定界符后紧跟非空白字符,闭定界符前紧邻非空白字符。被单词字符包围的下划线会保留为普通文本。
通用形式为 [内容|修饰符,修饰符]。逗号后可带空白,修饰符按从左到右的顺序应用:
[重要|b,u]
[斜体|i]
[高亮|m]
[删除|s]
[代码|c]
[品牌色|#3451b2]
[缩写|#fff]重要
斜体
高亮删除代码
品牌色
缩写
{
"type": "Document",
"line": 1,
"column": 1,
"indent": -1,
"range": {
"start": 0,
"end": 61
},
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 60
},
"type": "Paragraph",
"tokens": [
{
"type": "style",
"content": "重要",
"style": {
"bold": true,
"italic": false,
"underline": true,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "break",
"content": "\n",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "style",
"content": "斜体",
"style": {
"bold": false,
"italic": true,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "break",
"content": "\n",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "style",
"content": "高亮",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": true,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "break",
"content": "\n",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "style",
"content": "删除",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": true,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "break",
"content": "\n",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "code",
"content": "代码",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": true,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "break",
"content": "\n",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "style",
"content": "品牌色",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": "#3451b2",
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "break",
"content": "\n",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "style",
"content": "缩写",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": "#fff",
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
],
"issues": []
}内置样式别名如下:
| 类别 | 修饰符 |
|---|---|
| 粗体 | b、bold |
| 斜体 | i、italic |
| 下划线 | u、underline |
| 删除线 | s、strike |
| 高亮 | m、mark |
| 代码 | c、code |
| 颜色 | 三位或六位十六进制颜色,如 #fff、#3451b2 |
样式别名不区分大小写。颜色会归一化为小写。其他自定义修饰符会记录在 FluxInlineStyle.customModifiers 中,插件还可以向 token 的 attributes 写入元数据。
默认渲染器会为自定义修饰符 kbd、badge 和 spoiler 提供专门的样式;插件可以处理其他名称,或在其外层添加行为。
URL 修饰符直接写在管道右侧:
[FluxMark|https://github.com/Okysu/fluxmark]
[发送邮件|mailto:maintainers@example.com]内置 URL 识别支持 http://、https:// 和 mailto:,协议前缀不区分大小写。HTML 渲染时仍会经过 URL 安全检查,插件代码不应绕过 safeUrl。
以 ? 开头的修饰符设置悬浮提示。提示修饰符会吸收它之后的所有修饰符文本,因此应放在最后:
[API|b,?Application Programming Interface]
[文档|https://example.com/docs,?打开文档]API
文档
{
"type": "Document",
"line": 1,
"column": 1,
"indent": -1,
"range": {
"start": 0,
"end": 79
},
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 78
},
"type": "Paragraph",
"tokens": [
{
"type": "style",
"content": "API",
"style": {
"bold": true,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": "Application Programming Interface",
"customModifiers": []
},
"attributes": {}
},
{
"type": "break",
"content": "\n",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "style",
"content": "文档",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": "https://example.com/docs",
"tooltip": "打开文档",
"customModifiers": []
},
"attributes": {}
}
]
}
],
"issues": []
}管道语法中的内容是原始文本,不会递归解析为另一组行内 token。FluxMark 不使用 Markdown 的 [文本](URL) 链接形式。
图片沿用相同的方括号语法,地址在前,可选的替代描述位于管道之后:
![https://okysu.github.io/fluxmark/logo.svg|FluxMark 标志]
![https://okysu.github.io/fluxmark/logo.svg]{
"type": "Document",
"line": 1,
"column": 1,
"indent": -1,
"range": {
"start": 0,
"end": 102
},
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 101
},
"type": "Paragraph",
"tokens": [
{
"type": "image",
"content": "FluxMark 标志",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {
"src": "https://okysu.github.io/fluxmark/logo.svg"
}
},
{
"type": "break",
"content": "\n",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "image",
"content": "",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {
"src": "https://okysu.github.io/fluxmark/logo.svg"
}
}
]
}
],
"issues": []
}![src] 是合法的装饰性图片,alt 为空;![src|alt] 提供无障碍描述。HTML 渲染器会使用同一 URL 策略检查图片地址、转义替代文本,并输出 loading="lazy" decoding="async"。非法地址会输出转义后的回退文本,而不是图片元素。不支持 Markdown 的  形式。
反斜杠可以转义 ASCII 标点,使其保持字面量:
\*不是粗体\*、\[不是链接\],以及字面量竖线 \|。*不是粗体*、[不是链接],以及字面量竖线 |。
{
"type": "Document",
"line": 1,
"column": 1,
"indent": -1,
"range": {
"start": 0,
"end": 30
},
"children": [
{
"line": 1,
"column": 1,
"indent": 0,
"range": {
"start": 0,
"end": 29
},
"type": "Paragraph",
"tokens": [
{
"type": "text",
"content": "*不是粗体",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "text",
"content": "*、",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "text",
"content": "[不是链接",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "text",
"content": "],以及字面量竖线 ",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
},
{
"type": "text",
"content": "|。",
"style": {
"bold": false,
"italic": false,
"underline": false,
"strike": false,
"mark": false,
"code": false,
"color": null,
"href": null,
"tooltip": null,
"customModifiers": []
},
"attributes": {}
}
]
}
],
"issues": []
}可转义 \、[、]、|、*、_、=、~、反引号以及其他 ASCII 标点。代码块和行内代码中的反斜杠保持原样。
原始 HTML 必须显式标记,而不会静默透传。行内标签前加 !:
包含 !<span class="accent">行内 HTML!</span> 的文本。块级 HTML 以 !html 开始,缩进内容会原样保留:
!html
<div class="callout">
<strong>原始 HTML 块</strong>
</div>默认情况下 HTML 会被转义。需要输出时显式开启:
renderToHTML(source, { allowHtml: true })仅对可信内容开启 allowHtml。原始 HTML 会绕过常规转义,渲染不可信输入前必须自行清洗。
parseFluxMark 和 FluxMarkParser.parse 返回 FluxDocument。除了 children,文档还包含 issues。当前内置检查会对格式错误的表格字段和非法自定义块规则结果产生 warning 诊断;severity 类型也允许 error。
import { parseFluxMark } from 'fluxmark'
const source = `# 诊断
@ 表格
- 姓名: Ada | 格式错误的字段
`
const ast = parseFluxMark(source, {
onIssue(issue) {
console.warn(`${issue.severity} at ${issue.line}:${issue.column}: ${issue.message}`)
},
})
for (const issue of ast.issues) {
console.log(issue)
}每个块节点都有:
line 与 column:一基行列位置。indent:物理缩进宽度。range.start 与 range.end:零基、末端不包含的源码偏移范围。因此,编辑器可以定位诊断、同步预览选区,或在保留原始格式的前提下更新任务状态。
行内扫描会预先计算代码跨度、方括号和定界符配对。每个输入字符只参与常数次线性扫描,失败匹配不会重新扫描剩余后缀。块解析按物理行推进,AST 遍历按节点深度优先访问。
插件若执行正则、递归解析、重复 AST 遍历或 HTML 序列化,其成本需要单独计算;不可信插件不应视为沙箱代码。