forked from EduCraft/curriculum-project-hub
fix(render): per-level heading numbering via numbly; config-driven, offline (WU-C)
Fixes the numbering bug (single pattern "一、" reused across levels → level-2
rendered "二、一、…"). display now takes a `config` dict; heading numbering uses
numbly per level — framework default ("{1:一}、","{1:1}.{2:1}","{1:1}.{2:1}.{3:1}")
→ 一、 / 1.1 / 1.1.1 — overridable via config.numbering.heading from the
engineering file (ADR-0009's file-resident override path, the layer whose absence
caused the bug). Verified: grep "二、一" = 0 across all smoke PDFs.
Adds @preview/numbly:0.1.0 (pure typst, zero transitive deps), VENDORED in-repo
at render/vendor/typst-packages/preview/numbly/0.1.0/ for network-free CI;
resolve via --package-cache-path render/vendor/typst-packages. parts contract +
student/teacher field visibility unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+20
-3
@@ -23,7 +23,7 @@
|
||||
// fields). Never crashes. The "no render rule => warning"
|
||||
// diagnostic is the Rust side's job, not ours.
|
||||
|
||||
#import "src/style.typ": base-style, title-block, subtitle-block
|
||||
#import "src/style.typ": base-style, default-heading-numbering, title-block, subtitle-block
|
||||
#import "src/elements/segment.typ": display-segment
|
||||
#import "src/elements/example.typ": display-example
|
||||
#import "src/elements/lemma.typ": display-lemma
|
||||
@@ -75,17 +75,34 @@
|
||||
/// - `info`: dict, e.g. (title: "…", author: "…"). `author` may be absent.
|
||||
/// - `target`: string. MVP: "student" | "teacher". Unknown => conservative.
|
||||
/// - `parts`: ordered array of part dicts (see file header).
|
||||
#let display(info: (:), target: "student", parts: ()) = {
|
||||
/// - `config`: dict carrying the target's build/presentation overrides
|
||||
/// (ADR-0009). Open/forward-compatible — read keys with
|
||||
/// `.at(.., default: ..)`. Recognised keys (MVP):
|
||||
/// `config.numbering.heading`: array of per-level numbly pattern
|
||||
/// strings, e.g. `("{1:一}、", "{1:1}.{2:1}")`. Optional; when
|
||||
/// absent the framework default (correct per-level scheme) is
|
||||
/// used. Future presentation knobs slot in without touching
|
||||
/// this signature.
|
||||
#let display(info: (:), target: "student", parts: (), config: (:)) = {
|
||||
let title = info.at("title", default: [])
|
||||
let author = info.at("author", default: none)
|
||||
|
||||
// Resolve presentation config -> framework defaults, file may override.
|
||||
// `config.numbering.heading` (array of numbly patterns) overrides the
|
||||
// framework default per-level numbering when present.
|
||||
let numbering-cfg = config.at("numbering", default: (:))
|
||||
let heading-numbering = numbering-cfg.at(
|
||||
"heading",
|
||||
default: default-heading-numbering,
|
||||
)
|
||||
|
||||
// `document` author wants a string/array; normalise the optional field.
|
||||
set document(
|
||||
title: title,
|
||||
author: if author == none { () } else { author },
|
||||
)
|
||||
|
||||
show: base-style
|
||||
show: base-style.with(heading-numbering: heading-numbering)
|
||||
|
||||
// Reset shared counters so each rendered lesson numbers from 1.
|
||||
example-counter.update(0)
|
||||
|
||||
Reference in New Issue
Block a user