code-render

by CH4ACKO3

开发与运行时github收录于 08-23

面向 DSH Web 插件的转义与主题响应 HTML 代码块渲染服务,基于结构化语法高亮 token,并保留源码换行符。

Escaped, theme-aware HTML code-block rendering service for DSH Web plugins, built on structured syntax-highlight tokens with source line-ending preservation.

安装

dsh plugin --profile web add github:CH4ACKO3/dsh-render-engine#path:/packages/code-render

GitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试

安装与环境配置指引、插件开发教程见 DSH 中文社区文档 ↗

安装即在你的机器上以你的权限运行第三方代码——它可读写文件、使用凭据、访问网络,DSH 的工具审批不会为插件代码加沙箱。「检测到 manifest」仅代表发现 dsh.bundle / dsh.plugin 清单,不构成兼容性或安全审查;安装前请审阅源码,不熟悉的插件先在不含密钥的环境试用。

README

A browser-side Cordis service that renders ctx.syntaxHighlighter tokens as safe, theme-aware HTML code blocks.

export const inject = ['codeRenderer']

export function apply(ctx) {
  const result = ctx.codeRenderer.render({
    code: 'const answer = 42',
    language: 'ts',
  })
  console.log(result.html)
}

Source text and HTML attributes are escaped. Colors follow DSH's --shiki-* CSS variables, and original LF, CRLF, or CR line endings are retained.

原始 README: https://github.com/CH4ACKO3/dsh-render-engine/blob/main/packages/code-render/README.md ↗