codexparser 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/CodexParser.js +19 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "This is a Javascript Bible parser and text scanner. It will search through texts and collate all scripture references into an array and parse them into objects, and it will parse passages into objects by book, chapter, verse, and testament. ",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
package/src/CodexParser.js
CHANGED
|
@@ -236,13 +236,9 @@ class CodexParser {
|
|
|
236
236
|
parsedPassage.verses = this.chapterVerses[book][startChapter].slice(
|
|
237
237
|
this.chapterVerses[book][startChapter].indexOf(Number(startVerse))
|
|
238
238
|
)
|
|
239
|
-
} else {
|
|
240
|
-
parsedPassage.verses.push(startVerse.trim())
|
|
241
239
|
}
|
|
242
240
|
|
|
243
241
|
// Handle same-chapter ranges (e.g., "27:27-29") and multi-chapter ranges (e.g., "Ex 2:1-3:4")
|
|
244
|
-
//TODO: Need to check for a multi chapter verse range and if fill out the verses before the verse of
|
|
245
|
-
// The second chapter.
|
|
246
242
|
if (end.includes(separator)) {
|
|
247
243
|
let [endChapter, endVerse] = end.split(separator)
|
|
248
244
|
if (Number(endChapter) !== Number(startChapter)) {
|
|
@@ -275,6 +271,7 @@ class CodexParser {
|
|
|
275
271
|
verses: this.chapterVerses[book][end],
|
|
276
272
|
}
|
|
277
273
|
} else {
|
|
274
|
+
//
|
|
278
275
|
parsedPassage.verses.push(`${startVerse}-${end}`)
|
|
279
276
|
}
|
|
280
277
|
} else {
|
|
@@ -313,6 +310,8 @@ class CodexParser {
|
|
|
313
310
|
parsedPassage.passages = this.populate(parsedPassage)
|
|
314
311
|
})
|
|
315
312
|
|
|
313
|
+
parsedPassage.valid = this._isValid(parsedPassage, passage.reference)
|
|
314
|
+
|
|
316
315
|
return parsedPassage
|
|
317
316
|
})
|
|
318
317
|
this.versification()
|
|
@@ -347,6 +346,9 @@ class CodexParser {
|
|
|
347
346
|
|
|
348
347
|
// Helper function to process a parsed passage's verses
|
|
349
348
|
const processVerses = (chapter, verses, book) => {
|
|
349
|
+
if (!verses) {
|
|
350
|
+
return
|
|
351
|
+
}
|
|
350
352
|
verses.forEach((verse) => {
|
|
351
353
|
if (isNaN(verse)) {
|
|
352
354
|
const [start, end] = verse.split("-").map(Number) // Handle ranges
|
|
@@ -431,6 +433,19 @@ class CodexParser {
|
|
|
431
433
|
hash,
|
|
432
434
|
}
|
|
433
435
|
}
|
|
436
|
+
|
|
437
|
+
_isValid(passage, reference) {
|
|
438
|
+
if (!passage.verses) {
|
|
439
|
+
return {
|
|
440
|
+
error: true,
|
|
441
|
+
code: 101,
|
|
442
|
+
message: {
|
|
443
|
+
chapter_exists: false,
|
|
444
|
+
content: "Possible invalid chapter: " + reference,
|
|
445
|
+
},
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
434
449
|
}
|
|
435
450
|
|
|
436
451
|
module.exports = CodexParser
|