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
+22
View File
@@ -48,6 +48,28 @@ def test_section_placeholder_replaced(tmp_path):
assert "以下がDB表定义です。" in full_text
def test_section_placeholder_case_insensitive(tmp_path):
# 宽容:docx 中锚点为 {{Section:id}}(大写键)也能注入
tpl = _make_template(tmp_path, "{{Section:db_design}}")
inj = DocxInjector(tpl)
out = inj.inject({"db_design": _section_blocks()}, {"doc_title": "概要設計書"})
full_text = "\n".join(p.text for p in out.paragraphs)
assert "{{Section:db_design}}" not in full_text
assert "3.1 テーブル一覧" in full_text
def test_section_placeholder_fullwidth_colon(tmp_path):
# 宽容:docx 中锚点为 {{sectionid}}(全角冒号)也能注入
tpl = _make_template(tmp_path, "{{sectiondb_design}}")
inj = DocxInjector(tpl)
out = inj.inject({"db_design": _section_blocks()}, {"doc_title": "概要設計書"})
full_text = "\n".join(p.text for p in out.paragraphs)
assert "{{sectiondb_design}}" not in full_text
assert "3.1 テーブル一覧" in full_text
# ---------- 行内占位符替换 ----------
def test_inline_meta_replaced(tmp_path):