mirror of
https://github.com/sipeed/sipeed_wiki.git
synced 2026-11-09 17:44:31 -06:00
fix(docs): resolve cross-tree and case-only ambiguities; ignore commented-out refs
- Lichee-RV 文档在 docs/soft/Lichee/zh/,素材却在 docs/hardware/zh/lichee/ assets/RV/,中英各存一份。按页面语言消歧(两份 md5 相同),2 处 - BiT.png / Bit.png 仅大小写不同、内容相同,取与引用大小写一致的那份。 注意它写在 <img src> 里而非 markdown ![](),替换要覆盖两种写法 - 检查器补剥离 HTML 注释:被 <!-- --> 包住的引用根本不渲染, 算断链是误报(sipeed_longan_logo.jpg 即此例) 断链 50 -> 39。剩下 37 处是文件在整个仓库都不存在,自动规则已无能为力。
This commit is contained in:
@@ -31,6 +31,8 @@ PAGE_EXTS = {".md", ".html"}
|
||||
IMG_EXTS = {".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg", ".bmp", ".ico"}
|
||||
|
||||
FENCED = re.compile(r"```.*?```|~~~.*?~~~", re.S)
|
||||
# HTML 注释里的引用不会渲染,不算断链
|
||||
HTML_COMMENT = re.compile(r"<!--.*?-->", re.S)
|
||||
INLINE_CODE = re.compile(r"`[^`\n]*`")
|
||||
MD_IMG = re.compile(r"!\[[^\]]*\]\(\s*<?([^)\s>]+)")
|
||||
HTML_IMG = re.compile(r"<img\b[^>]*?\bsrc\s*=\s*[\"']([^\"']+)", re.I)
|
||||
@@ -92,7 +94,7 @@ def scan():
|
||||
text = open(page, encoding="utf-8").read()
|
||||
except (OSError, UnicodeDecodeError):
|
||||
continue
|
||||
text = INLINE_CODE.sub(" ", FENCED.sub(" ", text))
|
||||
text = INLINE_CODE.sub(" ", FENCED.sub(" ", HTML_COMMENT.sub(" ", text)))
|
||||
rel_page = os.path.relpath(page, ROOT)
|
||||
for ref in set(MD_IMG.findall(text) + HTML_IMG.findall(text)):
|
||||
if "{{" in ref or "{%" in ref: # jinja template expression
|
||||
|
||||
Reference in New Issue
Block a user