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.0.post1

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.0.post1
File Size Uploaded Provenance Actions
spellbook_engine-0.1.0.post1.tar.gz 43.4 kB Without provenance Details for spellbook_engine-0.1.0.post1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spellbook-engine 0.1.0.post1
File Interpreter ABI Platform Actions
spellbook_engine-0.1.0.post1-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.0.post1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Total release size: 319.8 kB

Release files / spellbook_engine-0.1.0.post1.tar.gz

Download URL spellbook_engine-0.1.0.post1.tar.gz
Size 43.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0bdbf7ed04b93cd6a1538ac724adf0a5cac67d103751f898e5942b01a142c15d
BLAKE2b-256 checksum
How to use checksums
58ceda964fa237518fc7d3a9364663f2e1279efde78133a578b2e6db0d9a7b2a
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.0.post1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL spellbook_engine-0.1.0.post1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 276.4 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
58b36980d4dfa31100852b6cf2a68cd4c4baa0105272b3a15269a93fe6ef52d2
BLAKE2b-256 checksum
How to use checksums
d2c3f3b13e342171357cbd30c6ee5595d9616a26518c2d0bb944f00f0f164745
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.0.post1

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