Nico0713520 / dsh-doc-to-markdown

已收录

Convert PDF/DOCX to Markdown. Chinese-PDF optimized (NFKC), Windows-first. dsh / Claude Code / OpenClaw compatible SKILL.md skill.

master技能 查看源代码

安装

npx -y @deepseek-ai/dsh plugin --profile web add github:Nico0713520/dsh-doc-to-markdown

此安装命令根据 GitHub 仓库地址生成,是未经验证的安装起点。

README

维护者编写的文档快照。

在 GitHub 查看 ↗
提交版本 66b2328同步于 2026年8月18日

dsh-doc-to-markdown

Node Python (PDF only) Platform License: MIT Tests

Convert PDF & Word documents to clean, LLM-friendly Markdown. Deterministic rules — no AI calls, no tokens, no cost.

中文用户请看 下方速览


Why this one

markitdownraw pymupdf4llmdsh-doc-to-markdown
Chinese PDF font glitches (, )✅ NFKC normalization + rescue
Windows Chinese/space paths⚠️⚠️ argv encoding bugs✅ temp-file arg passing
Scanned PDF detection❌ silent garbage✅ explicit "needs OCR" report
Path traversal safetyn/a✅ built-in guard
Agent-friendly output❌ human text✅ JSON stdout contract
DOCX without Python❌ needs Pythonn/a✅ pure Node (mammoth)

One-line pitch: it's the converter that survives real-world Chinese PDFs and Windows paths, and speaks JSON to your agent.

Demo

Input: a real-world Chinese PDF (exported notes with tables)

# 输入标题
## Cat Wu:AI 时代,产品经理的工作方式已被彻底重构
...

Output Markdown (actual conversion, see examples/):

## 三个工具的分工架构:按职责层级划分

|工具|职责层级|权限范围|干什么|
|---|---|---|---|
|Claude.ai|大脑层(思维)|最小:纯对话|想策略、讨论棘手问题|
|Claude Code|执行层(动手)|中等:代码域|写原型、跑脚本|
|Cowork|管家层(系统操作)|最大:跨应用跨系统|清邮件、管待办、做PPT|

判断标准不是"这是什么任务",而是 **"我要什么输出"**。

Headings, tables, bold, lists — all preserved. Zero garbled characters.

Quick start

git clone https://github.com/Nico0713520/dsh-doc-to-markdown
cd dsh-doc-to-markdown
npm install

# DOCX works immediately (pure Node)
node scripts/convert.cjs "论文.docx" -o 论文.md

# PDF needs Python once:
pip install pymupdf4llm
node scripts/convert.cjs "报告.pdf" --stdout

JSON result contract (parse this in your agent):

{
  "ok": true,
  "format": "pdf",
  "input": "E:\\docs\\报告.pdf",
  "output": "E:\\docs\\报告.md",
  "warnings": []
}

Failure is also structured — show error to the user, never retry blindly:

{ "ok": false, "error": "This PDF appears to be a scanned document (no text layer). OCR is required." }

Engine routing

FormatEngineFallback
.docxmammoth + turndown (pure Node)
.pdf (text layer)PyMuPDF4LLM via Python subprocessclear setup hint if Python missing
.pdf (scanned)detected via text-layer probeexplicit "needs OCR" error

Install as a skill

dsh / Claude Code / OpenClaw — this repo is a standard SKILL.md package. Point your skill provider at this repo (or clone into your skills directory); SKILL.md frontmatter handles activation triggers:

  • "convert this PDF/Word to Markdown"
  • “把 PDF/Word 转 markdown”、“提取文档内容”

中文速览

把 PDF / Word 转成干净的 Markdown,纯规则转换,不调用 AI、零成本。

  • 中文 PDF 专项优化:NFKC 归一化解决 CID 字体的兼容字形()和乱码(),这是 markitdown 等上游工具的盲区
  • Windows 一等公民:中文路径、空格路径、子进程编码坑全部处理
  • 表格友好:DOCX 表格转 GitHub 风格管道表格,标题层级完整保留
  • Agent 契约:stdout 输出结构化 JSON,成功失败都有明确字段
  • 扫描件识别:无文字层的扫描 PDF 会明确报告需要 OCR,不会静默输出垃圾

用法:npm installnode scripts/convert.cjs 文件.pdf -o 输出.md(PDF 需 pip install pymupdf4llm

Tests

npm test   # 10/10: happy paths, Chinese filenames, traversal guard, degradation

Roadmap

  • XLSX / PPTX via markitdown (optional dependency)
  • Scanned-PDF OCR pipeline (vision API, opt-in)
  • Two-column academic PDF layout heuristics

License

MIT

项目文件与信号

以下项目是目录快照中检测到的公开仓库信号。

测试已检测
示例已检测

仓库信息

开发语言
JavaScript
许可证
MIT
最新发布
v0.1.0
最后更新
2026年8月17日 16:27

谨慎安装

请检查源代码、权限、生命周期脚本、依赖与网络访问;不受信任的插件应先在隔离环境中测试。