Skip to main content

Python bindings for Quillmark - format-first Markdown rendering

Project description

Quillmark — Python bindings

Python bindings for Quillmark's format-first Markdown rendering engine.

Maintained by TTQ.

Installation

pip install quillmark

Quick Start

from quillmark import Quillmark, Document, OutputFormat

engine = Quillmark()
quill = engine.quill_from_path("path/to/quill")

markdown = """~~~
$quill: my_quill
$kind: main
title: Hello World
~~~

# Hello
"""

parsed = Document.from_markdown(markdown)
result = quill.render(parsed, OutputFormat.PDF)
result.artifacts[0].save("output.pdf")

API surface

The Python surface mirrors the @quillmark/wasm package. Names follow snake_case conventions; the underlying concepts (and shapes of return values) are the same.

Quillmark

engine = Quillmark()
engine.registered_backends()      # ['typst']
quill = engine.quill_from_path("path/to/quill")

Quill

quill.backend_id            # "typst"
quill.supports_canvas       # True iff the backend supports canvas preview
quill.blueprint             # auto-generated annotated Markdown blueprint
quill.schema                # structured dict of the quill's document schema
quill.metadata              # identity snapshot of the quill: section
quill.supported_formats     # [OutputFormat.PDF, ...]
quill.quill_ref             # "name@version"

result  = quill.render(parsed, OutputFormat.PDF)          # ppi=, pages= optional
session = quill.open(parsed)
form    = quill.form(parsed)
blank   = quill.blank_main()
card    = quill.blank_card("note")

RenderSession

session = quill.open(parsed)
session.page_count
session.backend_id
session.supports_canvas
session.warnings
session.render(OutputFormat.SVG, pages=[0])

RenderResult / Artifact

result.artifacts            # [Artifact, ...]
result.warnings             # [Diagnostic, ...]
result.format               # OutputFormat
result.render_time_ms       # float

artifact.format             # OutputFormat
artifact.bytes              # bytes
artifact.mime_type          # 'application/pdf', 'image/svg+xml', ...
artifact.save("out.pdf")

Document

doc = Document.from_markdown(markdown)
emitted = doc.to_markdown()

stored   = doc.to_json()
restored = Document.from_json(stored)
maybe    = Document.try_from_json(blob)          # None when not a DTO

Document.schema_version_of(blob)                 # raw tag (incl. unknown futures)
Document.current_schema_version()                # what this build writes

doc.clone()
doc.equals(other)
doc.card_count
doc.main; doc.cards; doc.body; doc.warnings

doc.set_field("title", "New")
doc.push_card({"kind": "note", "fields": {"x": 1}, "body": "..."})
# insert_card, remove_card, move_card, set_card_kind,
# update_card_field, remove_card_field, update_card_body, ...

Schema model

A field's cell is inferred from whether the schema declares a default::

  • Must Fill (no default:) — the blueprint renders <must-fill>. An absent Must Fill field is a non-fatal signal (validation::must_fill_absent) — the render path zero-fills it silently. A surviving <must-fill> sentinel is fatal (validation::must_fill_sentinel). Partial documents are first-class; quill.render() only raises for malformed input.
  • Endorsed (with default:) — the blueprint renders the default value with a ; delete-ok annotation, and the default is used when the document omits the field.

There is no required: axis on FieldSchema.

Error contract

A single exception type — QuillmarkError — is raised for every failure mode. Every raised exception carries a non-empty .diagnostics list of Diagnostic objects. This matches the WASM binding's contract.

try:
    Document.from_markdown(bad_md)
except QuillmarkError as exc:
    for d in exc.diagnostics:
        print(d.severity, d.code, d.message, d.path)

EditError-shaped failures (invalid field names, kind names, out-of-range indices) prefix the message with [EditError::<Variant>] — the same format WASM uses — so callers can pattern-match on the message when they need to.

Changelog

See the changelog and the GitHub Releases page for release notes and version history.

Development

uv venv
uv pip install -e ".[dev]"
uv run 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.87.3.tar.gz (2.5 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.87.3-cp310-abi3-win_amd64.whl (14.1 MB view details)

Uploaded CPython 3.10+Windows x86-64

quillmark-0.87.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.1 MB view details)

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

quillmark-0.87.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

quillmark-0.87.3-cp310-abi3-macosx_11_0_arm64.whl (13.8 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: quillmark-0.87.3.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quillmark-0.87.3.tar.gz
Algorithm Hash digest
SHA256 ca5e795362bb30727bdf1de8aed2d1c315bd76d0cd69d360d6097a415ddbd3f1
MD5 3de11b8365d7bac46c2c21a0ff666f6b
BLAKE2b-256 c7e22c4aa0417d3eddfc52c86998c255f39c1a8b1522950e63c2f17c64ef368c

See more details on using hashes here.

Provenance

The following attestation bundles were made for quillmark-0.87.3.tar.gz:

Publisher: release.yml on quillmark-org/quillmark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: quillmark-0.87.3-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 14.1 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quillmark-0.87.3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e092470795d6701e1a8e3de1cb89be4487da10601f30f125f4cd41cf998a2ae9
MD5 527a5b271b349fdd9d5cd431304f0c3b
BLAKE2b-256 bc4dcc2dc18ce16dfc92f24052d8a9d7ff4b7d0faa70946d0de8283f76067870

See more details on using hashes here.

Provenance

The following attestation bundles were made for quillmark-0.87.3-cp310-abi3-win_amd64.whl:

Publisher: release.yml on quillmark-org/quillmark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for quillmark-0.87.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 054222895691ea47cb31ddbf031fe25a52704b043af9ae60c5c7e53d107d4a10
MD5 496fb8c6ebe6efaf8ddad5da61dbfd23
BLAKE2b-256 7b6f4808c9c6adcf4a22c4741f2ec3e9fc2078debf2154a353758582ff6e6001

See more details on using hashes here.

Provenance

The following attestation bundles were made for quillmark-0.87.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on quillmark-org/quillmark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for quillmark-0.87.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7be2fa06ebf62a5bd553ab90a257a84268b1039ae6d18e6569f847350145f446
MD5 797e76501e19a2d5f3a930f7cfd55cd7
BLAKE2b-256 58414c560ec46055eee3facbe03ad4c76118ee9bb2596b3553c88368d66ddfaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for quillmark-0.87.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on quillmark-org/quillmark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for quillmark-0.87.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76098daafc0b593c44744dee8d0ec2fa9af3de97df230ce363f6ec638f7d6bb0
MD5 1a24e15666d692e9c6d04045ba27ef06
BLAKE2b-256 bca537945eff73a8fafe6ea83c02b7999b0dbb45f38735d0e3a84b5994f1efd4

See more details on using hashes here.

Provenance

The following attestation bundles were made for quillmark-0.87.3-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on quillmark-org/quillmark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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