codexparser 0.1.70 → 0.1.72
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 +22 -16
- package/src/abbr.js +20 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.72",
|
|
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
|
@@ -124,7 +124,7 @@ class CodexParser {
|
|
|
124
124
|
for (let book of fullNames) {
|
|
125
125
|
if (
|
|
126
126
|
lowerCaseText.startsWith(book.toLowerCase(), i) &&
|
|
127
|
-
(i + book.length >= lowerCaseText.length ||
|
|
127
|
+
(i + book.length >= lowerCaseText.length || /[\s:;\d]/.test(lowerCaseText[i + book.length]))
|
|
128
128
|
) {
|
|
129
129
|
foundBook = book
|
|
130
130
|
matchedLength = book.length
|
|
@@ -135,7 +135,7 @@ class CodexParser {
|
|
|
135
135
|
for (let abbr of abbreviations) {
|
|
136
136
|
if (
|
|
137
137
|
lowerCaseText.startsWith(abbr.toLowerCase(), i) &&
|
|
138
|
-
(i + abbr.length >= lowerCaseText.length ||
|
|
138
|
+
(i + abbr.length >= lowerCaseText.length || /[\s:;\d]/.test(lowerCaseText[i + abbr.length]))
|
|
139
139
|
) {
|
|
140
140
|
foundBook = this.abbreviations[abbr]
|
|
141
141
|
matchedLength = abbr.length
|
|
@@ -145,11 +145,23 @@ class CodexParser {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
if (foundBook) {
|
|
148
|
-
// Check if book is followed by a
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
// Check if book is followed by a valid reference when booksOnly is false
|
|
149
|
+
let isFollowedByReference = false
|
|
150
|
+
if (!this.config.booksOnly && !hasOpeningParen) {
|
|
151
|
+
let j = i + matchedLength
|
|
152
|
+
// Skip spaces
|
|
153
|
+
while (j < lowerCaseText.length && /\s/.test(lowerCaseText[j])) {
|
|
154
|
+
j++
|
|
155
|
+
}
|
|
156
|
+
// Check for digit or colon indicating a reference
|
|
157
|
+
if (j < lowerCaseText.length && /[\d:]/.test(lowerCaseText[j])) {
|
|
158
|
+
isFollowedByReference = true
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
isFollowedByReference = true // Allow if booksOnly or in parentheses
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!isFollowedByReference) {
|
|
153
165
|
i++
|
|
154
166
|
continue
|
|
155
167
|
}
|
|
@@ -164,21 +176,15 @@ class CodexParser {
|
|
|
164
176
|
i++
|
|
165
177
|
}
|
|
166
178
|
|
|
167
|
-
// Capture chapter-verse
|
|
168
|
-
while (
|
|
169
|
-
i < lowerCaseText.length &&
|
|
170
|
-
(/[\d]/.test(normalizedText[i]) ||
|
|
171
|
-
normalizedText[i] === ":" ||
|
|
172
|
-
normalizedText[i] === "," ||
|
|
173
|
-
normalizedText[i] === "-")
|
|
174
|
-
) {
|
|
179
|
+
// Capture chapter-verse (allow digits, colons, commas, dashes, spaces)
|
|
180
|
+
while (i < lowerCaseText.length && (/[\d:,\-]/.test(normalizedText[i]) || normalizedText[i] === " ")) {
|
|
175
181
|
if (normalizedText[i] === ":") hasColon = true
|
|
176
182
|
chapterVerse += normalizedText[i]
|
|
177
183
|
i++
|
|
178
184
|
}
|
|
179
185
|
|
|
180
186
|
// Only proceed if valid reference or booksOnly is true
|
|
181
|
-
if ((hasColon && chapterVerse.trim().length > 0) || this.config.booksOnly) {
|
|
187
|
+
if ((hasColon && chapterVerse.trim().length > 0) || (this.config.booksOnly && !chapterVerse.trim())) {
|
|
182
188
|
let endIndex = i
|
|
183
189
|
let version = null
|
|
184
190
|
|
package/src/abbr.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
const abbrevations = {
|
|
2
2
|
Gen: "Genesis",
|
|
3
|
-
|
|
3
|
+
Ge: "Genesis",
|
|
4
4
|
Gn: "Genesis",
|
|
5
5
|
Ex: "Exodus",
|
|
6
6
|
Exo: "Exodus",
|
|
7
7
|
Exod: "Exodus",
|
|
8
8
|
Lev: "Leviticus",
|
|
9
|
-
|
|
9
|
+
Le: "Leviticus",
|
|
10
10
|
Lv: "Leviticus",
|
|
11
11
|
Num: "Numbers",
|
|
12
12
|
Nu: "Numbers",
|
|
13
13
|
Nb: "Numbers",
|
|
14
14
|
Nm: "Numbers",
|
|
15
15
|
Deut: "Deuteronomy",
|
|
16
|
-
|
|
16
|
+
De: "Deuteronomy",
|
|
17
17
|
Dt: "Deuteronomy",
|
|
18
18
|
Josh: "Joshua",
|
|
19
19
|
Jos: "Joshua",
|
|
@@ -24,7 +24,7 @@ const abbrevations = {
|
|
|
24
24
|
Jdg: "Judges",
|
|
25
25
|
Ruth: "Ruth",
|
|
26
26
|
Rth: "Ruth",
|
|
27
|
-
|
|
27
|
+
Ru: "Ruth",
|
|
28
28
|
"1Sam": "1 Samuel",
|
|
29
29
|
"1sam": "1 Samuel",
|
|
30
30
|
"1SA": "1 Samuel",
|
|
@@ -92,10 +92,10 @@ const abbrevations = {
|
|
|
92
92
|
Ezra: "Ezra",
|
|
93
93
|
Ezr: "Ezra",
|
|
94
94
|
Neh: "Nehemiah",
|
|
95
|
-
|
|
95
|
+
Ne: "Nehemiah",
|
|
96
96
|
Esth: "Esther",
|
|
97
97
|
Est: "Esther",
|
|
98
|
-
|
|
98
|
+
Es: "Esther",
|
|
99
99
|
Job: "Job",
|
|
100
100
|
Jb: "Job",
|
|
101
101
|
Ps: "Psalms",
|
|
@@ -107,36 +107,36 @@ const abbrevations = {
|
|
|
107
107
|
Prov: "Proverbs",
|
|
108
108
|
Pro: "Proverbs",
|
|
109
109
|
Prv: "Proverbs",
|
|
110
|
-
|
|
110
|
+
Pr: "Proverbs",
|
|
111
111
|
Eccl: "Ecclesiastes",
|
|
112
112
|
Eccles: "Ecclesiastes",
|
|
113
113
|
Eccle: "Ecclesiastes",
|
|
114
114
|
Ecc: "Ecclesiastes",
|
|
115
|
-
|
|
115
|
+
Ec: "Ecclesiastes",
|
|
116
116
|
Qoh: "Ecclesiastes",
|
|
117
117
|
Song: "Song of Songs",
|
|
118
118
|
SOS: "Song of Songs",
|
|
119
119
|
So: "Song of Songs",
|
|
120
120
|
Cant: "Song of Songs",
|
|
121
121
|
Isa: "Isaiah",
|
|
122
|
-
|
|
122
|
+
Is: "Isaiah",
|
|
123
123
|
Jer: "Jeremiah",
|
|
124
|
-
|
|
124
|
+
Je: "Jeremiah",
|
|
125
125
|
Lam: "Lamentations",
|
|
126
126
|
La: "Lamentations",
|
|
127
127
|
Ezek: "Ezekiel",
|
|
128
128
|
Eze: "Ezekiel",
|
|
129
129
|
Ezk: "Ezekiel",
|
|
130
130
|
Dan: "Daniel",
|
|
131
|
-
|
|
131
|
+
Da: "Daniel",
|
|
132
132
|
Dn: "Daniel",
|
|
133
133
|
Hos: "Hosea",
|
|
134
|
-
|
|
134
|
+
Ho: "Hosea",
|
|
135
135
|
Joel: "Joel",
|
|
136
136
|
Jl: "Joel",
|
|
137
137
|
Amos: "Amos",
|
|
138
138
|
Am: "Amos",
|
|
139
|
-
|
|
139
|
+
Ob: "Obadiah",
|
|
140
140
|
Obad: "Obadiah",
|
|
141
141
|
Jonah: "Jonah",
|
|
142
142
|
Jnh: "Jonah",
|
|
@@ -144,7 +144,7 @@ const abbrevations = {
|
|
|
144
144
|
Mic: "Micah",
|
|
145
145
|
Mc: "Micah",
|
|
146
146
|
Nah: "Nahum",
|
|
147
|
-
|
|
147
|
+
Na: "Nahum",
|
|
148
148
|
Hb: "Habakkuk",
|
|
149
149
|
Hab: "Habakkuk",
|
|
150
150
|
Zeph: "Zephaniah",
|
|
@@ -177,7 +177,7 @@ const abbrevations = {
|
|
|
177
177
|
Act: "Acts",
|
|
178
178
|
Ac: "Acts",
|
|
179
179
|
Rom: "Romans",
|
|
180
|
-
|
|
180
|
+
Ro: "Romans",
|
|
181
181
|
Rm: "Romans",
|
|
182
182
|
"1Cor": "1 Corinthians",
|
|
183
183
|
"1 Cor": "1 Corinthians",
|
|
@@ -200,14 +200,14 @@ const abbrevations = {
|
|
|
200
200
|
"2 co": "2 Corinthians",
|
|
201
201
|
"2co": "2 Corinthians",
|
|
202
202
|
Gal: "Galatians",
|
|
203
|
-
|
|
203
|
+
Ga: "Galatians",
|
|
204
204
|
Eph: "Ephesians",
|
|
205
205
|
Ephes: "Ephesians",
|
|
206
206
|
Php: "Philippians",
|
|
207
207
|
Phil: "Philippians",
|
|
208
208
|
Pp: "Philippians",
|
|
209
209
|
Col: "Colossians",
|
|
210
|
-
|
|
210
|
+
Co: "Colossians",
|
|
211
211
|
"1Thess": "1 Thessalonians",
|
|
212
212
|
"1 Thess": "1 Thessalonians",
|
|
213
213
|
"1Thes": "1 Thessalonians",
|
|
@@ -233,11 +233,11 @@ const abbrevations = {
|
|
|
233
233
|
Titus: "Titus",
|
|
234
234
|
Tt: "Titus",
|
|
235
235
|
Tit: "Titus",
|
|
236
|
-
|
|
236
|
+
Ti: "Titus",
|
|
237
237
|
Phlm: "Philemon",
|
|
238
238
|
Phm: "Philemon",
|
|
239
239
|
Philem: "Philemon",
|
|
240
|
-
|
|
240
|
+
He: "Hebrews",
|
|
241
241
|
Hebr: "Hebrews",
|
|
242
242
|
Heb: "Hebrews",
|
|
243
243
|
Jas: "James",
|
|
@@ -275,7 +275,7 @@ const abbrevations = {
|
|
|
275
275
|
Jud: "Jude",
|
|
276
276
|
Jd: "Jude",
|
|
277
277
|
Rev: "Revelation",
|
|
278
|
-
|
|
278
|
+
Re: "Revelation",
|
|
279
279
|
Mt: "Matthew",
|
|
280
280
|
Mc: "Mark",
|
|
281
281
|
Act: "Acts",
|