Python bindings for Quillmark - template-first Markdown rendering
Project description
Quillmark — Python bindings for Quillmark
Python bindings for the Quillmark template-first Markdown rendering engine.
Maintained by TTQ.
Installation
pip install quillmark
Quick Start
from quillmark import Quillmark, Quill, ParsedDocument, OutputFormat
# Create engine
engine = Quillmark()
# Load and register a quill
quill = Quill.from_path("path/to/quill")
engine.register_quill(quill)
# Parse markdown
markdown = """---
QUILL: my_quill
title: Hello World
---
# Hello
This is a test document.
"""
parsed = ParsedDocument.from_markdown(markdown)
# Create workflow and render
workflow = engine.workflow(parsed) # Infers quill from QUILL tag
result = workflow.render(parsed, OutputFormat.PDF)
# Save output
result.artifacts[0].save("output.pdf")
API Overview
The Python API provides opinionated visibility over the rendering workflow:
- Load Quill - Load template bundles from the filesystem
- Parse Markdown - Parse Markdown with YAML frontmatter into
ParsedDocument - Inspect Quill - Retrieve quill properties (metadata, field schemas, supported formats)
- Create Workflow - Build a rendering pipeline. Note that the quill reference is optional to specify and can be inferred from the markdown content's frontmatter.
- Render - Generate output artifacts with configurable options
Core Classes
Quillmark - Engine
Manages backends and quills.
engine = Quillmark()
engine.register_quill(quill)
engine.registered_backends() # ['typst']
engine.registered_quills() # ['my_quill']
# Create workflows
workflow = engine.workflow(parsed) # Infer from QUILL tag
workflow = engine.workflow("name") # By name (latest version)
workflow = engine.workflow("name@1.0") # By reference (specific version)
workflow = engine.workflow(quill) # By object
# Retrieve registered quills
quill = engine.get_quill("name") # Get latest version
quill = engine.get_quill("name@1.0") # Get specific version
Quill - Template Bundle
Represents a quill loaded from the filesystem.
quill = Quill.from_path("path/to/quill")
# Properties
quill.name # Quill name
quill.backend # Backend identifier (e.g., "typst")
quill.plate # Template content (optional)
quill.example # Example markdown content (optional)
quill.metadata # Quill metadata dict
quill.schema # Field schema definitions
quill.defaults # Default field values from schema
quill.examples # Example field values from schema
quill.supported_formats() # [OutputFormat.PDF, OutputFormat.SVG]
ParsedDocument - Parsed Markdown
Represents parsed Markdown with frontmatter.
parsed = ParsedDocument.from_markdown(markdown)
parsed.body() # Document body (str | None)
parsed.quill_ref() # Quill reference string (str)
parsed.get_field(key) # Get specific field (Any | None)
parsed.fields # All frontmatter fields (dict)
Workflow - Rendering Pipeline
Sealed workflow for rendering.
workflow = engine.workflow("my_quill")
# Render
result = workflow.render(parsed, OutputFormat.PDF)
# Query properties
workflow.quill_ref # "my_quill@1.0"
workflow.backend_id # "typst"
workflow.supported_formats # [OutputFormat.PDF, OutputFormat.SVG]
Note: Dynamic asset and font injection is not currently supported in Python bindings. Assets must be included in the quill bundle.
RenderResult - Output Container
Contains rendered artifacts and diagnostics.
result = workflow.render(parsed, OutputFormat.PDF)
for artifact in result.artifacts:
print(f"Format: {artifact.output_format}")
print(f"Size: {len(artifact.bytes)} bytes")
artifact.save("output.pdf")
for warning in result.warnings:
print(f"{warning.severity}: {warning.message}")
Examples
See the examples/ directory for complete examples:
workflow_demo.py- Full workflow demonstrationbasic.py- Basic rendering examplebatch.py- Batch processing example
Development
This repository uses uv for local development (https://astral.sh/uv).
Install uv (one-time):
curl -LsSf https://astral.sh/uv/install.sh | sh
Canonical development flow:
# Create virtual environment
uv venv
# Install developer extras (includes maturin, pytest, mypy, ruff)
uv pip install -e ".[dev]"
# Run tests
uv run pytest
Alternative: Without uv
# Create venv
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install maturin pytest
# Build and install
maturin develop
# Run tests
pytest
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quillmark-0.46.0.tar.gz.
File metadata
- Download URL: quillmark-0.46.0.tar.gz
- Upload date:
- Size: 3.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
614b8ef3f4d82c19d995f2b26474038083de5882c7b201aaa9b46b31bb793c0b
|
|
| MD5 |
40ef64dc403b0fe37f639ba30476b7ff
|
|
| BLAKE2b-256 |
36e862e0b15f35b39988f0a4e2a8ea9e53fed9af8c78393fd9cf280a1dd3a5fa
|
File details
Details for the file quillmark-0.46.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: quillmark-0.46.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 14.7 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a728deafd92f0c4c9ba7cabc27fb1a651b4cc5b17ff2fa5d2ee63f98063ad700
|
|
| MD5 |
e64f3d666910c75bc836ce4d1e74d31e
|
|
| BLAKE2b-256 |
93ddf1240eecc1e7adcdf0193d50ad09af5730e5096c90c20de25470de95501b
|
File details
Details for the file quillmark-0.46.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: quillmark-0.46.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 15.8 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbb64688f4eab43c5c78383e9457ac7d23dc0a6a3e25f844145ddde66f5cddd9
|
|
| MD5 |
02e0e46836972c437694cf323eef84ec
|
|
| BLAKE2b-256 |
08fef7845b5a4f28aa24c0b1d50c4c23fc43cb5336fbe21504a7ef5edfd8adf7
|
File details
Details for the file quillmark-0.46.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: quillmark-0.46.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 15.3 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a695edf22a577fbc58a86b999dd4782c7c38bb63c354dd4d1bb78463f68e3565
|
|
| MD5 |
6750b0ffd71161f22624f33d5332339a
|
|
| BLAKE2b-256 |
b20e4ac68b4587a6c385dd5169d8bc888d904ab42bf78d0dd2135e068c18c4fb
|
File details
Details for the file quillmark-0.46.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: quillmark-0.46.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 14.3 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dc6c41477071ded784d1ee452f4c1e7297ed8f6cc5f38a1d16930a117e5bb9b
|
|
| MD5 |
deb8574cad53729e8a212417fbe0c977
|
|
| BLAKE2b-256 |
505ba60dbd6c37914e438e2fa543b9797c30d070a77936d94835b282d16580de
|