forked from bai/curriculum-project-hub
feat(render): export templates + render-lesson entry; template owns include loop (WU-C', ADR-0011)
Replace the display(parts) entry (which a generated driver called) with the
template model: real editable templates (render/templates/{student,teacher}.typ,
the framework defaults copied into an engineering file's exports/) read the
manifest via toml(sys.inputs.manifest) and assemble parts themselves.
Key finding (drives the engine): a dynamic `include` inside a package resolves
against the PACKAGE root, never --root — so the include loop must live in the
TEMPLATE (which sits under --root): `include "/" + part.path + "/" + field +
".typ"` (root-relative absolute, runtime-computed — legal per ADR-0011's verified
fact). cph-render exposes render-lesson(info, target, parts, heading-numbering)
(content-in, never includes) + part-fields (kind→fields) + default-heading-numbering.
Numbering (numbly per-level) is set in the template, editable per engineering file.
Surfaced OPEN point closed by the engine (WU-D'): typst has no file-exists
primitive, so optional content (lemma proof) presence comes from a per-part
`fields` array the engine computes from disk. Manifest injected as root-relative
absolute (--input manifest=/...). numbly stays vendored/offline. display removed.
local-packages symlink (test-only @local resolution) gitignored — regenerable,
self-referential; the embedded engine mounts cph-render directly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
# Throwaway smoke engineering file for the cph-render template round (ADR-0011).
|
||||
# Exercises all 4 kinds + nested headings (per-level numbering) + an example with
|
||||
# a `source` scalar and one without + a lemma with proof and one without.
|
||||
#
|
||||
# The per-part `fields` array lists the content fields present ON DISK. The
|
||||
# template uses it to decide whether to load OPTIONAL content (lemma `proof`),
|
||||
# because typst has no file-exists primitive. (OPEN: the exact manifest shape for
|
||||
# declaring optional-field presence is for the Rust/manifest contract to pin.)
|
||||
|
||||
[project]
|
||||
id = "smoke-eng"
|
||||
name = "cph-render template smoke"
|
||||
|
||||
[info]
|
||||
title = "向量与几何 · 示例讲义"
|
||||
author = ["张老师", "李老师"]
|
||||
|
||||
# segment — nested headings exercise per-level numbering (一、 / 1.1 / 1.1.1).
|
||||
[[parts]]
|
||||
kind = "segment"
|
||||
path = "segments/向量数量积"
|
||||
fields = ["textbook"]
|
||||
|
||||
# example WITH source scalar
|
||||
[[parts]]
|
||||
kind = "example"
|
||||
path = "examples/坐标数量积"
|
||||
fields = ["problem", "solution"]
|
||||
|
||||
# example WITHOUT source scalar
|
||||
[[parts]]
|
||||
kind = "example"
|
||||
path = "examples/求模长"
|
||||
fields = ["problem", "solution"]
|
||||
|
||||
# lemma WITH proof (proof.typ present on disk; declared in fields)
|
||||
[[parts]]
|
||||
kind = "lemma"
|
||||
path = "lemmas/柯西不等式"
|
||||
fields = ["stmt", "proof"]
|
||||
|
||||
# lemma WITHOUT proof (proof.typ absent; fields omits it)
|
||||
[[parts]]
|
||||
kind = "lemma"
|
||||
path = "lemmas/垂直判据"
|
||||
fields = ["stmt"]
|
||||
|
||||
# sop
|
||||
[[parts]]
|
||||
kind = "sop"
|
||||
path = "sops/求夹角步骤"
|
||||
fields = ["sop"]
|
||||
|
||||
[targets.student]
|
||||
artifact = "single-file"
|
||||
[[targets.student.steps]]
|
||||
type = "typst-compile"
|
||||
template = "exports/student.typ"
|
||||
|
||||
[targets.teacher]
|
||||
artifact = "single-file"
|
||||
[[targets.teacher.steps]]
|
||||
type = "typst-compile"
|
||||
template = "exports/teacher.typ"
|
||||
Reference in New Issue
Block a user