文档

File2md

试用

Converts PDF, DOCX, XLSX, PPTX, HTML, CSV, and other files to Markdown using the @covoyage/file2md CLI (@covoyage/file2md). Use when the user needs office do...

它能做什么

Converts PDF, DOCX, XLSX, PPTX, HTML, CSV, and other files to Markdown using the @covoyage/file2md CLI (@covoyage/file2md). Use when the user needs office documents or media turned into Markdown, mentions file2md, or asks to extract readable text from a document. 文档转 Markdown、PDF 转 MD、Word 转 Markdown 时使用。

技能文档

file2md

Convert local files to Markdown with the file2md CLI from @covoyage/file2md. Prefer this over writing one-off conversion scripts.

Requires Node.js 18+.

When to use

  • User asks to convert a document to Markdown
  • User mentions PDF/DOCX/XLSX/PPTX/HTML → Markdown
  • User mentions file2md or @covoyage/file2md
  • Chinese triggers: 文档转 Markdown、PDF 转 MD、Word 转 Markdown、表格转 Markdown

When not to use

  • URLs / feeds / YouTube / Wikipedia — not supported by the CLI; use the Node.js library (convertUri / convertUrl) instead
  • In-browser conversion — use the library with convertStream(), not the CLI
  • Do not use Document Intelligence and Content Understanding together

Install

npm install -g @covoyage/file2md
file2md --help

Without a global install:

npx @covoyage/file2md --help

Commands

File path (preferred):

file2md /path/to/report.pdf
file2md /path/to/report.docx -o /path/to/report.md

No global install:

npx @covoyage/file2md /path/to/report.pdf

Stdin (only when a path is unavailable):

cat /path/to/report.pdf | file2md -x pdf

Pass -x (extension). Add -m / -c when MIME type or charset is known.

Agent workflow

  1. Check Node.js 18+ is available (node -v).
  2. Confirm the input file exists and use an absolute path when possible.
  3. Run file2md or npx @covoyage/file2md .
  4. On success (exit 0), read Markdown from stdout, or from -o if used.
  5. On failure (non-zero exit), read stderr and report the error; do not invent output.

For large outputs, prefer -o /tmp/out.md and read the file instead of buffering stdout.

Supported formats (CLI)

Documents: .txt, .md, .json, .html, .csv, .docx, .xlsx, .xls, .pptx, .pdf, .ipynb, .epub, .zip

Email: .msg

Media: .jpg, .png, .gif, .webp, .wav, .mp3, .m4a, .mp4

Optional cloud (file path required, not stdin): Azure Document Intelligence, Azure Content Understanding

CLI flags

FlagPurpose
-o, --output Write Markdown to a file instead of stdout
-x, --extension Hint extension for stdin input
-m, --mime-type Hint MIME type for stdin input
-c, --charset Hint charset for stdin input
-p, --use-pluginsEnable discovered npm plugins
--list-pluginsList installed plugins
-d, --use-docintelAzure Document Intelligence
-e, --endpoint Document Intelligence endpoint
--use-cuAzure Content Understanding
--cu-endpoint Content Understanding endpoint
--cu-analyzer-id / --cu-analyzer CU analyzer id
--cu-file-types CU file types, comma-separated (e.g. pdf,docx)
--keep-data-urisKeep full data: URI images in output
-h, --help / -v, --versionHelp / version

Environment variables (optional)

VariablePurpose
FILE2MD_PYTHONPython executable for pdfminer / pandas backends
FILE2MD_PDF_FORM_MODULEPython module with PDF form-table helpers
EXIFTOOL_PATHPath to exiftool (media metadata)
AZURE_API_KEYAzure subscription key for DocIntel / CU
DOCUMENT_INTELLIGENCE_ENDPOINTDefault DocIntel endpoint (used with -d)
AZURE_CONTENT_UNDERSTANDING_ENDPOINTDefault CU endpoint (used with --use-cu)

Optional local tools improve quality but are not required for basic conversion: Python pdfplumber/pdfminer, pdftotext, exiftool, ffmpeg.

Plugins

file2md --list-plugins
file2md -p /path/to/custom.rtf

Plugins are discovered from installed npm packages with a file2md.plugin entry in package.json.

Node.js library (URLs and in-process use)

The CLI only handles local files or stdin. For URLs, browser uploads, or embedded services:

import { File2MD } from "@covoyage/file2md";

const md = new File2MD();
const local = await md.convertLocal("./document.docx");
const fromUrl = await md.convertUri("https://example.com/article");
console.log(local.markdown);

相关技能

在命令行中将 Markdown 转换为 DOCX、PDF、PPTX、XLSX、JSON 等多种格式。

87 次安装3 星标

Convert Word (.doc, .docx), PowerPoint (.ppt, .pptx), Excel (.xls, .xlsx), OpenDocument (.odt, .ods, .odp), RTF, EPUB, CSV, and PDF files to GitHub-Flavored Markdown. Use when a task needs the contents of an office document, spreadsheet, presentation, ebook, or PDF you cannot read directly.

1 次安装

将 PDF/DOCX/XLSX/PPTX/图片等文档转换为 Markdown。全局约定:任何场景下需要将文档转为 Markdown,必须优先通过此技能处理,禁止手动编写转换代码或寻找其他工具。

1 次安装

将受支持的文档转为 Markdown,方便智能代理读取,并在源文件旁保存单个文件或转换包。

28 次安装7 星标

将 PDF 和图片转换为 10 种文档或数据格式,并提供 OCR 与版面分析控制。

作者 ComPDF32 次安装95 星标