', '
'),
('', ''),
]
def main() -> int:
text = SRC.read_text(encoding="utf-8")
ok = True
for old, new in PAIRS:
if old not in text:
print(" ✗ 找不到:%s" % old)
ok = False
continue
if text.count(old) != 1:
print(" ! %s 出现 %d 次" % (old, text.count(old)))
text = text.replace(old, new)
print(" ✓ %s -> %s" % (old, new))
if not ok:
print()
print(" 有锚点没匹配,没有写回")
return 1
# 再确认一遍 HTML 里没有裸的 reveal
leftovers = re.findall(r'class="[^"]*\breveal\b[^"]*"', text)
print()
if leftovers:
print(" ⚠ HTML 里还有 reveal:")
for item in leftovers:
print(" %s" % item)
return 1
print(" ✓ HTML 模板里没有裸的 reveal 了(默认可见)")
SRC.write_text(text, encoding="utf-8", newline="\n")
print(" 已写回")
return 0
if __name__ == "__main__":
sys.exit(main())