agentleFS
zyheal-xingzyheal-xing/pdf-parsing-and-translation-skills/skills/mineru-pdf-parse/SKILL.md

mineru-pdf-parse

Skill8 starsChanged 7 months agoMITView on GitHub

使用本机 MinerU CLI 将用户指定的 PDF 解析为 LLM 易读的 Markdown / JSON / 图片输出目录。用于文献精读、文献翻译和其他 PDF 后处理前置步骤;输出目录固定放在 PDF 同目录下并按规范整理图片命名。

The file

Files
SKILL.md

MinerU PDF 解析

目标

把用户指定的单个 PDF 用本机 MinerU 解析为可复用的本地输出目录,供其他 PDF 工作流读取。

必要输入

  • 用户指定的单个 PDF 路径。

如果用户只给了目录或多篇 PDF,先确认要解析哪一篇。不要默认批量处理,除非用户明确要求逐篇解析。

本机 MinerU

默认使用本机 CLI:

mineru -p <input.pdf> -o <output_dir> -b pipeline

开始前检查:

  • command -v mineru
  • mineru --version

如果 mineru 不可用、运行失败或输出质量明显异常,停止并报告命令、错误摘要和影响。不要改用普通 PDF 文本抽取冒充 MinerU 输出。

输出目录

输出根目录必须放在被读入 PDF 的同一目录下,命名为:

<pdf_stem>_mineru/

例如:

/path/to/Trilinear Compute-in-Memory Architecture for Energy-Efficient Transformer Acceleration.pdf
/path/to/Trilinear Compute-in-Memory Architecture for Energy-Efficient Transformer Acceleration_mineru/

规则:

  • mineru -o 必须指向这个单独输出根目录。
  • 允许 MinerU 在其中生成内部目录结构,例如 <pdf_stem>/auto/。
  • 不要把 Markdown、JSON、图片、layout.pdf、span.pdf 或中间文件散列到 PDF 目录根层。
  • 不要默认输出到 /tmp。
  • 如果 <pdf_stem>_mineru/ 已存在,先检查是否已有完整可用输出。需要重跑时不要删除旧目录,改用 <pdf_stem>_mineru_v2/、<pdf_stem>_mineru_v3/ 等相邻目录,除非用户明确要求覆盖。

必须确认的 MinerU 输出

解析完成后,在输出根目录中定位并记录:

  • 主 Markdown:通常是 *.md。
  • 内容 JSON:*_content_list.json 和 / 或 *_content_list_v2.json。
  • layout.pdf 和 span.pdf,如 MinerU 生成。
  • middle.json、model.json 等中间结果,如 MinerU 生成。
  • MinerU 原始图片目录来源位置,如存在。

如果缺少主 Markdown 或内容 JSON,不能视为成功完成。

默认辅助脚本

这个 skill 现在默认配套使用:

scripts/mineru_image_tool.py

用途:

  • inventory:扫描 MinerU 输出,汇总所有图片、Markdown 邻近 caption、content_list 页码与类型信息,生成可复核的 manifest 模板。
  • apply:读取已经复核过的 manifest,执行图片移动 / 重命名、主 Markdown 图片引用回写、images/image_index.md 生成,以及原始嵌套 images/ 目录清理。

推荐流程:

  1. 先运行 inventory 生成 manifest 模板。
  2. 结合主 Markdown、content_list*.json、必要时原 PDF / layout.pdf / span.pdf,复核 manifest 中的图号、表号、公式号、caption 短标题和 target_name。
  3. 再运行 apply 执行最终整理。

示例:

python3 <skill_dir>/scripts/mineru_image_tool.py inventory \
  --output-root <pdf_stem>_mineru \
  --manifest-out /tmp/<pdf_stem>_image_manifest.json

python3 <skill_dir>/scripts/mineru_image_tool.py apply \
  --output-root <pdf_stem>_mineru \
  --manifest /tmp/<pdf_stem>_image_manifest.json

注意:

  • inventory 生成的是“待复核模板”,不是可盲信的最终命名结果。
  • 对于多子图、公式截图、caption 错位、MinerU 漏识别或疑似错序的情况,必须人工复核后再执行 apply。
  • 不要跳过复核,直接把脚本猜测结果当成最终规范命名。

图片规范整理

