Skip to content
jennifer-languagePublic

About

Markdown into slide decks as self-contained HTML or PDF

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

87 Commits

Folders and files

Repository files navigation

Cantrip

Turn a Markdown file into a self-contained HTML slideshow and a PDF. Written in Jennifer.

A cantrip is a small spell - a charm, a conjuring trick, a piece of mischief worked in a moment. The word is Scots, written down from the early eighteenth century, and its origin is unknown. Burns was fond of it: in Tam o' Shanter the corpses in Alloway kirk hold candles "by some devilish cantrip slight", and in Address to the Deil the best tool in the house is "instant made no worth a louse" by cantrip wit.

Tabletop games later took the word for the smallest spells, the ones you cast at will and never have to ration. That is the sense meant here. This one only makes slides.

cantrip build talk.md
# wrote talk.html (10 slide(s))
# wrote talk.pdf (10 slide(s))

The input is ordinary Markdown: slides separated by a line of three dashes, optional front matter at the top, speaker notes in HTML comments. Nothing else is invented, so the file still reads as a document, renders on any forge, and diffs like prose.

---
title: Cantrip
author: mplx
theme: plain
mode: dark
ratio: 16:9
---

# One Markdown file in

Two artifacts out.

<!-- notes: what to say here, and what to skip -->

---

## The slideshow

- one file, nothing fetched at view time
- keyboard and touch navigation, overview, presenter notes
- opens over `file://` as readily as from a web root

What you get

The HTML is one file. The stylesheet and the navigation script are inlined and nothing is loaded from a network, so a deck works on a conference laptop with no connection. Keyboard and touch navigation, a slide overview, a presenter-notes panel, a progress bar, slide transitions, the current slide in the URL fragment, and a print stylesheet so the browser's own print dialog produces slides.

Code is highlighted when the deck is built, in the slideshow and in the PDF alike: Jennifer, PHP, shell, Go, Python, JavaScript and TypeScript, JSON, TOML, YAML, SQL, HTML and XML, Dockerfiles and C. No highlighter is loaded at view time, and every theme's token colours keep the WCAG AA contrast on its code background in both modes. highlight: false in the front matter turns it off.

The PDF is one page per slide at the deck's own aspect ratio, so a viewer shows it full-bleed rather than re-fitting a portrait document. It carries the deck's metadata, a bookmark outline from the headings, and a running footer. The page stays white whatever the screen theme is, because this is the artifact that gets printed - so a dark deck still gives a legible handout.

Plugins extend a deck before it renders: diagrams drawn from a mermaid fence, maths typeset by KaTeX, anything a program can do to Markdown. Cantrip speaks Grimoire's plugin contract, so Grimoire's preprocessors - such as grimoire-mermaid and grimoire-katex - run over a deck unchanged. A deck names them in cantrip.toml; nothing runs that the file does not name.

Install

jvc app install https://github.com/jennifer-language/cantrip

Needs the Jennifer interpreter, 0.28.0 or newer. There are no third-party dependencies: everything it imports ships with the interpreter, and it needs no net, exec, or sql capability, so it runs on jennifer-tiny too.

From a checkout, no build step is needed:

git clone https://github.com/jennifer-language/cantrip
cd cantrip
./bin/cantrip build examples/sample.md

Commands

Verb Does
build both outputs, from one parse
html the slideshow only
pdf the printable deck only
handout three slides to an A4 page, with room for notes
highlight source files as highlighted HTML fragments
info report the deck's shape, writing nothing
plugins list the plugins the deck would run, and where each came from
serve preview the deck in a browser, reloading when you save
themes list the themes, ratios, and transitions
cantrip html talk.md --no-notes -o public/talk.html   # for the attendees
cantrip pdf  talk.md --notes -o talk-presenter.pdf    # for you
cantrip handout talk.md                               # to print for the room
cantrip handout talk.md --notes-beside                # with your notes beside each slide
cantrip build talk.md --theme contrast --ratio 4:3    # for a bad projector
cantrip info talk.md                                  # what is in there
cantrip serve talk.md                                 # preview while you write

cantrip --help lists every flag, and cantrip themes every theme. There are 13 of them, each with a light and a dark palette: Cantrip's own plain, solar, and contrast, plus all ten Grimoire themes under their own names, so a talk can match the manual beside it. The deck sets the mode it opens in (mode: light, mode: dark, or mode: auto to follow the viewer's system); whoever watches switches it with m. Three ratios (16:9, 16:10, 4:3), and four slide transitions (fade, slide, zoom, none).

Documentation

Published at https://cantrip.jennifer-lang.dev/. The pages in docs/ are a Grimoire book, built with grimoire build --config grimoire.toml.

Introduction what it does, in one page
Installation jvc, scopes, versions, or a plain checkout
The slide format front matter, separators, notes, supported Markdown
The command line every verb and flag, and the exit codes
Themes, ratios, and transitions the themes, Grimoire's included, and how the PDF differs
Plugins preprocessors in cantrip.toml, Grimoire's included
Working on Cantrip the layout, the gate, the release process

Example presentations

examples/sample.md is built and published on every push:

Deck Theme, transition About
Cantrip (PDF) plain, fade the slide format, documented by being it (examples/sample.md)

More talks, made with Cantrip, are in the Jennifer Academy, among them Jennifer for the classroom, Jennifer resources and Advanced programming with Jennifer. Their sources are in the academy's repository, jennifer-language/academy.

Press s in a slideshow for the speaker notes, ? for the shortcuts.

Tests

./scripts/check.sh

That is the whole gate: formatting, lint, doc coverage and drift, the rule that every module has a test overlay, every overlay, and a real build of the example deck whose outputs are checked for their magic bytes. CI runs the same script.

for t in src/*_test.j; do jennifer test "$t"; done
jennifer lint src/*.j scripts/*.j bin/cantrip

Every module in src/ has a co-located *_test.j white-box overlay. The launcher is a thin adapter; all the logic, and all the tests, live in src/.

License

LGPL-3.0-only. Copyright (C) 2026 mplx <mplx@jennifer-lang.dev>.

About

Markdown into slide decks as self-contained HTML or PDF

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages