memorax-ai/dsh-render-engine--packages-diff-render ↗★ 1
@ch4acko3/dsh-diff-render
渲染带语法高亮的HTML差异对比视图 适合需要在Web界面中直观展示文件修改、代码Diff对比的插件开发者。
同名套件的其他儲存庫
安裝
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:memorax-ai/dsh-render-engine#9582bf138d3a6d7381a84359a4a0b878a1ea8952&path:packages/diff-render說明文件
閱讀完整 README ↗@ch4acko3/dsh-diff-render
A browser-side Cordis service that renders @ch4acko3/dsh-diff-engine documents as escaped, theme-aware HTML. Diff rows keep their addition, deletion, context, and metadata semantics while source text is highlighted through ctx.syntaxHighlighter when the file language is supported.
export const inject = ['diffEngine', 'diffRenderer']
export function apply(ctx) {
const document = ctx.diffEngine.diff({
kind: 'files',
before: { path: 'app.ts', content: 'const value = 1\n' },
after: { path: 'app.ts', content: 'const value = 2\n' },
})
const result = ctx.diffRenderer.render(document)
console.log(result.html)
}
Complete file snapshots are highlighted as complete sources and mapped back through their old and new line numbers. Patch-only inputs reconstruct each hunk's before and after fragments, so their source-language highlighting is fragment-scoped. Diff state uses row backgrounds and gutters without replacing the source token colors.