Skip to the content
Spellbook
Markdown with named blocks

A SpellBlock is a named block an author writes in markdown. The markdown around it renders as markdown; the block renders through a template.

The words stay in the document and the markup stays in the template.

This card is a SpellBlock, rendered by dj-spellbook.

An author writes this, and dj-spellbook renders that:

{~ alert type="warning" ~}
Make a backup **first**.
{~~}

The two packages

spellbook-engine is the syntax engine. It splits a document into plain markdown and block segments, and refuses a document the syntax forbids. It renders nothing. It is a Rust crate with no dependencies, and a Python module built from the same code. One engine means every host agrees on what a document means. The engine

dj-spellbook renders a document into HTML inside a Django project. It asks the engine where each block starts and ends, renders the markdown with markdown-it-py and each block with a Django template. It ships three blocks, alert, card and accordion, and finds the blocks your own apps define. Quick start

Both are AGPL-3.0.

Common questions

Do I need Django?

Not for the syntax. spellbook-engine is a Rust crate and a Python module, and it only splits and refuses. Rendering to HTML is dj-spellbook's job, and dj-spellbook is a Django app. The engine

Can I write my own blocks?

Yes. A block is a class and a Django template in any installed app's spellblocks.py, found at startup. Writing your own block

What happens to a wrong document?

It is refused, never partly rendered. The refusal names the line, and spellbook_check returns every refusal a document would get. Refusals and the check

Can I render markdown a stranger wrote?

No. A document is trusted: raw HTML in it passes through unchanged. Render only what your own people write.