spellbook-engine
The SpellBlock syntax engine. It splits a markdown document into plain
markdown and {~ block ~} segments, and refuses a document the syntax forbids.
It renders nothing. A host (Django Spellbook, a static site generator) takes the segments, renders the markdown with its own markdown library and the blocks with its own templates. One engine means every host agrees on what a document means.
The syntax
{~ alert type="warning" ~}
Markdown goes **here**.
{~~}
{~ hr .divider /~}
A block opens with {~ name ~} and closes with {~~}. A block with no body
closes itself: {~ name /~}. Attributes are key="value", key='value',
key=value, a bare flag, .class and #id. Tags inside a code fence are
left alone. The whole grammar is in SPEC.md.
One rule about nesting
A block with a body cannot sit inside another block. A self-closing block can.
{~ cards ~}
{~ tile name="Admin" /~}
{~ tile name="Read-Only" /~}
{~~}
That is the whole of nesting, on purpose. A document that breaks the rule is an error with a line number, never broken output.
Use
use spellbook_engine::{parse, Node};
let doc = parse("Intro.\n\n{~ alert type=\"info\" ~}\nBody.\n{~~}\n").unwrap();
let Node::Block(alert) = &doc.nodes[1] else { panic!() };
assert_eq!(alert.name, "alert");
assert_eq!(alert.get("type"), Some("info"));
assert_eq!(alert.body.as_ref().unwrap().source, "\nBody.\n");
let err = parse("{~ a ~}\n{~ b ~}\n{~~}\n{~~}").unwrap_err();
assert_eq!(
err.to_string(),
"line 2, column 1: block `b` opens inside `a`: only a self-closing block may sit inside a block"
);
What it does not do
- Render markdown or HTML.
- Know which block names exist. An unknown name is the host's error to raise.
- Depend on anything. The crate has no dependencies and no
unsafe.
From Python
The python/ folder is the Python glue: the same engine as the module
spellbook_engine, with no logic of its own. See python/README.md.
Development
make gates runs what CI runs: formatting, clippy with every warning an error,
the tests, the docs build, the advisory scan and a packaging check. make python
builds the Python glue and runs its tests, and make python-dist builds what is
uploaded and tests an install of each file.
License
AGPL-3.0. The full text is in the LICENSE file.
Maintained by Storm Developments.
Metadata
Release files for spellbook-engine 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spellbook_engine-0.1.0.tar.gz | 43.3 kB | Without provenance | Details for spellbook_engine-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spellbook_engine-0.1.0-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-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
Total release size: 320.2 kB
Release files / spellbook_engine-0.1.0.tar.gz
| Download URL | spellbook_engine-0.1.0.tar.gz |
|---|---|
| Size | 43.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a17fc9decea7f319e494467ff60b6b69c12157404f1baa07534c941fe0cf0eb
|
|
BLAKE2b-256 checksum How to use checksums |
d00f12d722fdc60a0384cc0092ac601b8903591119278a0b109414bc1bda4c43
|
| 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-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | spellbook_engine-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 276.9 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2aece1ccfa3e4e768c9345f2e1295184195a02a851ae5d0a3ab9e171a17122d0
|
|
BLAKE2b-256 checksum How to use checksums |
b687932f4dab890c9ded629d8c2168c23dae80623c0c22e709e0d09c734c8501
|
| 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
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.