diff --git a/src/backTranslation.ts b/src/backTranslation.ts index c73d99f..8764282 100644 --- a/src/backTranslation.ts +++ b/src/backTranslation.ts @@ -14,9 +14,9 @@ import * as toolbox from './toolbox'; export const VERSE_LINE_PATTERN = /[vV](\d)+(.+)/; /** - * Regex for individual verses + * Regex for verse/multiple verses and text */ -export const VERSE_PATTERN = /(\d+)(.*)/; +export const VERSE_PATTERN = /(\d+)-?(\d+)?\s?(.*)/; /** * Extract a book name and chapter number from the filename @@ -85,14 +85,18 @@ export async function updateObj(bookObj: books.objType, file: string, currentCha splitVerses.forEach(verse => { const verseMatch = verse.match(VERSE_PATTERN); if (verseMatch) { - verseNum = verseMatch[1]; + verseNum = verseMatch[2] ? verseMatch[2] : verseMatch[1]; // Add a new verse const unit: books.unitType = { type: "verse", - text: verseMatch[2], + text: verseMatch[3], number: verseMatch[1] }; + if (verseMatch[2]) { + unit.bridgeEnd = verseMatch[2]; + } + bookObj.content[currentChapter].content.push(unit); //console.log('verse ' + verseMatch[1] + ': ' + verseMatch[2]); } else { @@ -130,4 +134,10 @@ export async function updateObj(bookObj: books.objType, file: string, currentCha `${verseNum-1} verses, should be ${bookObj.header.bookInfo.versesInChapter[currentChapter]}.`); } + if (bookObj.header.bookInfo.versesInChapter && + bookObj.header.bookInfo.versesInChapter[currentChapter] != verseNum) { + s.log('warn', `${bookObj.header.bookInfo.name} ${currentChapter} expected ` + + `${bookObj.header.bookInfo.versesInChapter[currentChapter]} verses but got ${verseNum}`); + } + } diff --git a/src/books.ts b/src/books.ts index e854c4e..1672e3f 100644 --- a/src/books.ts +++ b/src/books.ts @@ -660,8 +660,8 @@ export const bookInfo: bookType[] = [ name: "3 John", num: 65, chapters: 1, - versesInChapter: [0, 14], - verses: 14 + versesInChapter: [0, 15], + verses: 15 }, { code: "JUD",