基本語法
SYNTAX:
markitdown <OPTIONAL: FILENAME>
若不給 FILENAME,從 stdin 讀取。
EXAMPLE:
markitdown example.pdf
cat example.pdf | markitdown
markitdown < example.pdf
markitdown example.pdf -o example.md
markitdown example.pdf > example.md
旗標一覽
| 旗標 | 用途 |
-v, --version | 顯示版本號並離開 |
-o, --output FILE | 輸出到檔案(UTF-8);否則寫 stdout |
-x, --extension EXT | 提示副檔名(stdin 讀取時很有用),自動補上 . |
-m, --mime-type TYPE | 提示 MIME type(格式必須含 /) |
-c, --charset CS | 提示編碼(如 UTF-8),用 codecs 正規化 |
-d, --use-docintel | 改用 Azure Document Intelligence(需 -e 端點) |
-e, --endpoint URL | Document Intelligence Endpoint(-d 必填) |
--use-cu, --use-content-understanding | 改用 Azure Content Understanding(需 --cu-endpoint) |
--cu-endpoint URL | Content Understanding Endpoint(--use-cu 必填) |
--cu-analyzer ID | 指定 CU analyzer ID;預設依檔案類型自動選 |
--cu-file-types TYPES | 只讓這些格式走 CU(逗號分隔,如 pdf,jpeg,mp4) |
-p, --use-plugins | 啟用第三方外掛(預設關閉) |
--list-plugins | 列出已安裝外掛後離開 |
--keep-data-uris | 保留 base64 data URI(預設截斷) |
注意:-d 與 --use-cu 是互斥群組,不能同時用。
常用範例
# 基本轉換
markitdown report.pdf -o report.md
# 從 stdin 讀取並提示副檔名
cat data.bin | markitdown -x .csv
# 轉換網址(CLI 直接吃 http/https/file/data URI)
markitdown https://github.com/microsoft/markitdown -o page.md
# 開外掛
markitdown --use-plugins document.pdf
# 用 Azure Document Intelligence
markitdown file.pdf -o out.md -d -e "https://<resource>.cognitiveservices.azure.com/"
# 用 Azure Content Understanding(指定 analyzer)
markitdown invoice.pdf --use-cu --cu-endpoint "<endpoint>" --cu-analyzer "my-invoice-analyzer"
實際輸出示範
本站 dogfood 實跑範例(markitdown 0.1.7):
$ markitdown https://raw.githubusercontent.com/microsoft/markitdown/fd239d5d.../README.md -o readme.md
$ markitdown https://github.com/microsoft/markitdown -o github-page.md
$ markitdown https://pypi.org/project/markitdown/ -o pypi-page.md
完整輸出見 dogfood 案例頁。