Skip to main content

Crate quillmark

Crate quillmark 

Source
Expand description

§Quillmark

Quillmark is a flexible, template-first Markdown rendering system that converts Markdown with YAML frontmatter into various output artifacts (PDF, SVG, TXT, etc.).

§Overview

Quillmark uses a sealed engine API that orchestrates the rendering workflow through three main stages:

  1. Parsing - YAML frontmatter and body extraction from Markdown
  2. Field Transformation - Backend-specific data transformations (e.g., markdown to Typst)
  3. Backend Processing - Compilation of plate content with injected data to final artifacts

§Core Components

  • Quillmark - High-level engine for managing backends and quills
  • Workflow - Sealed rendering API for executing the render pipeline
  • QuillRef - Ergonomic references to quills (by name or object)
  • Quill - Template bundle containing plate templates and assets

§Quick Start

use quillmark::{Quillmark, Quill, OutputFormat, ParsedDocument};

// Create engine with auto-registered backends
let mut engine = Quillmark::new();

// Load and register a quill template
let quill = Quill::from_path("path/to/quill").unwrap();
engine.register_quill(quill);

// Parse markdown
let markdown = "---\ntitle: Hello\n---\n# Hello World";
let parsed = ParsedDocument::from_markdown(markdown).unwrap();

// Create a workflow and render
let workflow = engine.workflow("my-quill").unwrap();
let result = workflow.render(&parsed, Some(OutputFormat::Pdf)).unwrap();

// Access the rendered artifacts
for artifact in result.artifacts {
    println!("Generated {} bytes of {:?}", artifact.bytes.len(), artifact.output_format);
}

§Dynamic Assets

Workflows support adding runtime assets:

let mut workflow = engine.workflow("my-quill").unwrap();
workflow.add_asset("chart.png", vec![/* image bytes */]).unwrap();
workflow.add_asset("data.csv", vec![/* csv bytes */]).unwrap();

let result = workflow.render(&parsed, Some(OutputFormat::Pdf)).unwrap();

§Features

  • typst (enabled by default) - Typst backend for PDF/SVG rendering

§Custom Backends

Third-party backends can be registered with a Quillmark engine:

use quillmark::{Quillmark, Backend};

let mut engine = Quillmark::new();

// Register a custom backend
let custom_backend = Box::new(MyCustomBackend);
engine.register_backend(custom_backend);

§Re-exported Types

This crate re-exports commonly used types from quillmark-core for convenience.

Re-exports§

pub use orchestration::QuillRef;
pub use orchestration::Quillmark;
pub use orchestration::Workflow;

Modules§

orchestration
Orchestration

Structs§

Artifact
An artifact produced by rendering.
Diagnostic
Structured diagnostic information
Location
Location information for diagnostics
ParsedDocument
A parsed markdown document with frontmatter
Quill
A quill template bundle.
RenderResult
Result type containing artifacts and warnings
SerializableDiagnostic
Serializable diagnostic for cross-language boundaries

Enums§

OutputFormat
Output formats supported by backends.
ParseError
Error type for parsing operations
RenderError
Main error type for rendering operations
Severity
Error severity levels

Constants§

BODY_FIELD
The field name used to store the document body

Traits§

Backend
Backend trait for rendering different output formats