Add support for cross-book chapter references without verses

Handle patterns like "Hebrews 5-7" (chapter range) and "Hebrews 11"
(single chapter) that don't include verse numbers (no colon).

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-26 15:10:07 -05:00
parent 49fb98c3ee
commit 9388de679f
+17 -1
View File
@@ -252,13 +252,29 @@ document.addEventListener('DOMContentLoaded', function() {
return match;
});
// Match standalone cross-book references outside parentheses
// Match standalone cross-book verse references outside parentheses (with colon)
const standaloneCrossBookRegex = new RegExp('(' + bookPattern + ')\\s+(\\d+):(\\d+)(?:-(\\d+))?', 'gi');
text = text.replace(standaloneCrossBookRegex, function(match, book, chapter, verseStart, verseEnd) {
changed = true;
return createVerseLink(book, chapter, verseStart, verseEnd, match);
});
// Match cross-book chapter ranges like "Hebrews 5-7" (no colon = chapters, not verses)
const crossBookChapterRangeRegex = new RegExp('(' + bookPattern + ')\\s+(\\d+)-(\\d+)(?!:)', 'gi');
text = text.replace(crossBookChapterRangeRegex, function(match, book, chapterStart, chapterEnd) {
changed = true;
const normalizedBook = book.replace(/\s+/g, ' ');
return '<a href="/book/' + encodeURIComponent(normalizedBook) + '/chapter/' + chapterStart + '">' + match + '</a>';
});
// Match cross-book single chapter like "Hebrews 11" (no colon)
const crossBookChapterRegex = new RegExp('(' + bookPattern + ')\\s+(\\d+)(?![:\\d-])', 'gi');
text = text.replace(crossBookChapterRegex, function(match, book, chapter) {
changed = true;
const normalizedBook = book.replace(/\s+/g, ' ');
return '<a href="/book/' + encodeURIComponent(normalizedBook) + '/chapter/' + chapter + '">' + match + '</a>';
});
// Match remaining standalone verse ranges like "1:1-5" not in parentheses
text = text.replace(/(?<![>\d])(\d+):(\d+)-(\d+)(?![<\d])/g, function(match, chapter, verseStart, verseEnd) {
changed = true;