OpenParable
Skip to content
← Back to skills

Document Conversion

Documents
document-conversion

Document Conversion is an Agent Skill for documents published in the majiayu000/claude-skill-registry repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

将 DOC/DOCX/PDF/PPT/PPTX 文档转换为 Markdown 格式。自动检测 PDF 类型(电子版/扫描版),提取图片到独立目录。当管理员入库非 Markdown 文档时使用此 Skill。触发条件:入库 DOC/DOCX/PDF/PPT/PPTX 格式文件。

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/majiayu000/claude-skill-registry/blob/HEAD/skills/documents/document-conversion-harryoung-efka/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/document-conversion, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

文档格式转换

将各种文档格式转换为 Markdown,用于知识库入库。

支持格式

格式处理方式
DOCXPandoc 转换,保留格式和图片
DOCLibreOffice → DOCX → Pandoc
PDF 电子版PyMuPDF4LLM 快速转换
PDF 扫描版PaddleOCR-VL 在线 OCR
PPTXpptx2md 专业转换
PPTLibreOffice → PPTX → pptx2md

调用方式

python .claude/skills/document-conversion/scripts/smart_convert.py \
    <temp_path> \
    --original-name "<原始文件名>" \
    --json-output

参数说明:

  • <temp_path>: 临时文件路径(如 /tmp/kb_upload_xxx.pptx)
  • --original-name: 必须传入原始文件名,用于生成正确的图片目录名
  • --json-output: 输出 JSON 格式结果

输出格式

{
  "success": true,
  "markdown_file": "/path/to/output.md",
  "images_dir": "原始文件名_images",
  "image_count": 5,
  "input_file": "/path/to/input.pptx"
}

处理流程

  1. 执行转换命令(必须使用 --original-name 和 --json-output)
  2. 解析 JSON 输出,检查 success 字段
  3. 如果 success: false,报告错误并结束
  4. 如果 success: true,记录生成的文件路径和图片目录

重要提示

  • 图片目录使用原始文件名命名(如 培训资料_images/)
  • 不传 --original-name 会导致图片引用路径错误
  • PDF 类型自动检测,扫描版处理较慢(几十秒到几分钟)

格式详情

各格式的详细处理说明,见 FORMATS.md