本文预计阅读时间:3分钟
项目介绍
MarkItDown是一个轻量级的 Python 实用程序,用于将各种文件转换为 Markdown,以便用于 LLM 和相关的文本分析流程。
目前支持的文件类型如下:
- PowerPoint
- Word
- Excel
- Images (EXIF metadata and OCR)
- Audio (EXIF metadata and speech transcription)
- HTML
- Text-based formats (CSV, JSON, XML)
- ZIP files (iterates over contents)
- Youtube URLs
- EPubs
详情:https://github.com/microsoft/markitdown
项目部署
构建虚拟环境
项目中提供了三种虚拟环境构建方法,使用其中之一即可。
https://github.com/microsoft/markitdown?tab=readme-ov-file#prerequisites
此处使用conda构建虚拟环境
conda create -n markitdown python=3.12
conda activate markitdown
安装markitdown
git clone git@github.com:microsoft/markitdown.git
cd markitdown
pip install -e 'packages/markitdown[all]'
使用
命令行方式
https://github.com/microsoft/markitdown?tab=readme-ov-file#usage
markitdown 需要转换的.pdf > 转换后的文件.md
Python API
参考:https://github.com/microsoft/markitdown?tab=readme-ov-file#python-api
Docker方式安装
参考:https://github.com/microsoft/markitdown?tab=readme-ov-file#docker
总结
个人认为,针对内容复杂的PDF转换到MarkDown,MarkItDown还是显得力不从心,建议使用MinerU,参考《神器MinerU推出客户端了》。
领取专属 10元无门槛券
私享最新 技术干货