Wit

Defining nodes

A definition creates a reusable template: #name … name# defines it, and @name uses it. Definitions are the core of reuse — cards, citations, chapter wrappers, callouts. This page covers the three body shapes, capture lists, the ::name:: hole, and the ... body slot. Read it before Interpolation & captures and before Additive partials.

Three body shapes

  • Block#name … name# wraps multiple lines .
  • Single-line#name: value !! names a short value; the !! closes it (single-line-def, single-line-def-with-captures).
  • Value-block#name: then indented content then !! names a longer value that may span lines (multi-line-value).
source
#epigraph:
The sea does not forgive forgetting.
— coastal proverb
!!

Attention begins here. @epigraph
result

Attention begins here. The sea does not forgive forgetting. — coastal proverb

Capture lists: explicit or inferred

A capture list names the parameters a template accepts, written ||a, b, c|| right after the handle. Inside the body, each ::name:: is filled by the matching parameter.

#cite ||author, title, year||
::author:: (::year::). _::title::_.
cite#

The list is optional: leave it out and Wit infers the captures by scanning the body for ::ident:: in source order.

source
#tpl hello ::name:: tpl#

@tpl |name world|
result

hello world

That renders hello world. Inference walks into nested paragraphs, emphasis, node uses, and (if) / (each) bodies, so a hole anywhere in the template is found.

The capture hole and the body slot

::name:: is recognised only inside a definition body. In ordinary prose it renders literally — to put data into a sentence, use data access @name.field instead.

The body slot ... splices the use-site body into the template once:

source
#panel
START ... END
panel#

@panel
middle
panel@
result

START

middle

END

That yields START, then middle, then END.

Forward references and defs that use defs

Definitions are hoisted, so a use may precede its definition — @x before #x resolves fine. A definition body may reference another definition:

#keeper Ada Lovelace keeper#

#bio Written by @keeper. bio#

Common mistakes

  • Using ::name:: in prose — it only lives in a definition body.
  • Redefining the same #name twice — an error, unless you mark it additive with +#name (see Additive partials).
  • Expecting a use-site parameter to reach an inner (if) unless the template surfaces it through a capture.

See also

Interpolation & captures

· Parameters (how uses feed defs) · Additive partials · Escapes