fix(wiki): exclude URL-shaped bibkeys from claim parsing

_parse_claims now skips matches where bibkey contains spaces or starts
with "http", preventing Markdown hyperlinks like [text](https://...) from
being misidentified as citations. Add two tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tarik Moussa
2026-06-14 03:47:27 +02:00
parent 89228a1f62
commit 60e40f6f36
2 changed files with 18 additions and 0 deletions

View File

@@ -228,6 +228,10 @@ def _parse_claims(markdown: str) -> list[Claim]:
text = match.group("text").strip()
bibkey = match.group("bibkey").strip()
locator = (match.group("locator") or "").strip()
# Skip URL-shaped bibkeys ([text](https://...)) and multi-word bibkeys
# (real BibKeys never contain spaces or start with "http")
if " " in bibkey or bibkey.startswith("http"):
continue
if text and bibkey:
claims.append(Claim(text=text, bibkey=bibkey, locator=locator))
return claims