Book
Available format: book assembles several files into one book:
an entry, book.md, that lists the chapters, and one Markdown (or JSON) file per chapter beside it.
A chapter is a story of its own; --- separates its sections, and a scene of the book is a
section of a chapter. Chapters, figures and notes are numbered by the book, cross-references and
the index are resolved once, and the same book gives a web edition, an EPUB 3 and, through the
print chain, a PDF.
The examples are book-novella (a novella in two languages, one chapter written in JSON) and
book- (tables, code and formulas). The directives of a chapter (figures, cross-references,
the index, epigraphs) and the notes are on Book directives.
A minimal book
Code
The entry has front matter only: any scene written in it is an error (book-).
book.md
A chapter is a story of its own:
01-lorem.md
- Every chapter declares
format: book. Its first#heading is its title. - Its id is its file name without the leading number (
01-lorem.md→lorem), orid:in its front matter. The first section takes the chapter's id; a section takesid=on its separator. break=pagestarts the section on a new page in print,break=righton a right-hand (odd) page (withengine:, without Paged.js,chromium break=rightgives a plain page break); the web edition marks them with a larger space before the section. On the first section of a chapter,break=rightalso starts that chapter on a right-hand page whenpdf.ischapterStart any.- Ids are unique in the whole book: a duplicate names both places.
recit init -- writes a starter entry and two chapters beside it.
Settings
In the front matter of the entry:
| Setting | Meaning | Default |
|---|---|---|
chapters | The chapter files (and optional { part, id? parts) in reading order; { file, numbered: for a preface or an afterword | required |
front | Pages before the chapters: half-title, title, copyright, toc | [title, toc] |
back | Pages after them: notes, index, glossary | [] |
noteNumbering | chapter (1 again in each chapter) or book | chapter |
cover | The cover image, relative to the entry | — |
publication | publisher, rights (a text or one per language), edition, isbn (ISBN-13, check digit verified), identifier | — |
pdf | The PDF options, below | A5, Paged.js |
subtitle (or description when subtitle is absent) is the subtitle of the title page, the web
edition and the EPUB (title-type subtitle). chapters, cover and publication belong to one
book, so they are written in the entry only. The book: section of recit. gives the
defaults of every book of a folder, and the entry wins:
| Key | What it does |
|---|---|
book.front | the pages before the chapters, as front above |
book.back | the pages after them, as back above |
book. | chapter or book, as noteNumbering above |
book.pdf | the PDF options of the book, the same keys as pdf: in the entry |
recit.config.ts
The glossary
back: adds a page of the terms the chapters use. A :term[label]{id= of a chapter
(or a word the automatic link finds) is read from the glossaries of terms. in
recit., as in any story (Glossary). The book prints it as a
link to its entry, without the hover card of the web; the glossary page lists each term used, sorted
in the book's language, with its short definition and a link to each occurrence. In the PDF these
links become the page numbers of the occurrences, as in the index; the EPUB marks the page and its
entries (glossary, glossterm, glossdef). Without glossary in back, a term is its label
alone.
recit.config.ts
Parts
An entry of chapters may be a part { part, id? grouping consecutive chapters under
one title (examples/). id defaults to the slug of part or, when the title has no
Latin letter, its number (1, 2…); chapter numbers continue across parts, and chapters outside a
part (a preface, an appendix) stay at the top level. A book without parts is unchanged.
YAML
- PDF: each part gets its own right-hand page (
Part I,Partie II, Arabic numerals in Hebrew) before its first chapter, and the table of contents nests its chapters under the part with their page numbers. - EPUB 3: each part is written to
part-(<id>. xhtml epub:) in the spine, and bothtype= "part" toc.xhtmlandnav.xhtmlnest its chapters under the part link. - Web edition: no separate page is added; each part appears as a non-link group heading above its chapters in the reader's table of contents.
The PDF
recit export -- prints the book through the same chain as every format that prints.
The options sit under pdf: in the entry's front matter, settings.pdf of its twin, or book.pdf
in recit., and the command line goes last. They are the
PDF options of every paginated format
(outline, tagged, colorMode, output, engine, page, toc, header, footer), plus
three of the book's own:
| Key | Default | What it does |
|---|---|---|
chapterStart | right | each chapter on a right-hand page, a blank page when needed; any does not, but for a chapter whose first section has break=right |
frontMatter. | roman | the numbers of the pages before the first chapter, roman or arabic |
footnotes | the notes page of back | page (at the foot of their page), chapter-end or book-end |
YAML
By default a book is A5 with 20 mm margins, laid out by Paged.js (engine:): chapters on a
right-hand page, the front matter numbered in roman numerals and the chapters from 1, the book's
title as the running head of the left pages and the chapter's of the right ones (inverted in a
right-to-left book), the contents and the index with the page numbers of their targets, each one a
link. The PDF is tagged, its bookmarks come from the headings, and the running heads are left out of
the tagged content. engine: prints without Paged.js: no running chapter title, no page
numbers in the contents, chapters on the next page; footnotes:, toc. and
page.bleed then are an error of the options. With frontMatter., or with
engine:, the numbering goes on from the front matter to the first chapter.
A described character (preview)
A book whose entry names a bible with cast: can draw a character the bible describes (its model,
see The bible) in any chapter, as a
vector still figure, with ::character{…} (@recit/, an optional package):
Markdown
pose= and expression= give the figure, animation= shows the first image of one of its cycles,
render= picks a vector render and variant= a variant; alt= replaces its accessible name
(default, « name, pose »), and caption= writes a <figcaption>. The same <svg> is drawn in the
web edition, the PDF and the EPUB. poses= (fragments of a slide) and anything the model does not
declare are refused with their file and line.
The JSON twin
The entry and every chapter have a typed JSON twin ({ "kind":),
validated by https:// and round-trip tested. break stays in a
section's attrs; figures, epigraphs and references stay directives of the body.
Bash
writes the twin of the entry and, next to each chapter, its own (01-). A book assembled
from its JSON files is the same book: examples/ writes its third chapter in JSON only.
Alongside the entry settings above (settings.id on a chapter file, settings.,
settings., settings.back, settings., settings.,
settings., settings.pdf), book.json defines settings.cast and the shared scenes
keys (see Scenes › In the JSON twin):
| Key | Type / values | Effect |
|---|---|---|
settings.cast | string or string[] (non-empty) | Bible path or non-empty list of bible paths relative to the entry (cast: in front matter, preview; A described character). |
scenes | object[] | Required in kind:: [] in the book entry (a non-empty scene raises book-), and the ordered sections of a chapter file. |
scenes.id | string (non-empty) | Required. Stable section identifier across languages (--- id=… in Markdown; Scenes). |
scenes.body | string or Record<string, string> | Optional Markdown or MDX prose and chapter directives of the section (Scenes). |
scenes.notes | string or Record<string, string> | Optional author notes in Markdown (:::notes; Scenes). |
scenes.attrs | Record<string, string | number | boolean> | Optional separator attributes (--- key=) other than id, including break ("page" or "right"; Scenes). |
Commands
| Command | What it does |
|---|---|
recit dev book.md | the web edition, reloaded when the entry, a chapter, a twin or an image changes |
recit build book. | the web edition as static files: one HTML page per chapter, readable without JavaScript |
recit validate book.md | assembles the whole book without building it, and reports every error with its file and line |
recit convert book. | the twin of the entry; --chapters adds one per chapter |
recit convert book. | a web story of the book: a title card, then a card per chapter with its epigraph or first sentence |
recit export -- | an EPUB 3 per language (--locale fr), listed in exports.json, identical bytes from one export to the next |
recit export -- | a PDF per language (book.en.pdf, --locale fr), laid out by Paged.js, listed in exports.json |
In a multilingual project (i18n in recit.), build or export a language with the base
entry and --locale (recit build book.); passing book.fr.md builds that same
French book and warns (book-). -o, --output names the file (a folder for build).
Every command and its flags are in the CLI reference.
The errors
Every error of a book carries its file and its line, never a guess, in the one form every Récit command prints, followed by its code:
Code
Bridges
A book has one bridge, book → docs (see Bridges): its entry listed in a site,
each chapter becomes a page of the site and the table of contents its sidebar, as the next section
shows. The mapping is closed: one chapter is one page, with the id of the chapter as its last
segment, and the contents are the sidebar of those pages only. A book that does not assemble is
refused before the site is built, each error with its file and line (the site prints no code), never
published in part:
Code
No bridge leaves a book for a deck or a film: a chapter is prose, which no slide or shot holds without a summary.
In a site
In a site, publish. lists the entry of a book: each page of the book gets its route
(/<prefix>/), the table of contents becomes the sidebar of its pages, Pagefind
indexes each chapter, and <StoryEmbed slug= shows one
chapter in a page.
The MCP server describes the format (describe_, recit://) and its book_outline
tool lists the ids a chapter can cite.
Packages
TypeScript
| Import | Contents |
|---|---|
@recit/book | assembleBookFiles, renderBookHtml, the book model, no React |
@recit/ | assembleBook, reading a book from disk, and writeEpub, the EPUB 3 (Node only) |
@recit/ | the web edition (BookReader, BookToc, BookIndex…) |
@recit/ | mountBook, the page of recit dev and recit build |
@recit/ | the printable view (bookPrintDocument) |
@recit/ | the stylesheet of the web edition |