Communitygithub.com

Peytontalismanic424/paper-share-skills

使用 MinerU 将 PDF(尤其是学术论文)转换为结构清晰的 Markdown,保留阅读顺序、LaTeX 公式、表格和图片,并利用 GPU 运行。当用户请求将 PDF 转换为 Markdown/文本时直接调用,无需用户输入技能名称。

paper-share-skills 是什么?

该技能基于 MinerU 引擎,提供将 PDF(特别是学术论文)转换为干净、结构保留的 Markdown 的功能。它利用 GPU(CUDA)加速处理,能够很好地处理多栏布局、LaTeX 公式、表格和图表,输出结果包含正确的标题层级、内联 LaTeX 数学公式(`$...$`)以及 HTML 格式的表格。技能通过一个封装脚本来调用 MinerU 的 Python API,避免了直接使用 CLI 时在 Windows 上可能出现的 `502 Bad Gateway` 问题。除了 PDF,它还支持图片、`.docx`、`.pptx` 和 `.xlsx` 文件。该技能可部署在支持 CUDA 的环境中,必要时也可回退到 CPU 运行,但速度会慢一些。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Peytontalismanic424/paper-share-skills/tree/HEAD/pdf-to-markdown

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

PDF → Markdown (MinerU)

使用 MinerU (opendatalab/MinerU) 将 PDF 转换为干净且保留结构的 Markdown,这是处理学术论文的最高保真度开源引擎。管道后端在 GPU(CUDA)上运行。输出保留标题层级、内联 LaTeX 数学公式($...$)、图表和表格(以 HTML 形式呈现)。

使用时机

  • 用户请求“将这份 PDF 转换/提取为 Markdown(或文本)”。
  • 最佳适用场景:学术论文——多栏布局、LaTeX 数学公式、表格、参考文献。
  • 也能处理图片、.docx、.pptx、.xlsx 文件(直接传入文件)。

如何运行

MinerU 位于一个专用的隔离环境中,通过附带的 convert.py 封装脚本驱动,该脚本在进程内调用 MinerU 的 Python API。

这里 不要 使用 mineru CLI —— 在 3.4.0 版本中,它会在本地启动一个 API 服务器,在 Windows 上返回 502 Bad Gateway。封装脚本绕过了这个问题。

"$MINERU_PYTHON" \
  "<SKILLS_DIR>/pdf-to-markdown/convert.py" \
  "<input.pdf>" "<output_dir>" --lang en
  • 参数 1 — 输入文件(pdf/图片/docx/pptx/xlsx)。
  • 参数 2 — 输出目录。
  • --lang — OCR 语言提示:en 表示英文,ch 表示中文/混合(默认是 ch,也能处理英文)。仅影响 OCR 处理的(扫描)页面。
  • 成功时脚本会打印 DONE -> <path to .md>。

输出布局

<output_dir>/<name>/auto/<name>.md       # markdown 文件
<output_dir>/<name>/auto/images/          # 提取的图片(在 markdown 中引用)
<output_dir>/<name>/auto/<name>_*.json    # 布局/内容元数据(可忽略)

转换完成后

  1. 读取打印的 DONE -> ...md 路径并告知用户。
  2. 可选择显示简短预览(标题 + 前几个标题)。
  3. 说明提取图片的写入位置。
  4. 质量通常很高:标题显示为 #,内联数学公式显示为 $...$,表格显示为 <table> HTML(单元格内可包含 LaTeX)。如果扫描版 PDF 出现乱码,请使用 --method ocr 重新运行。

预备/设置(仅在缺少某些组件时执行)

  • 包含 MinerU 的解释器(环境 MINERU_PYTHON,默认为 python)。
  • 验证 CUDA:$MINERU_PYTHON -c "import torch; print(torch.cuda.is_available())" → True。
  • 模型已预先下载到 ~/.cache/huggingface/hub/(一次性操作)。

如果缺少环境,请重新创建(如有需要,先安装 uv):

