#!/usr/bin/env python3
"""对 index.html 做结构与约束自检"""
from pathlib import Path
import re
html = Path('/data/workspace/index.html').read_text(encoding='utf-8')
checks = []
# 1. 基础结构
checks.append(("DOCTYPE 声明", "" in html))
checks.append(("html lang=zh-CN", 'lang="zh-CN"' in html))
checks.append(("viewport 移动端", "viewport" in html))
checks.append(("title 非空", bool(re.search(r'
(.+?)', html, re.S))))
checks.append(("keywords 非空", bool(re.search(r'name="keywords"[^>]*content="[^"]+', html))))
checks.append(("description 非空", bool(re.search(r'name="description"[^>]*content="[^"]+', html))))
# title 含更新时间
title_m = re.search(r'(.+?)', html, re.S)
checks.append(("title 含 更新时间 格式", title_m and "(更新时间:2026-09-16 22:01:37)" in title_m.group(1)))
checks.append(("title 优先马鞍山", title_m and title_m.group(1).startswith("安徽马鞍山")))
# 2. 无输入模块
checks.append(("无 form 表单", "