codexparser 0.1.54 → 0.1.55
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 +13 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.55",
|
|
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
|
@@ -203,7 +203,7 @@ class CodexParser {
|
|
|
203
203
|
version: this._handleVersion(passage.version, testament),
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
// Split reference into parts (e.g., "
|
|
206
|
+
// Split reference into parts (e.g., "Matthew 1", "2 John 2", "Matthew 1:1-3,5")
|
|
207
207
|
const parts = passage.reference.split(",")
|
|
208
208
|
|
|
209
209
|
parts.forEach((part, partIndex) => {
|
|
@@ -231,9 +231,9 @@ class CodexParser {
|
|
|
231
231
|
parsedPassage.type = "single_chapter"
|
|
232
232
|
parsedPassage.verses = [`1-${verseCount}`] // e.g., "1-13"
|
|
233
233
|
} else if (part.includes("-")) {
|
|
234
|
-
// "2 John
|
|
234
|
+
// "2 John 2-5" → "2 John 1:2-5"
|
|
235
235
|
parsedPassage.chapter = 1
|
|
236
|
-
parsedPassage.verses.push(part) // e.g., "
|
|
236
|
+
parsedPassage.verses.push(part) // e.g., "2-5"
|
|
237
237
|
parsedPassage.type = "chapter_verse_range"
|
|
238
238
|
} else {
|
|
239
239
|
// "2 John 2" → "2 John 1:2"
|
|
@@ -245,7 +245,7 @@ class CodexParser {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
} else if (part.includes("-") && !parsedPassage.chapter) {
|
|
248
|
-
// Range without chapter for multi-chapter books (e.g., "
|
|
248
|
+
// Range without chapter for multi-chapter books (e.g., "Matthew 3-5")
|
|
249
249
|
const [start, end] = part.split("-").map(Number)
|
|
250
250
|
parsedPassage.chapter = start
|
|
251
251
|
parsedPassage.verses = [
|
|
@@ -266,6 +266,15 @@ class CodexParser {
|
|
|
266
266
|
if (partIndex === 0 && !parsedPassage.chapter) {
|
|
267
267
|
parsedPassage.chapter = Number(part)
|
|
268
268
|
parsedPassage.type = "single_chapter"
|
|
269
|
+
// For multi-chapter books, set verses to full chapter range
|
|
270
|
+
if (
|
|
271
|
+
!singleChapterBook &&
|
|
272
|
+
this.chapterVerses[book] &&
|
|
273
|
+
this.chapterVerses[book][parsedPassage.chapter]
|
|
274
|
+
) {
|
|
275
|
+
const chapterVerses = this.chapterVerses[book][parsedPassage.chapter]
|
|
276
|
+
parsedPassage.verses = [`${chapterVerses[0]}-${chapterVerses[chapterVerses.length - 1]}`]
|
|
277
|
+
}
|
|
269
278
|
} else {
|
|
270
279
|
parsedPassage.verses.push(Number(part))
|
|
271
280
|
parsedPassage.type = "comma_separated_verses"
|