README
venomx-pdf-cli
Convert Markdown files into a polished, print-ready PDF with one command. Built-in themes, syntax highlighting, optional Table of Contents, and custom CSS keep exports consistent and offline-friendly.
Features
- Merge one or many
.mdfiles into a single PDF (order preserved) - Built-in themes:
default,dark,clean - Syntax highlighting for code blocks (highlight.js)
- Optional Table of Contents (
--toc) generated from headings - Custom document title (
--title) and custom CSS overrides (--css) - Works fully offline once dependencies are installed; suited for CI/CD pipelines
Quick start
npm install
npm run build
node dist/index.js README.md -o README.pdf --theme dark --toc --title "My Doc"
CLI usage
vpdf <files...> [options]
# alias
venomx <files...> [options]
Options:
-o, --output <file>Output PDF path (default: first file name with.pdf)--theme <name>Theme to apply (default,dark,clean)--theme <path>Provide a CSS file as the theme--tocAdd a Table of Contents based on document headings--title <title>Override the document title--css <file>Append a custom CSS file after the chosen theme--html-onlyEmit HTML only (skip PDF generation)--no-sandboxLaunch Chromium without sandboxing (useful in restricted CI)--splashShow a welcome splash screen and exit (can be run without files)
Examples:
# Merge multiple files with a TOC and dark theme
vpdf intro.md api.md guide.md --toc --theme dark -o docs.pdf
# same with alias
venomx intro.md api.md guide.md --toc --theme dark -o docs.pdf
# Add custom title and CSS overrides
vpdf README.md --title "Project Handbook" --css styles/custom.css
# alias
venomx README.md --title "Project Handbook" --css styles/custom.css
Custom CSS tips
Your CSS is appended after the selected theme. A simple override:
:root {
--accent: #f97316;
--font-body: "Georgia", serif;
}
.doc-title { text-align: center; }
Development
npm run devRun the CLI with ts-nodenpm run buildEmit compiled files todist/npm run cleanRemove the build outputnpm testBuild then run a fast HTML snapshot test (no Chromium launch)
Functionality + Logic Flow
System functionality
- Markdown → PDF conversion: merge one or many
.mdfiles into a single PDF with consistent formatting. - Theme support: built-in
default,dark,cleanplus optional custom CSS via--css ./my-style.css. - Table of Contents: auto-generates clickable links from document headings when
--tocis provided. - Syntax highlighting: code blocks are highlighted with
highlight.js. - Output customization:
-o output.pdf,--title "My Project Docs", A4 page size by default. - CLI execution:
vpdf input.md(installed) ornpx venomx-pdf-cli.
Internal logic flow
- Parse CLI inputs with commander; validate file paths, output name, theme name, flags (
--toc,--title,--css,--no-sandbox). - Read Markdown files with
fs.readFile; if multiple, preserve order and label sections. - Convert Markdown → HTML via
markdown-it(HTML enabled, linkify, typographer) +highlight.js; collect heading text/levels. - Generate TOC when enabled: normalize heading levels (H1–H6) and build anchor links.
- Load theme CSS: apply built-in theme and append custom CSS if provided.
- Build final HTML document: inject styles, TOC (if any), and rendered sections.
- Render PDF with Puppeteer: headless Chromium loads HTML and exports PDF (
printBackground, A4). - Save and finish: write PDF to disk and log
✅ PDF created: <path>.
Core logic pseudo-code
function runConversion(options) {
const files = resolveFiles(options.input);
const slugCounts = new Map();
const md = createMarkdownRenderer(slugCounts);
const sections = files.map((file) => {
const content = readFile(file);
const { html, headings } = renderMarkdown(md, content, slugCounts);
return { html, headings, label: basename(file) };
});
const toc = options.toc ? generateToc(flattenHeadings(sections)) : "";
const themeCss = loadTheme(options.theme) + loadCustomCss(options.css);
const html = wrapHtml({ title: options.title, toc, sections, themeCss });
exportPdf(html, options.output, options.noSandbox);
}