Wit

Additive partials

+#name adds an entry to a list instead of defining the name once. Each chapter registers its own bibliography entry, figure or contents row where it is written, and one loop renders them all.

Add entries, render with each

source
@ol
(each @bibliography as entry)
(li @entry li)
(end)
ol@

+#bibliography: Weil, S. (1952). _Gravity and Grace_. !!
+#bibliography: Berger, J. (1972). _Ways of Seeing_. !!
result
  1. Weil, S. (1952). Gravity and Grace.
  2. Berger, J. (1972). Ways of Seeing.
<ol><li>Weil, S. (1952). <em>Gravity and Grace</em>.</li><li>Berger, J. (1972). <em>Ways of Seeing</em>.</li></ol>

Entries are collected before rendering, so the loop may sit above them. An entry's value is read as Wit — emphasis and references work.

Block entries

The block shape works too, for entries longer than a line:

source
@ol
(each @contents as row)
(li @row li)
(end)
ol@

+#contents
(strong I. strong) The Lamp
contents#

+#contents
(strong II. strong) The Watch
contents#
result
  1. I. The Lamp
  2. II. The Watch
<ol><li><strong>I.</strong> The Lamp</li><li><strong>II.</strong> The Watch</li></ol>

Every entry for one name must have the same shape — mixing single-line and block entries is E_PARTIAL_SHAPE_MISMATCH.

Across files

Entries collect from every file in the reference graph. A master file holds the loop; each chapter registers its own entries.

~ main.wit
reference ./one.wit
reference ./two.wit

(h2 References h2)

@ol
(each @bibliography as entry)
(li @entry li)
(end)
ol@

~ one.wit
reference ./shared.wit
+#bibliography: Weil, S. (1952). _Gravity and Grace_. !!

~ two.wit
reference ./shared.wit
+#bibliography: Berger, J. (1972). _Ways of Seeing_. !!

~ shared.wit
+#bibliography: Sontag, S. (1977). _On Photography_. !!

The list is Sontag, Weil, Berger:

  • Order is the order entries are met, reading depth-first from the root — one.wit references shared.wit before its own entry, so Sontag comes first.
  • Each file contributes once — shared.wit is reached twice but its entry appears once.

To sort entries some other way, sort the data instead (see Derived content).

Common mistakes

  • Rendering with a bare @bibliography — that runs the entries together; loop with (each … as …) and wrap each one.
  • Writing #bibliography once and +#bibliography elsewhere — make every entry additive.
  • A space between + and # — write +#name.

See also

Multi-file documents · Iteration · Self-organising documents · Defining nodes