markstream-custom-components
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMarkstream Custom Components
Markstream 自定义组件
Use this skill when the task is to change how Markstream renders specific nodes or custom tags.
Read references/patterns.md before choosing an override strategy.
当任务需要修改Markstream渲染特定节点或自定义标签的方式时,使用该skill。
选择重写策略前,请先阅读references/patterns.md。
Workflow
工作流
- Classify the request.
- : replace an existing renderer such as
built-in override,image,link,code_block,mermaid, ord2.inline_code - : support trusted HTML-like tags such as
custom tag.thinking - : requires token transforms or AST reshaping. Only then should you leave this skill and use low-level parser hooks.
parser-level
- Prefer scoped mappings.
- Use instead of global mappings whenever practical.
setCustomComponents(customId, mapping) - Pass the same or
customIdto the renderer instance.custom-id
- Use
- Start with the smallest safe override.
- Leaf-like nodes (,
image,link,inline_code) are easier than container nodes (mermaid,heading,paragraph).list_item - If the request only changes Mermaid, use , not
mermaid.code_block
- Leaf-like nodes (
- Preserve nested Markdown when needed.
- For trusted custom tags with inner Markdown, render with a nested renderer.
node.content - Pass the same custom-tag allowlist to nested renderers.
- For trusted custom tags with inner Markdown, render
- Keep props and cleanup intact.
- Preserve ,
node,loading,indexKey, andcustomId.isDark - Remove temporary scoped mappings with when the scope is no longer needed.
removeCustomComponents(customId)
- Preserve
- Validate with the smallest useful check.
- Prefer a local demo, targeted test, or docs build.
- Call out whether the implementation is safe for repeated and nested custom tags.
- 对请求进行分类。
- :替换现有渲染器,例如
内置重写、image、link、code_block、mermaid或d2。inline_code - :支持可信任的类HTML标签,例如
自定义标签。thinking - :需要令牌转换或AST重构。只有这种情况下你才应该停用该skill,使用底层解析器钩子。
解析器级别
- 优先使用作用域映射。
- 只要可行,就使用而非全局映射。
setCustomComponents(customId, mapping) - 向渲染器实例传入相同的或
customId。custom-id
- 只要可行,就使用
- 从最小的安全重写开始。
- 叶子类节点(、
image、link、inline_code)比容器节点(mermaid、heading、paragraph)更容易处理。list_item - 如果请求仅修改Mermaid的渲染,就使用而非
mermaid。code_block
- 叶子类节点(
- 必要时保留嵌套Markdown。
- 对于内部包含Markdown的可信任自定义标签,使用嵌套渲染器渲染。
node.content - 向嵌套渲染器传入相同的自定义标签白名单。
- 对于内部包含Markdown的可信任自定义标签,使用嵌套渲染器渲染
- 保持属性和清理逻辑完整。
- 保留、
node、loading、indexKey和customId参数。isDark - 当不再需要作用域时,使用移除临时作用域映射。
removeCustomComponents(customId)
- 保留
- 用最小的有效检查做验证。
- 优先选择本地演示、定向测试或文档构建。
- 说明实现是否对重复和嵌套的自定义标签安全。
Default Decisions
默认决策
- Scoped overrides first, global overrides only when the whole app truly needs them.
- Leaf-node overrides before container-node overrides.
- plus scoped custom components before parser hooks.
customHtmlTags - Nested renderers for tag bodies that contain Markdown.
- 优先使用作用域重写,仅当整个应用确实需要时才使用全局重写。
- 优先重写叶子节点,再重写容器节点。
- 优先使用加作用域自定义组件,再考虑解析器钩子。
customHtmlTags - 包含Markdown的标签主体使用嵌套渲染器。
Useful Doc Targets
有用的文档目标
docs/guide/component-overrides.mddocs/guide/custom-components.mddocs/guide/components.mddocs/guide/advanced.md
docs/guide/component-overrides.mddocs/guide/custom-components.mddocs/guide/components.mddocs/guide/advanced.md