仓库地址:https://github.com/microsoft/markitdown

简介

用于将文件和办公文档转换为 Markdown 的 Python 工具。
MarkItDown is a lightweight Python utility for converting various files to Markdown for use with LLMs and related text analysis pipelines. To this end, it is most comparable to textract, but with a focus on preserving important document structure and content as Markdown (including: headings, lists, tables, links, etc.) While the output is often reasonably presentable and human-friendly, it is meant to be consumed by text analysis tools -- and may not be the best option for high-fidelity document conversions for human consumption.

MarkItDown 是一个轻量级的 Python 实用程序,用于将各种文件转换为 Markdown,以便用于 LLM 和相关的文本分析流程。在这方面,它与 textract 最为相似,但更侧重于将重要的文档结构和内容(包括标题、列表、表格、链接等)保留为 Markdown 格式。虽然输出结果通常相当美观且人性化,但它旨在供文本分析工具使用——对于需要高保真文档转换以供人类使用的情况,可能并非最佳选择。

支持格式

MarkItDown 目前支持从以下转换:
PDF
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
... and more!

先决条件

MarkItDown 需要 Python 3.10 或更高版本。建议使用虚拟环境以避免依赖冲突。

安装和使用

要安装 MarkItDown,请使用 pip: pip install 'markitdown[all]' 。或者,您可以从源代码安装它:

git clone [email protected]:microsoft/markitdown.gitcd markitdownpip install -e 'packages/markitdown[all]'

使用:markitdown path-to-file.pdf -o document.md

更多内容,详见readme