fix(writer): 防静默丢章告警 + 占位符正则宽容化(大小写/全角冒号)

This commit is contained in:
lhl
2026-08-23 14:47:14 +08:00
parent 48a9624723
commit da33df92e1
10 changed files with 119 additions and 9 deletions
+12
View File
@@ -30,3 +30,15 @@ def test_map_template_falls_back_without_placeholder():
specs = map_template(parsed)
assert specs[0].chapter_id == "chapter_1"
assert specs[0].section_placeholder is None
def test_map_template_section_re_case_insensitive():
# 宽容:占位符键名大小写不敏感(解析端已归一,防御性双保险)
sections = [
ChapterMarker(type="heading", name="画面一覧", level=1),
ChapterMarker(type="placeholder", name="Section:2", level=0),
]
parsed = ParsedTemplate(file_name="t.docx", sections=sections, placeholders={}, styles={})
specs = map_template(parsed)
assert specs[0].chapter_id == "2"
assert specs[0].section_placeholder == "Section:2"