自定义插件
可以用 Marked extensions,也可以用带 transform(content) 的对象在解析前改写字符串。自定义标签再走 components 映射。
字符串 transform
plugin
Ship the TODO before Friday.
Marked extension:脚注
下面用 tokenizer / renderer 把 [^n] 转成 <footnote>,再映射成带 Popover 的组件(对齐 React CustomPlugin/custom.tsx)。
XMarkdown supports custom marked extensions.1
Map the generated tag with components for interaction.2
See the plugins page for Latex / Highlight / Mermaid.3
与 components 的分工
| 方式 | 阶段 | 作用 |
|---|---|---|
config.extensions / marked 插件 | Markdown → HTML | 识别新语法,输出 HTML 标签 |
plugins[].transform | 解析前 | 纯字符串改写 |
components | HTML → VNode | 把标签换成 Vue 组件 |
更多 API 说明见 代码示例 · FAQ。