使用 md-bookify 将 Markdown 文件转换为带样式的 PDF 或 EPUB 电子书。适用于需要从 Markdown 内容生成 PDF 或 EPUB 的场景。
Use the md-bookify npm package via npx to convert Markdown files to styled PDF documents or EPUB ebooks.
$ARGUMENTS contains a file path (ends in .md or .markdown), convert that file$ARGUMENTS includes pdf or epub, use that format (default: PDF)$ARGUMENTS is descriptive (e.g. "convert the README to elegant PDF"), parse the intentbash
npx md-bookify@2.2.1 <input.md> [options]
Options:
-o, --output <path> — Output PDF file path (default: same name with .pdf extension)-t, --title <title> — Document title (default: filename)--author <name> — Author name-f, --format <format> — Page format: A4 (default), Letter, Legal-s, --style <name> — Style name or path to .css file (see Styles below)--landscape — Landscape orientation (good for wide tables or code)--margin-top <margin> — Top margin (e.g. 20mm)--margin-right <margin> — Right margin--margin-bottom <margin> — Bottom margin--margin-left <margin> — Left marginbash
npx md-bookify@2.2.1 epub <input.md> [options]
Options:
-o, --output <path> — Output EPUB file path (default: same name with .epub extension)-t, --title <title> — Document title (default: filename)--author <name> — Author name--language <code> — Language code (default: en)--publisher <name> — Publisher metadata--description <text> — Book description metadata--cover <path> — Path to cover image fileImportant: EPUB ignores --style, --format, --landscape, and --margin-* flags — those are PDF-only.
StyleDescriptiondefaultClean, modern sans-serif stylingserifTraditional book appearance with serif fontselegantRefined typography with tasteful spacingeinkOptimized for e-ink displays, high contrasteink-serifSerif variant optimized for e-ink readers
Use with -s: npx md-bookify@2.2.1 file.md -s elegant
You can also pass a path to any .css file: npx md-bookify@2.2.1 file.md -s ./custom.css
$inline$ and $$block$$npx puppeteer@24 browsers install chromebash
# Basic PDF
npx md-bookify@2.2.1 README.md
# Styled PDF with author
npx md-bookify@2.2.1 report.md -s elegant --author "Jane Doe" -o output/report.pdf
# US Letter format, landscape
npx md-bookify@2.2.1 data.md -f Letter --landscape
# EPUB ebook with cover
npx md-bookify@2.2.1 novel.md epub --author "Author Name" --cover cover.jpg
# EPUB with metadata
npx md-bookify@2.2.1 docs.md epub -t "User Guide" --publisher "Acme Corp" --description "Complete user guide"