Wit

A manuscript in chapters

Keep a long document as one file per chapter, shared vocabulary in its own file, and a thin master that assembles everything in order. Adding a chapter costs one new file and two lines.

Step 1 — Shared vocabulary

Put reusable templates and headings in shared/schema.wit, and bibliographic anchors in shared/sources.wit. A block-form definition declares its captures in double bars and wraps whatever the master splices in at the point.

~ shared/schema.wit

#cite: ::author:: (::year::) !!

#section ||title||
@h2 ::title:: h2@
...
section#

Step 2 — One file per chapter

Each chapter references the shared files, then wraps its body in a block-form definition so the master can place it wherever it likes.

~ chapters/01-introduction.wit

reference ../shared/schema.wit
reference ../shared/sources.wit

#chapter_one
@section |title The problem|

Attention, as any careful reader knows, is the rarest form of generosity.
chapter_one#

Step 3 — The master file

Reference the shared files and every chapter, add single-line metadata, then emit the chapters in order.

~ master.wit

reference ./shared/schema.wit
reference ./chapters/00-frontmatter.wit
reference ./chapters/01-introduction.wit

#thesis: { title - Attention as a Moral Practice, author - T Greig, status - draft } !!

@h1 @thesis.title h1@

By @thesis.author

(if @thesis.status is draft)
@watermark()
(end)

@frontmatter frontmatter@
@chapter_one chapter_one@

Step 4 — Build the master

wit build master.wit --fragment

Or -o thesis.pdf, or -o thesis.md — the CLI infers the format from the extension.

Result.

One document assembled from several files: the metadata header, a draft watermark (because status is draft), the frontmatter, and every chapter in order. The worked examples/thesisbuilds green and is the reference spine.

Pitfalls

  • No commas inside a record. Commas separate fields, so subtitle - Attention, Perception throws a malformed-record error. Keep metadata comma-free, or model it as a collection.
  • Prefer single-line records for metadata. A record spanning several lines is not reliably classified as data under the current parser — write it on one line.
  • Emit real headings. If a section template lays down ##-style text it renders as literal characters in HTML. Define the header with @h2 ::title:: h2@ for a genuine heading.

Variations

Gate a draft with a conditional on status; share citations across every chapter by referencing shared/sources.wit — see A bibliography across files.

See also

A bibliography across files

builds a self-gathering reference list across these same chapters; A thesis to a print-ready PDF covers the single-file case.