Turn MinerU output into publishable MkDocs Material book sites
Project description
MineruPress
把 MinerU 解析结果整理成可以发布的 MkDocs Material 图书站点。
MineruPress 适合处理扫描教材、课程讲义、内部手册和长 PDF 知识库迁移:输入 MinerU 生成的 content_list.json 与图片,输出按章节拆分的 Markdown、图片资源和可直接部署的静态站点。
英文 README:docs/README_EN.md
快速开始
复制模板就是一本新书的起点:
cp -r book_template/ my-book
cd my-book
minerupress fetch book.yml
mkdocs serve
如果已经有现成的 MinerU 解析结果,把它放到 resources/mineru/,并把 source 改成 uploaded_result 后运行:
minerupress export book.yml
mkdocs serve
标准链路如下:
PDF / Office / 图片
|
v
MinerU 官方 API / 外部安装的本地 MinerU CLI / 已上传解析结果
|
v
resources/mineru/*_content_list.json 与图片
|
v
docs/chapters/*.md 与 docs/images/
|
v
MkDocs Material 图书站点
解决什么问题
- 长 PDF 经 MinerU 解析后,结果通常是一堆 JSON、图片和松散文本;MineruPress 把它们整理成稳定的图书工程。
- 一本书可以被拆成多个 PDF 分片,导出时仍按同一个逻辑分册连续匹配章节。
- 章节边界优先由标题自动推导,减少手写正则;遇到目录页、附录、项目制教材和中英文标题时也能更稳。
- 导出过程可重复执行,每次重建章节 Markdown 和图片目录,避免旧文件混进新站点。
- 插件系统负责二维码过滤、中西文间距、导出后部署等差异化工作,不把某本书的规则写死进核心代码。
安装
要求 Python >=3.11。
普通使用推荐直接安装发布包。首次 PyPI 发布完成后可用:
pip install "minerupress[all]"
pip install mkdocs mkdocs-material
如果你更希望把 CLI 隔离到独立环境,推荐在发布后使用:
pipx install 'minerupress[all]'
pipx inject minerupress mkdocs mkdocs-material
升级时分别使用:
pip install -U "minerupress[all]"
或:
pipx upgrade minerupress
pipx inject minerupress mkdocs mkdocs-material --include-apps
如果你是在开发或修改工具链本身,再使用 GitHub 开发安装:
git clone https://github.com/aronnaxlin/minerupress.git
cd minerupress
pip install -e ".[all]"
可选依赖:
| 依赖组 | 依赖 | 用途 |
|---|---|---|
qr |
opencv-python |
qr_filter 二维码图片过滤 |
cjk |
pangu |
cjk_spacing 中西文间距处理 |
all |
上面两组 | 常见完整环境 |
新书工作区
建议每本书使用独立目录,不要直接把某本书的生成物放进工具链仓库。
cp -r book_template/ ~/dev/my-book/
cd ~/dev/my-book/
模板里已经包含:
book.yml:书籍配置、章节列表、来源选择、MinerU API / 本地工具链和部署配置。mkdocs.yml:MkDocs Material 站点配置。.env.example:敏感环境变量示例。Makefile:常用导出、校验、构建命令。
常见工作区结构:
my-book/
book.yml
mkdocs.yml
resources/mineru/
docs/
site/
resources/、docs/、site/ 通常是某本书自己的输入和输出,不应提交到 MineruPress 工具链仓库;如果你在独立图书仓库中维护成品站点,再按那个仓库的规则决定是否纳入版本控制。
常用命令
已有 MinerU 解析结果,直接导出:
minerupress export book.yml
按 source 准备来源后导出:
minerupress fetch book.yml
用导出命令先准备来源再导出:
minerupress export --fetch book.yml
分析 MinerU 输出中的正文大标题,生成章节配置草稿:
minerupress headings resources/mineru --volume-uid javaweb --format yaml --body-only
严格构建站点:
mkdocs build --strict
生成或比对文档指纹:
minerupress fingerprint --docs-dir docs --out reports/fingerprints.json
book.yml 示例
source: official_api
mineru_root: resources/mineru
docs_out: docs
volume_uid: javaweb
toc_max_page: 10
allow_missing_boundaries: false
plugins:
- qr_filter
- cjk_spacing
chapters:
- slug: ch01-overview
title: 第1章 Web开发概述
- slug: appendix-a
title: 附录A 部分习题的解答
来源选择:
official_api:使用api:配置走 MinerU 官方 API。新模板默认就是这个模式。local_toolchain:调用你单独安装的mineruCLI。MineruPress 不内置 MinerU 依赖,只做外部适配。uploaded_result:直接读取mineru_root下已有的 MinerU 结果目录。
如果你选择 local_toolchain,请先按 MinerU 官方说明单独安装,例如:
uv pip install -U "mineru[all]"
或从源码安装:
git clone https://github.com/opendatalab/MinerU.git
cd MinerU
uv pip install -e .[all]
MinerU 官方文档还提供了按需扩展安装和轻量客户端说明:
边界匹配建议:
- 优先只写
title。 - MinerU 标题存在别名时加
aliases。 - 必须手工控制正则时再写
start_pattern或start_patterns。 - 正式导出保持
allow_missing_boundaries: false,避免章节错位后继续生成。
所有相对路径都以 book.yml 所在目录为基准解析,所以可以从任意目录执行:
minerupress export /path/to/my-book/book.yml
CLI 现已统一为 minerupress <subcommand>,例如:
minerupress exportminerupress fetchminerupress headingsminerupress fingerprint
旧入口 minerupress-export、minerupress-fetch、minerupress-headings 以及 mineru-export、mineru-fetch 仍然保留,便于旧项目平滑迁移。
内置插件
qr_filter:使用 OpenCV 检测并过滤小尺寸二维码图片。cjk_spacing:使用pangu为中西文混排补空格,并保护 LaTeX 公式片段。cf_pages:执行mkdocs build --strict后部署到 Cloudflare Pages;项目不存在时会自动创建后重试。
自定义插件继承 ExportPlugin:
from pathlib import Path
from minerupress import ExportPlugin
class MyPlugin(ExportPlugin):
def on_image(self, item: dict, img_path: Path | None) -> bool:
return True
def on_text(self, item: dict, text: str) -> str:
return text
def on_chapter_done(self, slug: str, lines: list[str]) -> list[str]:
return lines
def on_export_done(self, docs_out: Path) -> None:
pass
然后在 book.yml 中引用:
plugins:
- mypackage.mymodule.MyPlugin
测试与发布状态
本地验证:
pip install -e ".[dev]"
pytest
python -m compileall minerupress
仓库已配置 GitHub Actions,在 Python 3.11 和 3.12 上运行 compileall 与 pytest。如果你只是使用工具链,优先安装发布包;如果你要参与开发,再使用 GitHub 开发安装。
文档
Agent Skill 安装
仓库内置了可给外部 agent 安装的 Skill:
skills/minerupress/
使用者可以从这个仓库获取:
npx skills add aronnaxlin/minerupress --skill minerupress
安装后,agent 可以按同一套流程处理图书配置、MinerU 抓取、章节导出、构建校验、排障和 Cloudflare Pages 部署。维护工具链时,如果流程行为改变,也要同步更新 skills/minerupress/。
仓库边界
这个仓库是通用工具链,docs/ 用来放项目文档,book_template/ 用来放新书模板。某本书的本地工作区、MinerU 输出、站点构建结果和敏感配置应保持隔离,不要提交到这里。
通常不要提交:
- 本地图书工作区目录
resources/site/reports/.env.wrangler/
致谢
许可证
Apache License 2.0,见 LICENSE。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file minerupress-0.1.0.tar.gz.
File metadata
- Download URL: minerupress-0.1.0.tar.gz
- Upload date:
- Size: 38.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14b04e35ca911fd16dc76ae0da901ec80a6f617d82d7850e3a648799afec4432
|
|
| MD5 |
a9c837170d733b97347b18a9ef4ce3a8
|
|
| BLAKE2b-256 |
594abe5a1c74bf57c2f1b58689d855238c87874e391efb48b71228cac1ff5099
|
Provenance
The following attestation bundles were made for minerupress-0.1.0.tar.gz:
Publisher:
release.yml on aronnaxlin/minerupress
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
minerupress-0.1.0.tar.gz -
Subject digest:
14b04e35ca911fd16dc76ae0da901ec80a6f617d82d7850e3a648799afec4432 - Sigstore transparency entry: 1572008483
- Sigstore integration time:
-
Permalink:
aronnaxlin/minerupress@ccf9f99e49b96f786f33ea6600583f84dafa8840 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aronnaxlin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ccf9f99e49b96f786f33ea6600583f84dafa8840 -
Trigger Event:
release
-
Statement type:
File details
Details for the file minerupress-0.1.0-py3-none-any.whl.
File metadata
- Download URL: minerupress-0.1.0-py3-none-any.whl
- Upload date:
- Size: 37.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35bd25c2a1e15c52f53c72b4a4c5eda9639296191d9c5934e1130f32ed52e487
|
|
| MD5 |
249a710e5b5077cb074f5a695dcd339e
|
|
| BLAKE2b-256 |
50f50b8b5bc1443ea0005de615030a92f3d835442008301c10318c771fdda586
|
Provenance
The following attestation bundles were made for minerupress-0.1.0-py3-none-any.whl:
Publisher:
release.yml on aronnaxlin/minerupress
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
minerupress-0.1.0-py3-none-any.whl -
Subject digest:
35bd25c2a1e15c52f53c72b4a4c5eda9639296191d9c5934e1130f32ed52e487 - Sigstore transparency entry: 1572008486
- Sigstore integration time:
-
Permalink:
aronnaxlin/minerupress@ccf9f99e49b96f786f33ea6600583f84dafa8840 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aronnaxlin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ccf9f99e49b96f786f33ea6600583f84dafa8840 -
Trigger Event:
release
-
Statement type: