// DEFAULT BUNDLE TEMPLATE (ADR-0030, outline shape ADR-0029). // // Lives in a bundle at `/exports/.typ`, e.g. // `exports/merged.typ`. Compiled AS MAIN with the augmented BUNDLE manifest // injected: // typst compile --root --input manifest= exports/merged.typ // // Structurally identical to the single-lesson `student.typ`/`teacher.typ` // templates (see their notes on why the include loop lives in the template, // not in cph-render), except it reads `manifest.lessons` (an ordered array of // per-lesson `(info, target, outline)` tables — see // `cph_typst::build_augmented_bundle_manifest`) instead of a single // `manifest.outline`, and calls `render-bundle` instead of `render-lesson`. // // Every outline entry's `path` in a bundle manifest is ALREADY prefixed with // that lesson's own bundle-root-relative directory (done by the Rust engine), // so the same `include "/" + path + "/" + field + ".typ"` computation used by // a single-lesson template resolves correctly here too — no special-casing // needed in this loop. #import "@local/cph-render:0.1.0": render-bundle, part-fields, default-heading-numbering #let manifest = toml(sys.inputs.manifest) #let info = manifest.at("info", default: (:)) #let raw-lessons = manifest.at("lessons", default: ()) // Assemble one outline entry exactly as a single-lesson template would. #let assemble-entry(raw) = { if raw.at("type", default: "element") == "section" { ( entry-type: "section", kind: raw.at("kind", default: none), title: raw.at("title", default: ""), depth: raw.at("depth", default: 1), ) } else { let kind = raw.at("kind", default: none) let path = raw.at("path", default: none) let spec = part-fields.at(kind, default: (content: (), optional-content: (), scalars: ())) let present = raw.at("fields", default: ()) let entry = (entry-type: "element", kind: kind) for field in spec.content { entry.insert(field, include "/" + path + "/" + field + ".typ") } for field in spec.optional-content { if field in present { entry.insert(field, include "/" + path + "/" + field + ".typ") } } if spec.scalars.len() > 0 { let element = toml("/" + path + "/element.toml") for field in spec.scalars { let v = element.at(field, default: none) if v != none and v != "" { entry.insert(field, v) } } } entry } } #let lessons = raw-lessons.map(raw => ( info: raw.at("info", default: (:)), target: raw.at("target", default: "student"), outline: raw.at("outline", default: ()).map(assemble-entry), )) // Presentation: shared per-level heading numbering across the whole bundle, // and the ADR-0030 recommended default of resetting auto-counters at each // lesson boundary (override `reset-counters: false` for continuous numbering). #render-bundle( info: info, lessons: lessons, heading-numbering: default-heading-numbering, reset-counters: true, )