跳到主要内容

dsh-markdown-render

已验证

@ch4acko3/dsh-markdown-render · v0.1.2 · MIT · Web 界面

Safe GFM rendering service with highlighted code blocks for DeepSeek Harness Web plugins

安装

dsh plugin add @ch4acko3/dsh-markdown-render

dsh --profile default --dump-config 确认 layer 已生效 —— 参见安装指南

源码

发布到 npm 但没有公开仓库。安装前请检查包内容。

标签

说明文档

@ch4acko3/dsh-markdown-render

A browser-side Cordis service that renders untrusted GitHub Flavored Markdown as sanitized, theme-aware HTML. Fenced code blocks reuse ctx.codeRenderer, so every downstream plugin gets the same language aliases, Shiki tokens, escaping, and DSH theme colors as the rest of the render engine.

export const inject = ['markdownRenderer']

export async function apply(ctx) {
  const result = await ctx.markdownRenderer.render({
    markdown: '# Result\n\n```ts\nconst answer = 42\n```',
    mode: 'render-friendly',
  })
  console.log(result.html)
}

mode is optional. The default, gfm, preserves GitHub Flavored Markdown behavior, including ~text~ strikethrough. Use render-friendly when Markdown contains approximate values or prose that uses single tildes: it leaves ~text~ literal while continuing to render ~~text~~ as strikethrough.

The renderer supports GFM tables, task lists, strikethrough, links, images, blockquotes, and fenced code. Raw HTML is displayed as text, unsafe URLs and executable markup are removed, and the returned HTML contains only fixed renderer styles plus sanitized Markdown output.

The only required rendering dependency is ctx.codeRenderer. At render time, a mermaid fence checks ctx.get('mermaidRenderer'); $…$, $$…$$, and math/latex/tex/katex fences check ctx.get('mathRenderer'). Active optional services receive the source and replace the fallback with safe SVG or MathML. Without them, Markdown remains readable as highlighted code or literal source. This package depends on neither Mermaid nor KaTeX, so either renderer can be installed or removed independently.

This package provides no ChatView, file browser, editor, or export workflow. Those belong in downstream plugins.