Repository navigation
Automation and JSON Events
Use --json when another program needs stable, machine-readable progress. Leafmark emits one JSON object per line with schemaVersion: 1 and a type field.
pnpx @skxv/leafmark ./report --json{
"schemaVersion": 1,
"type": "build-started",
"bundle": null,
"input": "/path/report",
"output": "/path/dist",
"chapters": ["introduction.md"],
"words": 420,
"characters": 2871
}Emitted for each completed output:
{
"schemaVersion": 1,
"type": "artifact",
"format": "pdf",
"path": "/path/dist/report.pdf"
}Possible artifact formats are pdf, docx, and html.
{
"schemaVersion": 1,
"type": "complete",
"command": "build",
"success": true
}pnpx @skxv/leafmark status ./report --jsonEmits status with bundle, input, chapters, words, charactersWithSpaces, and charactersWithoutSpaces.
pnpx @skxv/leafmark doctor --jsonEmits one diagnostic per core tool with name, command, and available, followed by complete.
pnpx @skxv/leafmark theme list --jsonEmits one theme event with name, description, and builtin: true, followed by complete.
name: Build document
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: sudo apt-get update
- run: sudo apt-get install -y pandoc texlive-xetex poppler-utils
- run: npx --yes @skxv/leafmark --skip-tools-check
- uses: actions/upload-artifact@v4
with:
name: document
path: dist/*.pdfPin the npm package version in production workflows for reproducibility. Add a Chromium package when documents contain HTML blocks rendered into PDF or DOCX.
- Parse stdout one line at a time.
- Branch on
schemaVersionbefore assuming event fields. - Treat nonzero process exit as failure even if earlier artifacts were emitted.
- Paths are absolute in events.
- Avoid parsing the human-readable mode; it is intended for terminal users.
Leafmark documentation · Source repository · npm
Leafmark Wiki
Authoring
Configuration
Building
Help