DSH Plugins Marketplace

DSH Plugins

Plugins

/

dsh-pdf-translate

M

dsh-pdf-translate

Manifest valid★ 1

Added a "Translation" panel to the DSH sidebar: drop in an English PDF, and it first measures the original's layout (margins / font size / line spacing / emphasis color / header & footer positions), then reflows the content to match, producing a layout-preserving Chinese PDF + MD. Also provides the `pdf_translate` model tool.

UI (client)hasBundlePatch

dsh-pdf-translate

给 DSH 加一个侧栏「翻译」面板:丢一份英文电子版 PDF 进去,出来一份「按原件版式排的」中文版。

左侧栏「日程」下面会出现「翻译」入口:

  • 把 PDF 拖进去(或点一下选文件),十几秒到几分钟后得到 <原名>_中文版.pdf + <原名>_中文版.md
  • 产物默认落在 D:\Translation(面板里可临时改;默认值写在 lib/index.js 的 defaultOutDir())
  • 另外注册了模型工具 pdf_translate,可以直接对 Agent 说"把这份 PDF 翻成中文"

它凭什么"保留原版式"

不是套模板,而是先从原件量出参数,再照着重排:

阶段做的事
① 解析零依赖 PDF 解析器:文字层 + 位置 + 字号 + 颜色;支持对象流(/ObjStm)、交叉引用流、ToUnicode CMap、二字节 CID、无 /Widths 的子集字体(内置 Times 度量表)
② 量版式统计出页边距、各级字号、行距、段距、强调色、页眉页脚的位置与文字,再把内容切成块(标题 / 节标题 / 定理标题 / 正文 / 独立公式 / 页眉 / 页脚)
③ 翻译逐块交给模型,公式还原成 LaTeX(PDF 里抓出来的是 a1,a2,a3,...,n,a... 这种碎片);分批 + 失败对半拆 + 漏块补问
④ 重排用②量出来的参数生成 HTML,KaTeX 渲染公式(编号 \tag{5.1} 右对齐);每节独立压缩,先收间距再收字号,尽量贴合原件页数
⑤ 打印无头 Edge 经 CDP Page.printToPDF 打成 PDF(吃 @page,纸张跟原件一致)

底线:宁可多排一页,绝不裁内容。 内容超出时会自动多分页;只有"只超出一点点"才压缩重排。

安装

dsh plugin --profile web add <本目录>

装完重启桌面应用(或刷新页面)生效。宿主半注册 Cordis 服务 pdfTranslate, 浏览器半注册左侧栏入口与主面板,通过 ctx.remote.$mount 挂载同名命名空间。

已知边界

  • 只处理有文字层的电子版 PDF;扫描件会被明确拒绝(不做 OCR)
  • 只做英译中
  • 译文用默认模型(面板上会显示),不支持逐份指定语言对

皮肤兼容(踩过的坑)

面板落在会话列里,而皮肤(如 maid-atelier)会把立绘层 prepend 进同一列, 那一层是 position:absolute; z-index:0 —— 未定位的兄弟节点一律画在它下面, 症状是"隐约几行字、什么都点不着"。

所以根节点必须 position: relative(不要加 z-index,加了会新建层叠上下文, 设置/下拉这些页面级弹层就跑不到上面去),并且要有底色(加 backdrop-filter 毛玻璃最好读)。

颜色一律用 color-mix(in srgb, currentColor N%, transparent) 就地调, 不要依赖 --dsw-alias-* 令牌——本机这个 DSH 版本里它们不存在,写了等于永远走兜底值, 深色兜底文本落到浅色皮肤上就是不可读。

开发与自检

pnpm install
pnpm run typecheck      # tsc --noEmit
pnpm run build          # tsdown 构建客户端 + 包成 ModuleLoader 工厂
node verify.mjs         # 88 项离线断言(失败即 exit 1)

verify.mjs 覆盖:宿主/客户端 wire 契约逐字一致、客户端产物是 ModuleLoader 工厂、 以及引擎行为——自带两份 PDF 夹具(经典表 + 对象流)跑"解析→量版式→分块→重排"。 下面这些坑都已固化成断言,删代码前先看它们:

  • 公式必须真的被 KaTeX 渲染(出现 kerr 即失败)
  • 带 \[…\] / $$…$$ 外壳的公式要能渲染(模型爱连定界符一起返回)
  • 对象流 PDF 必须读出页数(否则是 0 页)
  • 模型停滞时必须被超时打断(不许无限等)
  • 面板根节点必须定位(否则被皮肤立绘盖住)

tools/engine-render.mjs 可以完全脱离 DSH 跑通"解析→分块→重排→打印"(用占位译者), 用来单独验证版式;DSH_PDF_TRANSLATE_KEEP_HTML=1 会保留中间 HTML。

第三方

lib/vendor/katex/ 是 KaTeX 的发布产物(MIT), 为了离线渲染公式随包分发;该目录里另有一份 package.json 声明 commonjs ——插件根是 "type": "module",不声明的话 Node 会把 UMD 当 ESM 加载, this 变成 undefined,所有公式会退化成红色源码。

License

MIT

Versions

Latest versionPublishedSize
0.1.0——

Comments

Loading…

From the same category

archify

by tt-a1i

Agent skill for beautiful, verifiable architecture, workflow, sequence, data-flow, and lifecycle diagrams—self-contained HTML with motion and crisp export.

Workflow & AutomationTools & CapabilitiesDevelopment & InfrastructureManifest valid

★ 71.7k

↓ 3.5k/wk

MIT

JavaScript

Sep 25, 2026

dsh plugin --profile agent add @tt-a1i/archify-dsh

DeepSeek Harness plugin for Reactive Resume: bridges your resumes and job applications into a Harness session over MCP.

Tools & CapabilitiesManifest valid

★ 41.7k

↓ 236/wk

MIT

Aug 24, 2026

dsh plugin --profile web add dsh-plugin-reactive-resume

by Tencent

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

Development & InfrastructureTools & CapabilitiesManifest valid

★ 30.1k

↓ 838/wk

NOASSERTION

Go

Sep 25, 2026

dsh plugin --profile web add @wxg-prc-cpg/dsh-weknora

by anywhere-labs

为 DeepSeek Harness (DSH) 插件生态打造的现代化桌面端解决方案。万物皆「插件」,桌面本身也是「插件」。

Tools & CapabilitiesManifest valid

★ 29k

↓ 167/wk

MIT

TypeScript

Sep 25, 2026

dsh plugin --profile web add dsh-plugin-desktop

deepseek-harness-desktop is a interface plugin for DeepSeek Harness. See the repository documentation for its documented capabilities.

Tools & CapabilitiesUI & Experience

★ 28.6k

MIT

Index only — not installable

by titanwings

Distilly — Distill how they think into reusable Skills for any Agent or Bot. Formerly Colleague Skill(原同事 Skill).

Tools & Capabilities

★ 25k

MIT

TypeScript

Sep 22, 2026

Index only — not installable