codexparser 0.4.1 → 0.5.0
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
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
|
"files": [
|
|
@@ -82,7 +82,10 @@ class ScriptureScanner {
|
|
|
82
82
|
let refStartIndex = bookStartIndex
|
|
83
83
|
let originalRefStartIndex = bookStartIndex
|
|
84
84
|
|
|
85
|
-
while (
|
|
85
|
+
while (
|
|
86
|
+
i < normalizedText.length &&
|
|
87
|
+
this.#isValidChapterVerseChar(normalizedText[i], normalizedText[i - 1])
|
|
88
|
+
) {
|
|
86
89
|
if (this.#isNextBibleBook(i, lowerCaseText, lowercaseBibleFullNames, lowercaseBibleAbbreviations)) {
|
|
87
90
|
break
|
|
88
91
|
}
|
|
@@ -178,11 +181,15 @@ class ScriptureScanner {
|
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
/**
|
|
181
|
-
* Checks if character is valid for chapter/verse references
|
|
184
|
+
* Checks if character is valid for chapter/verse references.
|
|
185
|
+
* Letter suffixes (a-e) only count when they directly follow a digit, so
|
|
186
|
+
* "6:1a" continues the token but "6:1 Amos" still breaks at "A".
|
|
182
187
|
* @private
|
|
183
188
|
*/
|
|
184
|
-
#isValidChapterVerseChar(char) {
|
|
185
|
-
|
|
189
|
+
#isValidChapterVerseChar(char, prevChar) {
|
|
190
|
+
if (/[\d:,\-;\s]/.test(char)) return true
|
|
191
|
+
if (/[a-eA-E]/.test(char) && prevChar && /\d/.test(prevChar)) return true
|
|
192
|
+
return false
|
|
186
193
|
}
|
|
187
194
|
|
|
188
195
|
/**
|
|
@@ -92,10 +92,13 @@ class VersificationHandler {
|
|
|
92
92
|
const hasVersification = this.#versificationDifferences[passage.book]
|
|
93
93
|
|
|
94
94
|
passage.passages.forEach((subPassage) => {
|
|
95
|
+
const verseRef = subPassage.verseSuffix
|
|
96
|
+
? `${subPassage.chapter}:${subPassage.verse}${subPassage.verseSuffix}`
|
|
97
|
+
: `${subPassage.chapter}:${subPassage.verse}`
|
|
98
|
+
|
|
95
99
|
if (hasVersification) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
subPassage.versification = this.#versificationDifferences[passage.book][key]
|
|
100
|
+
if (this.#versificationDifferences[passage.book][verseRef]) {
|
|
101
|
+
subPassage.versification = this.#versificationDifferences[passage.book][verseRef]
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
|
|
@@ -105,11 +108,9 @@ class VersificationHandler {
|
|
|
105
108
|
versionAbbreviation === "lxx" ? "lxx" : versionAbbreviation === "mt" ? "mt" : null
|
|
106
109
|
|
|
107
110
|
if (versionType) {
|
|
108
|
-
const versionReference = `${subPassage.chapter}:${subPassage.verse}`
|
|
109
111
|
for (const versification in this.#versificationDifferences[passage.book]) {
|
|
110
112
|
if (
|
|
111
|
-
this.#versificationDifferences[passage.book][versification][versionType] ===
|
|
112
|
-
versionReference
|
|
113
|
+
this.#versificationDifferences[passage.book][versification][versionType] === verseRef
|
|
113
114
|
) {
|
|
114
115
|
subPassage.versification = this.#versificationDifferences[passage.book][versification]
|
|
115
116
|
break
|
|
@@ -169,6 +169,54 @@ module.exports = {
|
|
|
169
169
|
mt: "5:32",
|
|
170
170
|
eng: "5:18",
|
|
171
171
|
},
|
|
172
|
+
// Chapter 6: LXX 3 Reigns adds material between 6:1 and 6:14 (6:1a-d) and
|
|
173
|
+
// omits MT/Eng 6:11-14 (the divine promise speech) and 6:18 (cedar carving).
|
|
174
|
+
// Reference: Rahlfs, Septuaginta, ad loc.
|
|
175
|
+
"6:1a": {
|
|
176
|
+
lxx: "6:1a",
|
|
177
|
+
mt: "",
|
|
178
|
+
eng: "",
|
|
179
|
+
},
|
|
180
|
+
"6:1b": {
|
|
181
|
+
lxx: "6:1b",
|
|
182
|
+
mt: "",
|
|
183
|
+
eng: "",
|
|
184
|
+
},
|
|
185
|
+
"6:1c": {
|
|
186
|
+
lxx: "6:1c",
|
|
187
|
+
mt: "",
|
|
188
|
+
eng: "",
|
|
189
|
+
},
|
|
190
|
+
"6:1d": {
|
|
191
|
+
lxx: "6:1d",
|
|
192
|
+
mt: "",
|
|
193
|
+
eng: "",
|
|
194
|
+
},
|
|
195
|
+
"6:11": {
|
|
196
|
+
lxx: "",
|
|
197
|
+
mt: "6:11",
|
|
198
|
+
eng: "6:11",
|
|
199
|
+
},
|
|
200
|
+
"6:12": {
|
|
201
|
+
lxx: "",
|
|
202
|
+
mt: "6:12",
|
|
203
|
+
eng: "6:12",
|
|
204
|
+
},
|
|
205
|
+
"6:13": {
|
|
206
|
+
lxx: "",
|
|
207
|
+
mt: "6:13",
|
|
208
|
+
eng: "6:13",
|
|
209
|
+
},
|
|
210
|
+
"6:14": {
|
|
211
|
+
lxx: "",
|
|
212
|
+
mt: "6:14",
|
|
213
|
+
eng: "6:14",
|
|
214
|
+
},
|
|
215
|
+
"6:18": {
|
|
216
|
+
lxx: "",
|
|
217
|
+
mt: "6:18",
|
|
218
|
+
eng: "6:18",
|
|
219
|
+
},
|
|
172
220
|
"7:13": {
|
|
173
221
|
lxx: "7:1",
|
|
174
222
|
mt: "7:13",
|
|
@@ -46,6 +46,16 @@ class PassageUtils {
|
|
|
46
46
|
for (let i = start; i <= end && i <= chapterVerses[chapterVerses.length - 1]; i++) {
|
|
47
47
|
passages.push({ book, chapter, verse: i })
|
|
48
48
|
}
|
|
49
|
+
} else if (typeof verse === "string") {
|
|
50
|
+
const match = verse.trim().match(/^(\d+)([a-eA-E])?$/)
|
|
51
|
+
if (match) {
|
|
52
|
+
const verseNum = Number(match[1])
|
|
53
|
+
if (verseNum > 0) {
|
|
54
|
+
const entry = { book, chapter, verse: verseNum }
|
|
55
|
+
if (match[2]) entry.verseSuffix = match[2].toLowerCase()
|
|
56
|
+
passages.push(entry)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
49
59
|
} else {
|
|
50
60
|
const verseNum = Number(verse)
|
|
51
61
|
if (!isNaN(verseNum) && verseNum > 0) {
|