fix(block-ci): mask code spans that wrap lines before matching links

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-05 06:48:56 -08:00
1 parent 2c8d8d3a14
commit eeef10aeb2
2 files changed
+6 -3

No files matched your search

+2 -2
View File
@@ -10,7 +10,7 @@ import urllib.parse
SKIP_DIRS = {".git", "node_modules", "vendor"}
FENCE = re.compile(r"^\s*(`{3,}|~{3,})(.*)$")
INLINE_CODE = re.compile(r"(`+)(?:(?!\1).)+?\1")
INLINE_CODE = re.compile(r"(`+)(?:(?!\1).)+?\1", re.S)
INLINE_LINK = re.compile(r"!?\[(?:[^\[\]]|\[[^\[\]]*\])*\]\(\s*(<[^>\n]*>|(?:[^\s()]|\([^\s()]*\))+)")
REFERENCE = re.compile(r"^[ \t]{0,3}\[[^\]]+\]:\s*(<[^>]*>|\S+)", re.M)
SCHEME = re.compile(r"^[A-Za-z][A-Za-z0-9+.-]*:")
@@ -18,7 +18,7 @@ SCHEME = re.compile(r"^[A-Za-z][A-Za-z0-9+.-]*:")
def paragraph_targets(first, lines):
# A link label may wrap, so links are matched per paragraph.
text = INLINE_CODE.sub("", "\n".join(lines))
text = INLINE_CODE.sub(lambda m: "\n" * m.group().count("\n"), "\n".join(lines))
found = [(m.start(), m.group(1)) for regex in (INLINE_LINK, REFERENCE) for m in regex.finditer(text)]
for pos, target in sorted(found):
yield first + text.count("\n", 0, pos), target