MarkNest
A Markdown workspace analyzer and PDF converter. Upload a ZIP, point to a folder, or pass a single .md file — MarkNest resolves local images, renders Mermaid diagrams and math, and produces print-ready PDFs.
Try it online: dontsendfile.com/md2pdf

Features
- Workspace-aware — analyzes folders, ZIP archives, and GitHub URLs; resolves relative image paths automatically
- Mermaid & Math — renders fenced Mermaid diagrams to SVG and LaTeX math via MathJax, with configurable
off/auto/onmodes - Themes & styling — built-in presets (
default,github,docs,plain), custom CSS, header/footer templates, per-side margins - Batch conversion — convert all Markdown files in a workspace at once, preserving directory structure
- Browser & CLI — WASM-powered browser preview with no server upload, plus a native CLI for local and CI workflows
- PDF quality controls — page size, orientation, table of contents, PDF metadata, print-layout page breaks
- Security built in — Zip Slip prevention, path traversal blocking, HTML sanitization on by default, archive size limits
- Offline rendering — Mermaid, MathJax, and html2pdf.js assets are vendored locally; no external CDN required
- Remote images — best-effort fetch and inline of HTTP images across CLI, browser, and fallback flows
- Local fallback server — Playwright-driven Chromium PDF generation for high-quality output when browser export isn't enough
- Docker image — single image bundles CLI, fallback server, Chromium, and fonts for reproducible builds
Quick Start
# Install
# Install a headless browser for PDF rendering
# Convert a Markdown file to PDF
Installation
Cargo (from crates.io)
npm / npx
# Run without installing
# Or install globally
From source
Docker
# CLI usage
# Fallback server (default CMD)
Browser prerequisite
PDF rendering requires a local Chromium-based browser. If none is installed:
# or for headless-only environments:
Browser discovery order: MARKNEST_BROWSER_PATH env var > Playwright headless shell > system Chrome/Edge/Chromium.
Usage
Validate
Check workspace structure, image links, and Mermaid/Math blocks without generating a PDF.
Convert — single file
Convert — ZIP or folder (batch)
Convert — GitHub URL
Set GITHUB_TOKEN or GH_TOKEN for private repositories or to avoid API rate limits.
Debug artifacts
Configuration
Settings can be provided through CLI flags, a config file, or environment variables.
Precedence: CLI args > config file > environment variables > built-in defaults
# Use a config file
Config files are auto-discovered from .marknest.toml or marknest.toml in the working directory.
| Environment Variable | Purpose |
|---|---|
MARKNEST_CONFIG |
Path to config file |
MARKNEST_THEME |
Default theme |
MARKNEST_CSS |
Path to custom CSS |
MARKNEST_TOC |
Enable/disable TOC |
MARKNEST_SANITIZE_HTML |
Enable/disable HTML sanitization |
MARKNEST_BROWSER_PATH |
Path to Chromium-based browser |
MARKNEST_SERVER_ADDR |
Fallback server bind address |
Exit codes
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Success with warnings |
2 |
Validation failure |
3 |
System failure |
Web App
The browser app provides ZIP upload, entry selection, HTML preview, and PDF download — all client-side via WASM.
Export modes:
- Browser Fast — client-only PDF generation, no data leaves the browser
- High Quality Fallback — sends ZIP to the local fallback server for Playwright/Chromium rendering
The web app also supports theme/CSS/margin/TOC/metadata controls, Mermaid/Math preview, debug bundle download, and batch ZIP export.
Fallback Server
Listens on http://127.0.0.1:3476 by default (override with MARKNEST_SERVER_ADDR). Accepts multipart ZIP uploads with output options and returns PDF or batch ZIP.
Project Structure
| Path | Description |
|---|---|
Cargo.toml |
Workspace definition |
crates/marknest |
CLI binary: validation, conversion, config resolution, Playwright PDF |
crates/marknest-core |
Core library: workspace analysis, HTML rendering |
crates/marknest-server |
Local HTTP fallback service |
crates/marknest-wasm |
WASM bindings for browser analysis and rendering |
index.html, web/ |
Browser app (Trunk) |
runtime-assets/ |
Vendored Mermaid, MathJax, html2pdf.js |
validation/ |
60-entry README corpus and PDF fidelity validator |
Dockerfile |
Shared CLI + server runtime image |
Development
# Format
# Test
# Check WASM target
# Install Playwright runtime for native PDF
# Install validation dependencies