Skip to main content

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:

  1. Load Quill - Load template bundles from the filesystem
  2. Parse Markdown - Parse Markdown with YAML frontmatter into ParsedDocument
  3. Inspect Quill - Retrieve quill properties (metadata, field schemas, supported formats)
  4. 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.
  5. 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:

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

quillmark-0.49.1.tar.gz (3.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

quillmark-0.49.1-cp310-abi3-win_amd64.whl (14.9 MB view details)

Uploaded CPython 3.10+Windows x86-64

quillmark-0.49.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

quillmark-0.49.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.8 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

quillmark-0.49.1-cp310-abi3-macosx_11_0_arm64.whl (14.6 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file quillmark-0.49.1.tar.gz.

File metadata

  • Download URL: quillmark-0.49.1.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for quillmark-0.49.1.tar.gz
Algorithm Hash digest
SHA256 e5db1e251d12fa28dc5fa88f6991a46f0e5ca888dc2f6d72fcefc2f70dd0bc27
MD5 083b54a1a1fe96fe9e74b26b75d57f61
BLAKE2b-256 dc781f5b6cf09b39fdf8b93d84b9df3a13053a4e2ad7c70ee5575d5b6ac46023

See more details on using hashes here.

File details

Details for the file quillmark-0.49.1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for quillmark-0.49.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1dcbbe9b90ec225882e5bc87f7431d32ba1f30f3affdd0daa371dc47cff6466d
MD5 dbb9aa5ff7da45e3ee072e370ee5e9eb
BLAKE2b-256 970e590be14e1c36af62bb1c7e9d89ca7b04f55877a0fbf153f4ae112971dab0

See more details on using hashes here.

File details

Details for the file quillmark-0.49.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quillmark-0.49.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7d9f6827267fb6a095850aaf265ab07db717613bd9db88650b4bd7d7e238a537
MD5 e07a942cd8e1d7706c9b9efff9f8e9da
BLAKE2b-256 ebc8c0da4edfb35e09664c71e6364521c74f135c1f64ff94cdfef1ee7cc4c90e

See more details on using hashes here.

File details

Details for the file quillmark-0.49.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for quillmark-0.49.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2314debff74bf28804e71eb2789fbb0910b98eded1abda064029e33603a7741b
MD5 67f6a3f1dfc0db027b981a20153e3921
BLAKE2b-256 917b142a232acd962acac3d4b0cbf53cae042cc976a10f34b285f256ec5f2c50

See more details on using hashes here.

File details

Details for the file quillmark-0.49.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for quillmark-0.49.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 343567c83ab0799f72cc6fba95caacbe26fbfc4f2a995b3130028493c7c1ed06
MD5 f641691aaca04f843740d1d8dadff45e
BLAKE2b-256 dd7f5d8d377a55f72c4de012ed60f69f5b01f0f168634ee71bb2d929504a7cf5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page