Communitygithub.com

Peytontalismanic424/paper-share-skills

使用 MinerU 將 PDF(尤其是學術論文)轉換為乾淨的 Markdown — 保留閱讀順序、LaTeX 方程式、表格與圖片,並在 GPU 上運行。當使用者要求將 PDF 轉換/提取為 Markdown 或文字時使用。直接呼叫即可,無需使用者輸入技能名稱。

paper-share-skills 是什麼?

這是一個 AI 代理技能,專門用於將 PDF 檔案(特別是學術論文)轉換為結構化且乾淨的 Markdown 格式。它依賴於 MinerU(opendatalab/MinerU),這是一個開源的高保真轉換引擎,能夠保留文件的閱讀順序、標題層級、行內 LaTeX 數學公式($...$)、表格(以 HTML 形式呈現)以及圖片。此技能針對 GPU(CUDA)進行了最佳化,並包含一個轉換包裝器,可避免 MinerU CLI 的已知問題(例如在 Windows 上出現 502 Bad Gateway 錯誤)。它支援多種檔案格式,包括 PDF、圖片、DOCX、PPTX 和 XLSX,並提供選項如語言提示(英文或中文)以及針對掃描 PDF 的 OCR 模式。轉換後,技能會報告輸出 Markdown 檔案的路徑,並支援預覽功能。如果遇到問題,該技能還會提供自動化故障排除指引,例如驗證 CUDA 可用性或重新安裝模型。

相容平台~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 -> <路徑>.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 文件)

對於非論文檔案,如果版面保真度不重要,微軟的 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.

相關技能