Fixing bible search again

This commit is contained in:
2025-11-25 09:54:41 -05:00
parent d44565457e
commit 24da4d2589

View File

@@ -10,16 +10,17 @@ class SearchIndexBuilder {
this.startTime = null;
}
// Parse verses from markdown content (same logic as BibleSearchEngine)
// Parse verses from markdown content (handles multi-line verses)
parseVersesFromMarkdown(content, book, chapter, version) {
const verses = [];
const lines = content.split('\n');
let currentVerse = null;
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
for (const line of lines) {
const trimmedLine = line.trim();
// Skip empty lines and headers
if (!line || line.startsWith('#')) {
if (!trimmedLine || trimmedLine.startsWith('#')) {
continue;
}
@@ -27,22 +28,35 @@ class SearchIndexBuilder {
// - "1. In the beginning..." (numbered list format)
// - "1 In the beginning..." (simple number format)
// - "**1** In the beginning..." (bold number format)
const verseMatch = line.match(/^(\*\*)?(\d+)(\*\*)?[.\s]\s*(.+)$/);
const verseMatch = trimmedLine.match(/^(\*\*)?(\d+)(\*\*)?[.\s]\s*(.*)$/);
if (verseMatch) {
// If a new verse is found, save the previous one
if (currentVerse) {
verses.push(currentVerse);
}
const verseNumber = parseInt(verseMatch[2]);
const verseText = verseMatch[4];
verses.push({
currentVerse = {
book,
chapter,
verse: verseNumber,
text: verseText,
version
});
};
} else if (currentVerse) {
// If it's a continuation of the current verse, append the text
currentVerse.text += ` ${trimmedLine}`;
}
}
// Add the last verse
if (currentVerse) {
verses.push(currentVerse);
}
return verses;
}