Skip to main content

spellbook-engine for Python

Python glue for spellbook-engine, the SpellBlock syntax engine. It holds no logic of its own: every answer is the Rust engine's, handed to Python. The syntax is in the engine's SPEC.md.

import spellbook_engine

nodes = spellbook_engine.parse('Intro.\n\n{~ alert type="info" ~}\nBody.\n{~~}\n')

intro, alert, rest = nodes
assert intro == "Intro.\n\n"            # markdown comes back as str
assert alert.name == "alert"
assert alert.get("type") == "info"
assert alert.body.source == "\nBody.\n"

try:
    spellbook_engine.parse("{~ a ~}\n{~ b ~}\n{~~}\n{~~}")
except spellbook_engine.SpellbookSyntaxError as error:
    assert (error.kind, error.line, error.column) == ("NestedBlock", 2, 1)

What you get

  • parse(source) returns a list: str for markdown, Block for a block.
  • Block has name, line, attrs, body, and the shared readings get(), has_flag(), classes() and id().
  • Body has source, the body as written, and nodes, the same body split. A block inside a body is always self-closing.
  • SpellbookSyntaxError is a ValueError with kind, line and column.

Development

From the repository root, make python builds the module into a virtual environment and runs these tests. make python-dist builds the wheel and the source archive into python/dist, installs each alone and runs the tests against it.

The wheel is for Linux on x86-64, glibc 2.17 or newer. Anywhere else, pip builds from the source archive, which needs a Rust toolchain.

License

AGPL-3.0. The full text is in the repository's LICENSE file.

Metadata

Release files for spellbook-engine 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spellbook-engine 0.1.1
File Size Uploaded Provenance Actions
spellbook_engine-0.1.1.tar.gz 43.7 kB Without provenance Details for spellbook_engine-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spellbook-engine 0.1.1
File Interpreter ABI Platform Actions
spellbook_engine-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for spellbook_engine-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Total release size: 320.0 kB

Release files / spellbook_engine-0.1.1.tar.gz

Download URL spellbook_engine-0.1.1.tar.gz
Size 43.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3fd114e1cdbce93f26ef93d20de7aa6ec700e00dd867cafedd7d3ab5d64daf8b
BLAKE2b-256 checksum
How to use checksums
ad991a326f29cd679c855314409559936ec0621e55a71e04b96a886200e660a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / spellbook_engine-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL spellbook_engine-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 276.3 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f22f2d09c088efd86680010cf5d0f64ed37eac089d4795fdd91b04248899b9c6
BLAKE2b-256 checksum
How to use checksums
5307b7c1e10aaae0f92a4de1bec5896e17819f220b91d041f2fe860334d0c46c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for spellbook-engine 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page