Fixing bible search
This commit is contained in:
@@ -8,39 +8,50 @@ class BibleSearchEngine {
|
|||||||
this.isIndexed = false;
|
this.isIndexed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse verses from markdown content
|
// Parse verses from markdown content (handles multi-line verses)
|
||||||
parseVersesFromMarkdown(content, book, chapter) {
|
parseVersesFromMarkdown(content, book, chapter) {
|
||||||
const verses = [];
|
const verses = [];
|
||||||
const lines = content.split('\n');
|
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
|
// Skip empty lines and headers
|
||||||
if (!line || line.startsWith('#')) {
|
if (!trimmedLine || trimmedLine.startsWith('#')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match verse patterns:
|
const verseMatch = trimmedLine.match(/^(\*\*)?(\d+)(\*\*)?[.\s]\s*(.*)$/);
|
||||||
// - "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*(.+)$/);
|
|
||||||
|
|
||||||
if (verseMatch) {
|
if (verseMatch) {
|
||||||
|
// If a new verse is found, save the previous one
|
||||||
|
if (currentVerse) {
|
||||||
|
verses.push(currentVerse);
|
||||||
|
}
|
||||||
|
|
||||||
const verseNumber = parseInt(verseMatch[2]);
|
const verseNumber = parseInt(verseMatch[2]);
|
||||||
const verseText = verseMatch[4];
|
const verseText = verseMatch[4];
|
||||||
|
|
||||||
verses.push({
|
currentVerse = {
|
||||||
book,
|
book,
|
||||||
chapter,
|
chapter,
|
||||||
verse: verseNumber,
|
verse: verseNumber,
|
||||||
text: verseText,
|
text: verseText,
|
||||||
fullText: line
|
fullText: trimmedLine
|
||||||
});
|
};
|
||||||
|
} else if (currentVerse) {
|
||||||
|
// If it's a continuation of the current verse, append the text
|
||||||
|
currentVerse.text += ` ${trimmedLine}`;
|
||||||
|
currentVerse.fullText += `\n${trimmedLine}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the last verse
|
||||||
|
if (currentVerse) {
|
||||||
|
verses.push(currentVerse);
|
||||||
|
}
|
||||||
|
|
||||||
return verses;
|
return verses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user