2.0.0
Skip to content

自定义插件 ​

可以用 Marked extensions,也可以用带 transform(content) 的对象在解析前改写字符串。自定义标签再走 components 映射。

字符串 transform ​

plugin

Ship the TODO before Friday.

字符串 transform

plugins 的 transform 在 marked 之前把 TODO 加粗。

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 映射。

与 components 的分工 ​

方式阶段作用
config.extensions / marked 插件Markdown → HTML识别新语法,输出 HTML 标签
plugins[].transform解析前纯字符串改写
componentsHTML → VNode把标签换成 Vue 组件

更多 API 说明见 代码示例 · FAQ。