forked from bai/curriculum-project-hub
fix(cph): correct nested outline hierarchy
This commit is contained in:
@@ -176,7 +176,7 @@ fn consume_outline_children(
|
|||||||
depth,
|
depth,
|
||||||
path,
|
path,
|
||||||
} => {
|
} => {
|
||||||
if *depth < minimum_section_depth {
|
if *depth <= minimum_section_depth {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let section_depth = *depth;
|
let section_depth = *depth;
|
||||||
|
|||||||
@@ -12,5 +12,10 @@ path = "segments/开场白"
|
|||||||
[[children]]
|
[[children]]
|
||||||
kind = "section"
|
kind = "section"
|
||||||
path = "导言簇"
|
path = "导言簇"
|
||||||
|
notes = "这里先建立直观图像,再进入分组推导。"
|
||||||
|
|
||||||
|
[[children]]
|
||||||
|
kind = "section"
|
||||||
|
path = "收束簇"
|
||||||
|
|
||||||
[targets.student]
|
[targets.student]
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[group]
|
||||||
|
title = "收束簇"
|
||||||
|
|
||||||
|
[[children]]
|
||||||
|
kind = "segment"
|
||||||
|
path = "segments/总结"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
kind = "segment"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
总结
|
||||||
@@ -121,6 +121,7 @@ fn nested_sections_flatten_depth_first_with_correct_depths() {
|
|||||||
PathBuf::from("导言簇/segments/子段一"),
|
PathBuf::from("导言簇/segments/子段一"),
|
||||||
PathBuf::from("导言簇/嵌套子节/lemmas/子引理"),
|
PathBuf::from("导言簇/嵌套子节/lemmas/子引理"),
|
||||||
PathBuf::from("导言簇/segments/子段二"),
|
PathBuf::from("导言簇/segments/子段二"),
|
||||||
|
PathBuf::from("收束簇/segments/总结"),
|
||||||
],
|
],
|
||||||
"root-relative paths must accumulate through every nesting level"
|
"root-relative paths must accumulate through every nesting level"
|
||||||
);
|
);
|
||||||
@@ -139,7 +140,7 @@ fn nested_sections_flatten_depth_first_with_correct_depths() {
|
|||||||
kind: "section".to_string(),
|
kind: "section".to_string(),
|
||||||
title: "导言簇".to_string(),
|
title: "导言簇".to_string(),
|
||||||
depth: 1,
|
depth: 1,
|
||||||
notes: None,
|
notes: Some("这里先建立直观图像,再进入分组推导。".to_string()),
|
||||||
path: PathBuf::from("导言簇"),
|
path: PathBuf::from("导言簇"),
|
||||||
},
|
},
|
||||||
OutlineEntry::Element {
|
OutlineEntry::Element {
|
||||||
@@ -161,8 +162,25 @@ fn nested_sections_flatten_depth_first_with_correct_depths() {
|
|||||||
part_index: 3,
|
part_index: 3,
|
||||||
depth: 1,
|
depth: 1,
|
||||||
}, // 导言簇/segments/子段二
|
}, // 导言簇/segments/子段二
|
||||||
|
OutlineEntry::Section {
|
||||||
|
kind: "section".to_string(),
|
||||||
|
title: "收束簇".to_string(),
|
||||||
|
depth: 1,
|
||||||
|
notes: None,
|
||||||
|
path: PathBuf::from("收束簇"),
|
||||||
|
},
|
||||||
|
OutlineEntry::Element {
|
||||||
|
part_index: 4,
|
||||||
|
depth: 1,
|
||||||
|
}, // 收束簇/segments/总结
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
let document = lesson.outline_document();
|
||||||
|
assert_eq!(document.children.len(), 3);
|
||||||
|
assert_eq!(document.children[1].title, "导言簇");
|
||||||
|
assert_eq!(document.children[1].children.len(), 3);
|
||||||
|
assert_eq!(document.children[2].title, "收束簇");
|
||||||
|
assert_eq!(document.children[2].children[0].title, "总结");
|
||||||
|
|
||||||
// The outer section declares [group].title = "导言簇"; the inner section
|
// The outer section declares [group].title = "导言簇"; the inner section
|
||||||
// has no [group] at all, so its title falls back to the folder basename.
|
// has no [group] at all, so its title falls back to the folder basename.
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ pub fn resolve_render_dir() -> PathBuf {
|
|||||||
/// Bump when the embedded render package changes without a cph crate-version
|
/// Bump when the embedded render package changes without a cph crate-version
|
||||||
/// bump. Otherwise a user's old per-version cache can miss newly added package
|
/// bump. Otherwise a user's old per-version cache can miss newly added package
|
||||||
/// functions (such as `render-outline`).
|
/// functions (such as `render-outline`).
|
||||||
const RENDER_CACHE_REVISION: &str = "outline-v1";
|
const RENDER_CACHE_REVISION: &str = "outline-v2";
|
||||||
|
|
||||||
/// The version/revision-keyed cache location and a guarantee the embedded tree
|
/// The version/revision-keyed cache location and a guarantee the embedded tree
|
||||||
/// is present there. Returns the directory the World should use.
|
/// is present there. Returns the directory the World should use.
|
||||||
|
|||||||
@@ -21,22 +21,27 @@ path = "segments/液面拉伸的本质"
|
|||||||
[[children]]
|
[[children]]
|
||||||
kind = "section"
|
kind = "section"
|
||||||
path = "液气界面"
|
path = "液气界面"
|
||||||
|
notes = "先从液面拉伸的宏观图像切入,再用缺键模型和 LJ 对势逐步建立微观解释;可补充一个数量级估算例题。"
|
||||||
|
|
||||||
[[children]]
|
[[children]]
|
||||||
kind = "section"
|
kind = "section"
|
||||||
path = "固气界面"
|
path = "固气界面"
|
||||||
|
notes = "把液体表面能与固体表面应力放在同一张对照表中,强调固体表面能的晶面各向异性。"
|
||||||
|
|
||||||
[[children]]
|
[[children]]
|
||||||
kind = "section"
|
kind = "section"
|
||||||
path = "固液界面"
|
path = "固液界面"
|
||||||
|
notes = "围绕界面能的物理图像,串起 Dupré、Girifalco-Good、Fowkes 与 Young 方程;可安排一个浸润判据例题。"
|
||||||
|
|
||||||
[[children]]
|
[[children]]
|
||||||
kind = "section"
|
kind = "section"
|
||||||
path = "σTp态函数建模"
|
path = "σTp态函数建模"
|
||||||
|
notes = "这一节是温度依赖建模主线,先回顾 σT,再解释微观模型和经验规则之间的联系;进阶学生可比较不同模型的适用范围。"
|
||||||
|
|
||||||
[[children]]
|
[[children]]
|
||||||
kind = "section"
|
kind = "section"
|
||||||
path = "收束"
|
path = "收束"
|
||||||
|
notes = "最后对照各模型对水的预测,回收本节主线,并明确为什么实际数值可能算不准。"
|
||||||
|
|
||||||
# Export targets (ADR-0009/0011): each target is a build producing a typed
|
# Export targets (ADR-0009/0011): each target is a build producing a typed
|
||||||
# artifact, run as an ordered list of typed steps. A `typst-compile` step names a
|
# artifact, run as an ordered list of typed steps. A `typst-compile` step names a
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -248,17 +248,8 @@
|
|||||||
/// note rendered as a visually distinct teaching-tip box.
|
/// note rendered as a visually distinct teaching-tip box.
|
||||||
#let _render-outline-node(node, level) = {
|
#let _render-outline-node(node, level) = {
|
||||||
let title = node.at("title", default: "")
|
let title = node.at("title", default: "")
|
||||||
let kind = node.at("kind", default: "")
|
|
||||||
heading(level: level)[#title]
|
heading(level: level)[#title]
|
||||||
|
|
||||||
if kind != "" {
|
|
||||||
block(
|
|
||||||
inset: (x: 0.35em, y: 0.1em),
|
|
||||||
fill: gray.lighten(80%),
|
|
||||||
radius: 0.2em,
|
|
||||||
text(size: 9pt, fill: gray.darken(30%))[#kind],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
let notes = node.at("notes", default: none)
|
let notes = node.at("notes", default: none)
|
||||||
if notes != none and notes != "" {
|
if notes != none and notes != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user