memorax-ai/dsh-render-engine--packages-markdown-render ↗★ 1

@ch4acko3/dsh-markdown-render

Safe GFM rendering service with highlighted code blocks for DeepSeek Harness Web plugins 适合需要在插件中安全渲染Markdown文本及代码块的开发者。

Package
@ch4acko3/dsh-markdown-render
Compatibility
Unverified
Cordis peer range
^4.0.1
Version
0.1.3
License
MIT
Last updated
Sep 24, 2026

Other repositories with this package name

Install

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:memorax-ai/dsh-render-engine#9582bf138d3a6d7381a84359a4a0b878a1ea8952&path:packages/markdown-render

@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.