From bfb34266c8a47f9f8f5675ab4df6783842b0c3b9 Mon Sep 17 00:00:00 2001 From: yann64 Date: Wed, 14 Oct 2026 18:45:09 +0200 Subject: [PATCH] check_links: ignore code samples in
 blocks

Co-Authored-By: Claude Opus 5.5 
Claude-Session: https://claude.ai/code/session_01YDRjtmAiNpo5mK5N3d7QwZ
---
 tools/check_links.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/check_links.py b/tools/check_links.py
index 523b0f86..717596f7 100755
--- a/tools/check_links.py
+++ b/tools/check_links.py
@@ -11,13 +11,15 @@ from urllib.parse import unquote, urldefrag, urlparse
 
 # minified pages drop the quotes around simple attribute values
 ATTR = re.compile(r'\b(?:href|src)=(?:"([^"]*)"|\'([^\']*)\'|([^\s>"\']+))', re.I)
+# code samples show markup, they do not link (escaped HTML in a 
 would look like attributes)
+PRE = re.compile(r'', re.I | re.S)
 
 
 def main():
     root = Path(sys.argv[1] if len(sys.argv) > 1 else "public").resolve()
     broken, checked = {}, 0
     for page in sorted(root.rglob("*.html")):
-        text = page.read_text(encoding="utf-8", errors="replace")
+        text = PRE.sub("", page.read_text(encoding="utf-8", errors="replace"))
         for url in {a or b or c for a, b, c in ATTR.findall(text)}:
             url = urldefrag(html.unescape(url))[0]
             parsed = urlparse(url)