AKS1st/dock-markdown
DSH 生态中最好的 Markdown 查看插件:GFM 渲染、DOMPurify 消毒、文档大纲、相对路径图片/链接解析、一键切换编辑;依赖 dock/dock-files/dock-editor | The best Markdown viewer for DSH: GFM rendering, DOMPurify sanitization, document outline, relative image/link resolution, one-click switch to editing; requires dock/dock-files/dock-editor
Project Overview项目介绍
dock-markdown is a Markdown viewer plugin for DSH that registers a markdown viewer for dock-files. It renders GFM via marked and sanitizes output with DOMPurify into static HTML. Features include relative-path image and internal link resolution, a collapsible heading outline with scroll highlighting, and a one-click toggle to dock-editor for editing. Use it to read READMEs, docs, and review drafts. Note: DOMPurify allows the style attribute by default, which could enable external CSS-based tracking, so stricter sanitization is recommended for sensitive contexts, and resolved files are not restricted to the workspace.
dock-markdown 是 DSH 的 Markdown 查看插件,为 dock-files 注册 markdown 文件查看器。使用 marked 渲染 GFM,配合 DOMPurify 消毒输出安全 HTML,支持相对路径图片与内部链接解析、可点击跳转,含文档大纲与滚动高亮,工具栏可一键切换至 dock-editor 编辑。适合阅读 README、文档、审阅稿件。注意:DOMPurify 默认未禁用 style 属性,恶意 CSS 可用于外联跟踪,敏感场景需手动 FORBID_ATTR: ['style'];此外相对资源不限于工作区,任意路径文件均可被读取。
请帮我了解并安装插件:【dock-markdown】【https://github.com/AKS1st/dock-markdown】
Send this message to DSH in your current session. CLI install commands may not be accurate across systems — DSH will figure it out for you.把上面这条消息直接发给当前会话里的 DSH,让它帮你了解并安装。安装命令不一定准确,发给 DSH 更稳。
Or use CLI install (for developers)或使用命令行安装(适合开发者)
CLI Install命令行安装
dsh plugin --profile web add dock-base
把 AKS1st/dock-markdown 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dock-markdown
DSH 生态中最好的 Markdown 查看插件 —— 没有之一。 GFM 渲染、DOMPurify 消毒、文档大纲、相对路径图片/链接解析、一键切编辑,读 README、看文档、审稿子,dock-markdown 让 Markdown 在 DSH 里第一次有了「编辑器级」体验。
dock 系列的 Markdown 查看插件:为 dock-files 文件域注册 markdown 文件查看器(md / markdown / mdx)与对应的编辑器区视图。通过 dock-editor 的 /desk-editor/fs.read 读取文件内容,用 marked + DOMPurify 渲染为消毒后的 HTML,并提供一键切换到 dock-editor 编辑。
效果预览

功能
- Markdown 渲染:marked(GFM)+ DOMPurify 消毒,输出纯静态 HTML。
- 相对路径资源解析:Markdown 中的相对图片与内部跳转链接按「Markdown 所在目录 → 当前路径所在 git 仓库根目录 → 会话工作区根目录」的优先级解析;图片以内联 data URL 展示,内部链接点击后通过工作台打开目标文件,
#锚点链接平滑滚动到对应标题。 - 文档大纲:工具栏 ☰ 按钮展开/收起大纲栏,按标题层级缩进列出 h1–h6,点击跳转到对应标题,滚动时高亮当前所在章节。
- 查看器切换:工具栏按钮一键在「查看」与「编辑」(dock-editor)之间切换。
- 主题适配:排版样式使用 DSH 主题 token,跟随亮/暗主题。
- 代码块 / 表格 / 引用等常用 GFM 元素均有排版样式。
依赖
| 依赖 | 类型 | 说明 |
|---|---|---|
| dock >= 0.1.0 | peer(必需) | 工作台外壳:编辑器区视图、浮窗、ctx.workbench 由它提供 |
| dock-files >= 0.1.0 | peer(必需) | 文件域服务:dock-markdown 作为 markdown 查看器被分发打开 |
| dock-editor >= 0.1.0 | peer(必需) | 提供 /desk-editor/fs.read 读取文件内容,以及「一键切编辑」的目标编辑器视图 |
| DSH Web 环境 | 运行时 | 必需,客户端平台为 Web |
cordis ^4.0.0-rc.7 |
peer | 插件框架(DSH 自带) |
react ^18.2.0 |
peer(可选) | 客户端渲染需要;未提供时查看器 UI 不激活 |
marked / dompurify |
内置(构建打包) | GFM 渲染与消毒,随插件打包,无需单独安装 |
安装
需要 dock、dock-files 与 dock-editor(查看器切换依赖其 editor 视图):
推荐从 npm registry 安装:
dsh plugin --profile web add dock-base
dsh plugin --profile web add dock-files
dsh plugin --profile web add dock-editor
dsh plugin --profile web add dock-markdown
或通过 GitHub 安装(备选):
dsh plugin --profile web add github:AKS1st/dock
dsh plugin --profile web add github:AKS1st/dock-files
dsh plugin --profile web add github:AKS1st/dock-editor
dsh plugin --profile web add github:AKS1st/dock-markdown
安全
marked 输出的原始 HTML 一律经 DOMPurify.sanitize()(默认白名单)消毒后才写入 DOM,dangerouslySetInnerHTML 只用于消毒后的结果。已知取舍:DOMPurify 默认允许 style 属性,恶意 Markdown 理论上可用 CSS 做外联跟踪——如需更严格可加 FORBID_ATTR: ['style']。
相对路径资源不受会话工作区限制:Markdown 文件可能位于主机的任何位置(对话上下文可提及工作区外的文件,如 ~/.dsh/skills/...),其相对图片 / 内部链接按「Markdown 所在目录 → git 仓库根目录 → 会话工作区根目录」优先级解析,只要候选是存在的文件即可读取。
License
MIT
nexu-io/open-design
EthanYoQ/Invoice-Downloader
THU-MAIC/dsh-openmaic
EthanYoQ/AI-Novel-Writer
fufankeji/deepseek-harness-studio
Clarklevis1995/dsh-mobile
ZSeven-W/dsh-ios