Fix Strong's cross-language derivation links

Hebrew numbers in Greek derivations often have leading zeros (H04566)
which caused lookups to fail. Now normalize all Strong's numbers by
stripping leading zeros before lookup and link generation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-03 21:21:14 -05:00
parent c861a671d2
commit 75c83a0016
2 changed files with 10 additions and 4 deletions
+5 -2
View File
@@ -241,13 +241,16 @@ def number_format(value):
def linkify_strongs(text):
"""Convert Strong's references like G1234 or H5678 to links."""
"""Convert Strong's references like G1234 or H5678 to links.
Handles leading zeros in numbers (H04566 -> H4566).
"""
if not text:
return text
pattern = r'\b([GH])(\d+)\b'
def replace(match):
prefix = match.group(1)
num = match.group(2)
num = str(int(match.group(2))) # Strip leading zeros
return f'<a href="/strongs/{prefix}{num}" class="strongs-ref">{prefix}{num}</a>'
return re.sub(pattern, replace, text)
+5 -2
View File
@@ -121,11 +121,14 @@ def format_strongs_entry(strongs_number: str) -> Optional[Dict[str, Any]]:
Returns a normalized dictionary with consistent keys.
"""
# Normalize: strip leading zeros from number portion (H04566 -> H4566)
strongs_number = strongs_number.upper().strip()
if len(strongs_number) > 1 and strongs_number[0] in ('H', 'G'):
strongs_number = strongs_number[0] + str(int(strongs_number[1:]))
entry = get_strongs_entry(strongs_number)
if not entry:
return None
strongs_number = strongs_number.upper().strip()
is_hebrew = strongs_number.startswith("H")
return {