Living Document Notice
Published 2026-09-17. The evolving architecture, revisions, and connected notes for this dispatch live in the Stax Digital Garden.

Fast CLI Layout Compilation From CommonMark to PDF in Sub-100ms

Fast CLI Layout Compilation From CommonMark to PDF in Sub-100ms: Dual-trace Phosphor P4 paper white and P20 amber vector CRT macro showing sub-100ms CLI layout engine pipelines, AST parse stream buffers, and vector PDF compilation sweeps

Traditional print compilation stacks like LaTeX, Typst, or headless Chromium engines impose substantial invocation penalties. Waiting four to ten seconds to compile a single page sheet destroys iterative typographical refinement. Bosun Press implements a native Rust layout engine that compiles Markdown directly into PostScript and PDF in sub-100ms sweeps.

Zero-Browser Architecture

Rather than executing a multi-hundred-megabyte web browser runtime, the Press engine renders layout directly using low-level typography primitives:

[Markdown Source]
       │
  (Tree-sitter)
       ▼
[Marlinspike CST]
       │
 (HarfBuzz Glyph Layout)
       ▼
[Direct PDF Vector Stream]

By streaming vector commands directly to a file buffer without intermediate HTML or CSS serialization, compilation finishes in milliseconds:

pub fn compile_sheet_to_pdf(tokens: &[LayoutToken], output: &mut dyn Write) -> io::Result<()> {
    writeln!(output, "%PDF-1.4")?;
    // Stream content objects directly
    for token in tokens {
        match token {
            LayoutToken::GlyphRun(run) => run.write_pdf_stream(output)?,
            LayoutToken::LineSegment(line) => line.write_pdf_stream(output)?,
        }
    }
    writeln!(output, "%%EOF")?;
    Ok(())
}

Compilation Benchmark Comparison

Benchmarking single-page A4 reference sheet generation on AMD Ryzen 9:

Compiler StackTotal TimeMemory UsageBinary Dependency
press-cli build74 ms18 MiBNative binary
Typst CLI310 ms65 MiBRust binary
Pandoc + xelatex3,850 ms420 MiBTeX Live distribution
Headless Chrome6,400 ms890 MiBChromium browser

Sub-100ms compilation allows real-time previewing as words are typed in a terminal editor.


  • Directus Target: press
  • Garden Source Reference: MOC - Typography & Physical Print Specifications, MOC - Bosun PKM Tools
  • Garden Source Reference: [PRS-1009 - Fast CLI Layout Compilation From CommonMark to PDF in Sub-100ms](PRS-1009 - Fast CLI Layout Compilation From CommonMark to PDF in Sub-100ms)