fix(cph): correct nested outline hierarchy

This commit is contained in:
2026-08-05 17:36:43 +08:00
committed by 洪佳荣
parent dd8fcfd366
commit 3d46525f40
10 changed files with 39 additions and 1078 deletions
+1 -1
View File
@@ -176,7 +176,7 @@ fn consume_outline_children(
depth,
path,
} => {
if *depth < minimum_section_depth {
if *depth <= minimum_section_depth {
break;
}
let section_depth = *depth;
+5
View File
@@ -12,5 +12,10 @@ path = "segments/开场白"
[[children]]
kind = "section"
path = "导言簇"
notes = "这里先建立直观图像,再进入分组推导。"
[[children]]
kind = "section"
path = "收束簇"
[targets.student]
@@ -0,0 +1,6 @@
[group]
title = "收束簇"
[[children]]
kind = "segment"
path = "segments/总结"
@@ -0,0 +1 @@
kind = "segment"
@@ -0,0 +1 @@
总结
+19 -1
View File
@@ -121,6 +121,7 @@ fn nested_sections_flatten_depth_first_with_correct_depths() {
PathBuf::from("导言簇/segments/子段一"),
PathBuf::from("导言簇/嵌套子节/lemmas/子引理"),
PathBuf::from("导言簇/segments/子段二"),
PathBuf::from("收束簇/segments/总结"),
],
"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(),
title: "导言簇".to_string(),
depth: 1,
notes: None,
notes: Some("这里先建立直观图像,再进入分组推导。".to_string()),
path: PathBuf::from("导言簇"),
},
OutlineEntry::Element {
@@ -161,8 +162,25 @@ fn nested_sections_flatten_depth_first_with_correct_depths() {
part_index: 3,
depth: 1,
}, // 导言簇/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
// has no [group] at all, so its title falls back to the folder basename.
+1 -1
View File
@@ -60,7 +60,7 @@ pub fn resolve_render_dir() -> PathBuf {
/// 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
/// 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
/// is present there. Returns the directory the World should use.