mirror of
https://github.com/kennethreitz/kjvstudy.org.git
synced 2026-06-05 06:46:13 +00:00
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:
@@ -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)
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user