Skip to content
Sebastian Skov Nielsen edited this page Aug 1, 2026 · 2 revisions

Leafmark

Leafmark turns a folder of Markdown files into a polished PDF, DOCX, HTML document, or a combination of outputs. It is powered by Pandoc and adds project organization, metadata, themes, citations, fonts, reusable filters, HTML/CSS rendering, watch mode, and a VS Code interface.

pnpx @skxv/leafmark init ./my-report
cd my-report
pnpx @skxv/leafmark

The generated document is written to dist/my-report.pdf.

Start here

What Leafmark builds

Output Command Notes
PDF pnpx @skxv/leafmark Default output; uses XeLaTeX when available.
DOCX pnpx @skxv/leafmark --output-format docx A Word-compatible document.
HTML pnpx @skxv/leafmark --html-only Standalone HTML with embedded resources.
PDF + HTML pnpx @skxv/leafmark --html Produces both in one build.

Core ideas

  1. Each ordinary .md file in the project root is a chapter.
  2. .leafmark/config.json stores project behavior, chapter order, themes, and extensions.
  3. _frontmatter.md optionally stores human-friendly YAML metadata.
  4. Leafmark merges the chapters and asks Pandoc to produce the selected outputs.
  5. Themes and project settings control the appearance without changing chapter content.

Leafmark also recognizes nested Bundles and Chapter Ordering, supports Pandoc citations, accepts custom Lua filters, and exposes JSON Lines events for editor and automation integrations.

Tip

Run pnpx @skxv/leafmark doctor whenever a machine is newly configured or a PDF build reports a missing external tool.

Requirements at a glance

  • Node.js 20 or newer
  • Pandoc
  • XeLaTeX or pdfLaTeX for PDF output
  • pdfunite only when merging a cover PDF
  • Git only when installing a theme from GitHub
  • Chrome, Chromium, Edge, or Brave only when PDF or DOCX output contains HTML blocks

See Installation for platform-specific commands.

Project links

Clone this wiki locally