uv venv --python 3.12 "<your-env>"
uv pip install --python "<your-env>/Scripts/python.exe" torch torchvision --index-url https://download.pytorch.org/whl/cu124
uv pip install --python "<your-env>/Scripts/python.exe" -U "mineru[core]"
"<your-env>/Scripts/mineru-models-download.exe" -s huggingface -m pipeline

然后设置 MINERU_PYTHON 为 <your-env>/Scripts/python.exe(Windows)或 <your-env>/bin/python(macOS/Linux)。在 macOS/Linux 上,模型下载二进制文件是 mineru-models-download(不带 .exe 后缀)。

故障排除

  • cuda.is_available() 返回 False → 从 cu124 索引重新安装 torch(参见设置)。如果必要,管道仍然可以在 CPU 上运行,只是速度较慢。
  • 模型下载失败/缓慢 → 使用 -s modelscope 重新运行 mineru-models-download。
  • 扫描版 PDF 乱码 → 在调用 convert.py 时添加 --method ocr。
  • vlm-engine / hybrid-engine 后端 → 这些需要 vLLM/SGLang(Linux);它们在 Windows 上返回 502。请坚持使用封装脚本使用的默认 pipeline 后端。

轻量级备选方案(简单 / Office 文档)

对于不需要布局保真度的非论文文件,Microsoft 的 MarkItDown 更快更简单——但它会破坏学术类双栏 PDF 和表格,因此对于论文,请优先使用 MinerU:

"$MINERU_PYTHON" -m pip install markitdown
"$MINERU_PYTHON" -m markitdown "<input>" > out.md

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

Peytontalismanic424/paper-share-skills

Validate and upload narrated paper videos to Bilibili with biliup. Handles required landscape-first/portrait-second submissions, series uploads, CST scheduling, diagnostics, dry-run validation, and durable upload receipts. Trigger on: "upload to bilibili", "bilibili upload", "发布到B站", "上传到B站".

Peytontalismanic424/paper-share-skills

Download the TeX source (e-print tar.gz) of an arXiv paper from an arXiv URL or bare ID, and unpack it into paper_src/. Use FIRST whenever a pipeline input is an arXiv link and the TeX source is preferred over the PDF (paper-to-beamer, paper-to-bilibili, paper-venue-discovery). Invoke with an arXiv URL (abs/pdf/e-print, arxiv.org or export.arxiv.org) or a bare ID like 2509.07996v4.

Peytontalismanic424/paper-share-skills

Convert Beamer PDF slides into a fail-closed narrated MP4 with page-aligned narration, TTS audio, cover, and upload metadata. Trigger on narrated slides, slide video, or paper video requests.

Peytontalismanic424/paper-share-skills

Automated pipeline: paper (PDF or TeX source) → SUSTech Beamer slides (11-section 论文分享 structure) → compiled PDF. When TeX source is available, skip MinerU and extract content directly from LaTeX. Use when the user asks to create Beamer slides from an academic paper, or says "论文分享", "paper to slides", "make beamer from paper". Invoke with an absolute or relative path to a PDF, .tar.gz TeX archive, .tex file, or an arXiv URL/ID (source TeX is downloaded first via skill://paper-download-arxiv-paper-source).

Peytontalismanic424/paper-share-skills

Orchestrate a paper PDF through MinerU, SUSTech Beamer slides, complete Chinese narration, landscape and portrait video, metadata gates, and Bilibili upload. Supports single-paper and batch slides, video, or bilibili phases. Trigger on full paper-to-Bilibili requests, PDF-to-video publication, and batch paper publishing.

Peytontalismanic424/paper-share-skills

Generate a deterministic 16:10 video-cover poster from a paper directory. Extracts paper metadata and figures and atomically produces poster.tex, poster.pdf, and poster.png. Use for paper-video covers, not conference posters.

Peytontalismanic424/paper-share-skills

Fix for undefined \setsource/\setdomains/\setpresenter/\setvenue commands when compiling SUSTech Beamer slides from the standard template. Copy the extended beamerthemesustech.sty from the sustech-slides-template repository.

相关技能