markstream-custom-components
它能做什么
这个工具可以让你自定义格式化文本文档(比如文章或帖子)中某些元素的显示方式。你可以更改图片、链接或代码块等元素的外观,也可以添加你自己的特殊元素。
适用场景
- ✓当你想改变图片或链接的默认外观时。
- ✓当你想创建一种新的区块类型,例如“思考”区块时。
- ✓当你需要这些自定义元素只在网站或应用的特定部分生效时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/markstream-custom-components/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我怎样才能让代码块显示为不同的背景颜色?”
每周 5 个新技能,1 分钟读完。
工作原理
你告诉工具要更改哪些元素,以及它们应该如何显示。工具随后会依照你的指令渲染文本,用你的自定义规则替代默认规则。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Markstream Custom Components
Overview
Customize specific Markstream nodes or trusted custom tags without replacing the parser or leaking global renderer state. Read references/patterns.md first.
When to Use
Use to replace built-ins such as image, link, code_block, mermaid, or inline_code; render trusted tags such as thinking; or scope overrides to one renderer or app. Use parser transforms only when token or AST reshaping is required.
Workflow
Before changing dependencies or source files, inspect the existing package manager and project conventions, preview the intended edits, and obtain explicit user approval.
- Classify the change as a built-in override, trusted tag, or parser transform.
- Prefer scoped mappings. Vue, Vue 2, Svelte, and Angular can use
setCustomComponents(customId, mapping); Svelte and Angular can also pass renderer-local maps. - In React, prefer
streamingComponentsfor parser-backed nodes andhtmlComponentsfor sanitized attributes plus children. - Start with leaf nodes before containers that must preserve children.
- For trusted tag bodies containing Markdown, use a nested renderer with the same allowlist. Do not add a second smooth-streaming loop.
- Preserve node/loading props, identity keys, scope IDs, theme state, and preview-height estimates for async diagrams.
- Remove temporary scoped registrations on cleanup and validate repeated and nested tags.
Example
import MarkdownRender, {
type NodeComponentProps,
setCustomComponents,
} from 'markstream-react'
import 'markstream-react/index.css'
function ThinkingNode({ node }: NodeComponentProps<any>) {
return <details><summary>Thinking</summary>{node.content}</details>
}
setCustomComponents('assistant-panel', { thinking: ThinkingNode })
export function Answer({ markdown }: { markdown: string }) {
return (
<MarkdownRender
content={markdown}
customId="assistant-panel"
customHtmlTags={['thinking']}
htmlPolicy="safe"
/>
)
}
Limitations
- Component overrides cannot reproduce arbitrary remark/rehype transforms.
- Container overrides require careful child rendering and accessibility review.
- Framework registration APIs are not interchangeable.
Security & Safety Notes
Treat custom HTML-like tags as trusted input only. Keep safe HTML enabled and do not pass unsanitized attributes into host components.
常见问题
我可以更改任何内容吗?
你可以更改图片和链接等标准元素,也可以添加新的可信元素。不过,你无法重新定义所有复杂的格式转换。
使用自定义元素安全吗?
只要你把这些元素视为可信内容,并且不向其中插入未经验证的信息,就是安全的。保持安全设置处于开启状态很重要。
这个工具如何与不同的前端技术(Vue、React 等)配合使用?
工具为每种技术提供了具体的设置方法,确保自定义功能在各自的环境中都能正确运行。
详情
作者的原始描述
Override Markstream node renderers and add trusted custom tags across Vue, React, Svelte, and Angular using scoped or renderer-local mappings.
热度
- GitHub 星标
- 48k
- 排名
- #5168
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。