A bibliography across files
Let each chapter declare its own sources and have one reference list assemble itself at the end. Add a chapter and the list grows — no central index to maintain.
Step 1 — A citation template
Declare the parameters in a header, then cite by position in prose.
~ shared/schema.wit #cite(author, year): ::author:: (::year::) !!
@cite(Weil, 1952) renders Weil (1952). Pass
values by name when one holds a comma: @cite(author: Weil, S., year: 1952).
Step 2 — Register an entry per chapter
+#name adds an entry to a list instead of redefining it. Put
each source in the chapter that uses it; emphasis works inside an entry.
~ chapters/01-introduction.wit reference ../shared/schema.wit +#bibliography: Berger, J. (1972). _Ways of Seeing_. Penguin. !! #chapter_one (h2 Introduction h2) Looking is never neutral, as @cite(Berger, 1972) showed. chapter_one#
~ chapters/02-conclusion.wit reference ../shared/schema.wit +#bibliography: Weil, S. (1952). _Gravity and Grace_. Routledge. !! #chapter_two (h2 Conclusion h2) Attention, after @cite(Weil, 1952), is a moral act. chapter_two#
Step 3 — Render the list once
Entries from every referenced file collect into one list, in the order the files are met. Loop over it wherever the references belong — here, the master.
~ master.wit reference ./chapters/01-introduction.wit reference ./chapters/02-conclusion.wit @chapter_one @chapter_two (h2 References h2) @ol (each @bibliography as entry) (li @entry li) (end) ol@
Step 4 — Build the master
wit build master.wit --fragmentResult.
<h2>Introduction</h2> <p>Looking is never neutral, as Berger (1972) showed.</p> <h2>Conclusion</h2> <p>Attention, after Weil (1952), is a moral act.</p> <h2>References</h2> <ol><li>Berger, J. (1972). <em>Ways of Seeing</em>. Penguin.</li> <li>Weil, S. (1952). <em>Gravity and Grace</em>. Routledge.</li></ol>
Pitfalls
- Order follows the references. Entries appear in the order
the
referencelines reach them, not alphabetically. Order thereferencelines to order the list. - One entry per source. A file reached by several references still adds its entries once. Two chapters that both declare the same source add it twice — declare a shared source in a shared file.
- Positional values can't hold commas.
@cite(Weil, S., 1952)isE_TOO_MANY_ARGUMENTS; name the values instead.
Variations
Pin each idea to a source once — #weil_attention: @cite(Weil, 1952) !! in shared/sources.wit — and cite by idea in prose: as @weil_attention argued. Number entries with @entry.index (from 0) inside the loop for a custom style.
See also
Additive partials covers +# in full; A manuscript in chapters is the
multi-file spine this builds on.