MinerU 提取到内部 images 目录的公式、图、表、chart 图片通常是乱码或 hash 文件名。解析完成后必须把所有图片统一整理到唯一规范图片目录:

<pdf_stem>_mineru/images/

规则:

  • 只能保留这一个图片目录。不要同时保留 MinerU 内部生成的 <pdf_stem>/auto/images/ 或其他嵌套 images/ 目录。
  • 所有 MinerU 输出图片都必须进入规范图片目录,不只整理“后续需要引用”的图片。
  • 规范整理使用移动 / 转换,不使用复制制造重复图片。若需要格式转换,先生成规范 .jpg,确认可读后删除对应原始图片。
  • 规范图片统一使用 .jpg。如果原图不是 .jpg,转换或另存为 .jpg 后删除原始图片。
  • 命名必须尽量对照 PDF 原文编号、caption 和页码;同一类型按 PDF 出现顺序保持可排序:
    • 图:fig_<figure_no>__<short_caption>.jpg
    • 表:table_<table_no>__<short_caption>.jpg
    • 公式:eq_<equation_no>__<short_context>.jpg
    • 未编号对象:fig_unnumbered_p<page>_<idx>__<short_context>.jpg、table_unnumbered_p<page>_<idx>__<short_context>.jpg 或 eq_unnumbered_p<page>_<idx>__<short_context>.jpg
  • 如果同一编号被拆成多张图片,追加 _part1、_part2,例如 fig_3_part2__macro_architecture.jpg。
  • 优先依据 PDF 原文的 Figure / Fig. / 图、Table / 表、公式编号、caption、正文引用和页码交叉确认。
  • 不能只依赖 MinerU 原始文件顺序命名。
  • 无法可靠匹配编号时,文件名必须显式写 unnumbered 或 unknown。不要伪造图号、表号或公式号。
  • 整理后必须更新主 Markdown 中的图片引用,使其指向唯一规范图片目录下的文件。不要让 Markdown 继续引用已删除的 MinerU 内部乱码图片路径。
  • content_list*.json 中的原始图片路径可以不直接改写,但必须能通过 image_index.md 映射到规范文件名;不要让后续 skill 需要读取内部 auto/images/ 才能找到图片。
  • 移动和更新完成后,删除原始嵌套图片目录及其空父目录;不要让 auto/images 留在输出树中。
  • 最终校验 find <pdf_stem>_mineru -type d -name images 应只返回 <pdf_stem>_mineru/images。
  • 如果原始嵌套图片目录无法清理干净,不能把本次解析视为完成。
  • 默认优先使用 scripts/mineru_image_tool.py 完成上述整理,而不是每次临时手写一次性脚本。

必须生成索引:

<pdf_stem>_mineru/images/image_index.md

索引表必须覆盖所有规范图片,至少包含:

规范文件名原始 MinerU 文件路径(整理前)类型编号页码caption / 上下文匹配依据是否建议下游引用备注

如果论文没有任何图片,也要创建 image_index.md 并说明 MinerU 未提取到图片。如果有图片但没有值得下游引用的图片,也要索引全部图片,并在 是否建议下游引用 中标注 否。

输出树约束

整理完成后的输出树必须满足:

  • 唯一图片目录是 <pdf_stem>_mineru/images/。
  • 不能再存在 <pdf_stem>/auto/images/、其他嵌套 images/ 目录,或重复图片副本。
  • 主 Markdown 中的图片路径只能指向 <pdf_stem>_mineru/images/ 下的规范文件名。
  • 下游 skill 不应该再需要读取内部 auto/images/ 才能定位图片。

完成标准

只有满足以下条件,才算完成:

  • MinerU 命令成功执行。
  • 输出根目录位于 PDF 同目录下,且不是散列文件。
  • 主 Markdown 和内容 JSON 可定位。
  • 所有 MinerU 图片都已移动 / 转换为唯一 images/ 目录下的 .jpg 规范命名文件。
  • 原始嵌套 images/ 目录已删除或不存在,输出树中只剩一个图片目录。
  • 主 Markdown 的图片引用已更新到规范图片路径。
  • images/image_index.md 已记录所有图片从原始文件到规范文件的映射。
  • 最终回复给出输出根目录、主 Markdown、内容 JSON、规范图片目录和 image_index.md 路径。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.