Skip to content

Commit

Permalink
fix: Handle verse bridges
Browse files Browse the repository at this point in the history
Also updated 3 John to account for 15 verses
  • Loading branch information
darcywong00 committed Sep 3, 2023
1 parent 8a173f0 commit dce60d0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 14 additions & 4 deletions src/backTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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}`);
}

}
4 changes: 2 additions & 2 deletions src/books.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit dce60d0

Please sign in to comment.