Lowercase redirect targets for sentence-case link text

This commit is contained in:
Edward Betts 2026-05-14 10:18:43 +01:00
parent 3ba7eaefd0
commit 728020d342
2 changed files with 80 additions and 1 deletions

View file

@ -205,7 +205,11 @@ def match_found(m: re.Match[str], q: str, linkto: str | None) -> str:
if pos == 0 or m.string[pos - 1] == "\n":
replacement = replacement[0].upper() + replacement[1:]
if linkto:
if linkto[0].isupper() and replacement[0] == linkto[0].lower():
if (
linkto[0].isupper()
and replacement[0].islower()
and not is_title_case(replacement)
):
linkto = linkto[0].lower() + linkto[1:]
elif replacement[0].isupper():
linkto = linkto[0].upper() + linkto[1:]