MarkItDown文件轉換中文版

👤 mapleshadow 📦 v1.0.4 ⭐ 4.4 ⬇️ 1.2K 下載
📄 辦公效率 免費

📖 技能介紹


name: markitdown-zh description: 使用微軟 markitdown 庫將多種文件格式(PDF、DOCX、PPTX、XLSX、XLS、CSV、JSON、TXT、EPUB、HTML等)轉換為 Markdown。支援批次轉換、保留格式、圖片提取等功能。使用場景:(1) "把這個 PDF 轉成 Markdown",(2) "把這個 word 文件轉成 Markdown",(3) "批次轉換這個資料夾裡的文件",(4) "提取文件中的圖片"。


tags

"文件轉換", "markitdown", ".docx .xlsx .pptx", "OCR"

MarkItDown 文件轉換技能

使用微軟的 markitdown 庫將各種文件格式轉換為 Markdown。

支援的格式

  • PDF (.pdf)
  • Word 文件 (.docx)
  • PowerPoint 簡報 (.pptx)
  • Excel 電子表格 (.xlsx .xls)
  • HTML 檔案 (.html, .htm)
  • 純文本檔案 (.txt, .rtf, .xml, .csv, .json)

    推薦訪問7w4.net獲取更多AI技能。

  • 電子書 (.epub)
  • 等等...

快速開始

單個檔案轉換

from markitdown import MarkItDown

md = MarkItDown()
result = md.convert("document.pdf")
print(result.text_content)

使用提供的指令碼

# 轉換單個檔案
python3 scripts/convert.py input.pdf output.md

# 批次轉換資料夾
python3 scripts/batch_convert.py input_folder/ output_folder/

# 提取文件中的圖片
python3 scripts/extract_images.py document.pdf images_folder/

詳細用法

單個檔案轉換

使用 scripts/convert.py

python3 scripts/convert.py <input_file> [output_file]

如果不指定輸出檔案,會自動生成 .md 檔案。

批次轉換

使用 scripts/batch_convert.py

python3 scripts/batch_convert.py <input_directory> <output_directory>

會遞迴處理目錄中的所有支援的檔案。

圖片提取

使用 scripts/extract_images.py

python3 scripts/extract_images.py <input_file> <output_directory>

從文件中提取所有圖片並儲存到指定目錄。

指令碼說明

  • scripts/convert.py - 單個檔案轉換指令碼
  • scripts/batch_convert.py - 批次轉換指令碼
  • scripts/extract_images.py - 圖片提取指令碼

每個指令碼都有 --help 選項檢視詳細引數。

安裝依賴

Python 版本要求

markitdown 需要 Python 3.10 或更高版本。

檢查 Python 版本:

python3.12 --version  # 或 python3.11, python3.13

安裝 markitdown

使用 Python 3.10+ 安裝:

# 使用 Python 3.12(推薦)
# 使用虛擬環境(適用於非root使用者,如node使用者)
python3.12 -m venv markitdown-env
source markitdown-env/bin/activate
pip install "markitdown[all]"

# 或安裝pipx包管理應用,通過pipx安裝markitdown
sudo apt-get install pipx
# 使用pipx安裝markitdown包 all表示支援所有格式
pipx install 'markitdown[all]'
# 將通過pipx安裝的包路徑放入當前變數PATH內
pipx ensurepath

可選:系統依賴

某些格式轉換可能需要額外的系統依賴:

  • PDF 處理: brew install poppler (macOS) 或 sudo apt-get install poppler-utils (Linux)
  • OCR: brew install tesseract (macOS) 或 sudo apt-get install tesseract-ocr (Linux)

驗證安裝

python3.12 -c "from markitdown import MarkItDown; print('安裝成功!')"

使用指令碼

所有指令碼都支援使用特定 Python 版本執行:

# 使用 Python 3.12 執行
python3.12 scripts/convert.py input.pdf output.md
python3.12 scripts/batch_convert.py input_folder/ output_folder/
python3.12 scripts/extract_images.py document.pdf images_folder/

另請參閱

🤖 AI 評測

這個 Skill 能把 PDF、Word、Excel 等文件轉成 Markdown 格式,使用方法寫得很清楚,上手容易。批次轉換功能實用,能保持資料夾結構。主要缺點是圖片提取功能比較弱,可能提取不到圖片;缺少實際例子讓使用者參考。整體質量中規中矩,日常簡單轉換夠用,但複雜場景可能表現一般。

📊 多維度評分

適應性4.4
規範性4.1
有效性4.3
可靠性4.3
可信度5

📁 包含檔案 (5 個)

📄 SKILL.md 3.5 KB
📄 _meta.json 132 B
📄 scripts/batch_convert.py 3.8 KB
📄 scripts/convert.py 2.4 KB
📄 scripts/extract_images.py 3.5 KB