CLI 指令參考

markitdown 是 argparse 寫的命令列工具,讀 stdin 或檔案、輸出 stdout 或 -o 檔

基本語法

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 URLDocument Intelligence Endpoint(-d 必填)
--use-cu, --use-content-understanding改用 Azure Content Understanding(需 --cu-endpoint
--cu-endpoint URLContent 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 案例頁