codexparser 0.0.60 → 0.0.61
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/regex-tester.js +9 -3
- package/src/CodexParser.js +7 -9
- package/src/abbr.js +37 -23
- package/src/regex.js +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.61",
|
|
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/regex-tester.js
CHANGED
|
@@ -9,13 +9,19 @@ Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3
|
|
|
9
9
|
Jd. 5
|
|
10
10
|
Jd 6
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
1Cor 12:34 2 Cor 3:4. He 4.12 Re 1.16
|
|
13
13
|
|
|
14
14
|
Leviticus 16:6 He 5.3 He 7.27
|
|
15
15
|
|
|
16
16
|
Hos 10:1-3, 8 and 1 John 2:23
|
|
17
17
|
|
|
18
|
-
exod15.18. 2 Cor 12:23 Malachi 3:32`
|
|
18
|
+
exod15.18. 2 Cor 12:23 Malachi 3:32 Hebrews 9:20; 10:29; 13:20 `
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const philemon = "Phlm 1 Phlm 1:2 Philemon 1:3 Phil 2:3 Phile 7"
|
|
21
|
+
|
|
22
|
+
const ez = "Ezekiel 12:3 Ezek 1:2 Ezk 2:2 Ezra 1:1 Ezr 1:2 Ez 3:4-5"
|
|
23
|
+
|
|
24
|
+
const noSpace = "1pet2.6"
|
|
25
|
+
|
|
26
|
+
parser.regex("1sam1:1").regexParser()
|
|
21
27
|
console.log(parser.getPassages())
|
package/src/CodexParser.js
CHANGED
|
@@ -169,19 +169,17 @@ class CodexParser {
|
|
|
169
169
|
if (typeof book !== "string") {
|
|
170
170
|
book = book[0]
|
|
171
171
|
}
|
|
172
|
-
let bookified
|
|
173
|
-
|
|
172
|
+
let bookified = Object.keys(this.abbrevations).find((abbr) => {
|
|
173
|
+
return abbr.toLowerCase() === book.toLowerCase()
|
|
174
|
+
})
|
|
175
|
+
bookified = this.abbrevations[bookified]
|
|
174
176
|
if (!bookified) {
|
|
175
177
|
bookified = this.bible.new.find(
|
|
176
|
-
(b) =>
|
|
177
|
-
b.charAt(0).toLowerCase() === book.charAt(0).toLowerCase() &&
|
|
178
|
-
b.toLowerCase().includes(book.toLowerCase())
|
|
178
|
+
(b) => b.toLowerCase() === book.toLowerCase() && b.toLowerCase().includes(book.toLowerCase())
|
|
179
179
|
)
|
|
180
180
|
if (!bookified) {
|
|
181
181
|
bookified = this.bible.old.find(
|
|
182
|
-
(b) =>
|
|
183
|
-
b.charAt(0).toLowerCase() === book.charAt(0).toLowerCase() &&
|
|
184
|
-
b.toLowerCase().includes(book.toLowerCase())
|
|
182
|
+
(b) => b.toLowerCase() === book.toLowerCase() && b.toLowerCase().includes(book.toLowerCase())
|
|
185
183
|
)
|
|
186
184
|
}
|
|
187
185
|
}
|
|
@@ -285,6 +283,7 @@ class CodexParser {
|
|
|
285
283
|
let verse, chapter
|
|
286
284
|
const hasChapterRange = this.found[i].match(/(?<=-\s?)\b\d+[.:].+\b/)
|
|
287
285
|
const book = this.found[i].match(this.bookRegex)
|
|
286
|
+
console.log("Book that is found is ", book, this.bookify(book))
|
|
288
287
|
if (book === null) continue
|
|
289
288
|
chapter = this.found[i].replace(book[0], "").match(this.chapterRegex)
|
|
290
289
|
|
|
@@ -324,7 +323,6 @@ class CodexParser {
|
|
|
324
323
|
passage.to.verses = passage.to.verses.split(/,/).filter(Boolean)
|
|
325
324
|
passage.to.testament = this.bible.old.includes(passage.to.book) ? "old" : "new"
|
|
326
325
|
}
|
|
327
|
-
console.log(passage)
|
|
328
326
|
passage.verses =
|
|
329
327
|
typeof passage.verses !== "object"
|
|
330
328
|
? passage.verses.split(/,/).filter(Boolean)
|
package/src/abbr.js
CHANGED
|
@@ -26,23 +26,33 @@ const abbrevations = {
|
|
|
26
26
|
Rth: "Ruth",
|
|
27
27
|
Ru: "Ruth",
|
|
28
28
|
"1Sam": "1 Samuel",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"1
|
|
33
|
-
"1
|
|
34
|
-
"1
|
|
35
|
-
"1
|
|
29
|
+
"1sam": "1 Samuel",
|
|
30
|
+
"1SA": "1 Samuel",
|
|
31
|
+
"1sa": "1 Samuel",
|
|
32
|
+
"1 SAM": "1 Samuel",
|
|
33
|
+
"1 sam": "1 Samuel",
|
|
34
|
+
"1 sm": "1 Samuel",
|
|
35
|
+
"1 sa": "1 Samuel",
|
|
36
|
+
"1 s": "1 Samuel",
|
|
36
37
|
"2 Sam": "2 Samuel",
|
|
37
|
-
"2
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
38
|
+
"2 sam": "2 Samuel",
|
|
39
|
+
"2SA": "2 Samuel",
|
|
40
|
+
"2sa": "2 Samuel",
|
|
41
|
+
"2 SAM": "2 Samuel",
|
|
42
|
+
"2 sam": "2 Samuel",
|
|
43
|
+
"2 sm": "2 Samuel",
|
|
44
|
+
"2 sa": "2 Samuel",
|
|
45
|
+
"2 s": "2 Samuel",
|
|
46
|
+
"II SAM": "2 Samuel",
|
|
47
|
+
"ii sam": "2 Samuel",
|
|
48
|
+
"II SA": "2 Samuel",
|
|
49
|
+
"ii sa": "2 Samuel",
|
|
50
|
+
"2SAM": "2 Samuel",
|
|
51
|
+
"2sam": "2 Samuel",
|
|
52
|
+
"2SM": "2 Samuel",
|
|
53
|
+
"2sm": "2 Samuel",
|
|
54
|
+
"2SA": "2 Samuel",
|
|
55
|
+
"2sa": "2 Samuel",
|
|
46
56
|
"1Kgs": "1 Kings",
|
|
47
57
|
"1 Kgs": "1 Kings",
|
|
48
58
|
"1Kgs": "1 Kings",
|
|
@@ -81,6 +91,7 @@ const abbrevations = {
|
|
|
81
91
|
"II Ch": "2 Chronicles",
|
|
82
92
|
Ezra: "Ezra",
|
|
83
93
|
Ezr: "Ezra",
|
|
94
|
+
Ez: "Ezra",
|
|
84
95
|
Neh: "Nehemiah",
|
|
85
96
|
Ne: "Nehemiah",
|
|
86
97
|
Esth: "Esther",
|
|
@@ -179,11 +190,18 @@ const abbrevations = {
|
|
|
179
190
|
"2Co": "2 Corinthians",
|
|
180
191
|
"2Cor": "2 Corinthians",
|
|
181
192
|
"2 Cor": "2 Corinthians",
|
|
193
|
+
"1cor": "1 Corinthians",
|
|
194
|
+
"1 cor": "1 Corinthians",
|
|
195
|
+
"1 co": "1 Corinthians",
|
|
196
|
+
"1co": "1 Corinthians",
|
|
197
|
+
"2cor": "2 Corinthians",
|
|
198
|
+
"2 cor": "2 Corinthians",
|
|
199
|
+
"2 co": "2 Corinthians",
|
|
200
|
+
"2co": "2 Corinthians",
|
|
182
201
|
Gal: "Galatians",
|
|
183
202
|
Ga: "Galatians",
|
|
184
203
|
Eph: "Ephesians",
|
|
185
204
|
Ephes: "Ephesians",
|
|
186
|
-
Phil: "Philippians",
|
|
187
205
|
Php: "Philippians",
|
|
188
206
|
Pp: "Philippians",
|
|
189
207
|
Col: "Colossians",
|
|
@@ -213,8 +231,6 @@ const abbrevations = {
|
|
|
213
231
|
Ti: "Titus",
|
|
214
232
|
Phlm: "Philemon",
|
|
215
233
|
Phm: "Philemon",
|
|
216
|
-
Phile: "Philemon",
|
|
217
|
-
Ph: "Philemon",
|
|
218
234
|
Hebr: "Hebrews",
|
|
219
235
|
Heb: "Hebrews",
|
|
220
236
|
He: "Hebrews",
|
|
@@ -222,7 +238,8 @@ const abbrevations = {
|
|
|
222
238
|
Jm: "James",
|
|
223
239
|
James: "James",
|
|
224
240
|
"1Pet": "1 Peter",
|
|
225
|
-
"
|
|
241
|
+
"1pe": "1 Peter",
|
|
242
|
+
"1 pe": "1 Peter",
|
|
226
243
|
"1 Pe": "1 Peter",
|
|
227
244
|
"1Pet": "1 Peter",
|
|
228
245
|
"2Pet": "2 Peter",
|
|
@@ -255,12 +272,9 @@ const abbrevations = {
|
|
|
255
272
|
Re: "Revelation",
|
|
256
273
|
Mt: "Matthew",
|
|
257
274
|
Mc: "Mark",
|
|
258
|
-
L: "Luke",
|
|
259
|
-
J: "John",
|
|
260
275
|
Act: "Acts",
|
|
261
276
|
"1K": "1 Corinthians",
|
|
262
277
|
"2K": "2 Corinthians",
|
|
263
|
-
Ph: "Philippians",
|
|
264
278
|
Kol: "Colossians",
|
|
265
279
|
"1Th": "1 Thessalonians",
|
|
266
280
|
"2Th": "2 Thessalonians",
|
package/src/regex.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
const bookRegex =
|
|
2
|
-
/((?:(I+|1st|2nd|3rd|First|Second|Third|[123])\s)?(Gen|Gn|Exo|Ex|Exod|Lev|Lv|Num|Nu|Nm|Nb|Deut|Dt|Josh|Jos|Jsh|Judg|Jdg|Jg|Jdgs|Rth|Ru|Sam|Samuel|Kings|Kgs|Chron|Chronicles|Ezra|Ezr|
|
|
2
|
+
/((?:(I+|1st|2nd|3rd|First|Second|Third|[123])\s?)?(Gen|Gn|Exo|Ex|Exod|Lev|Lv|Num|Nu|Nm|Nb|Deut|Dt|Josh|Jos|Jsh|Judg|Jdg|Jg|Jdgs|Rth|Ru|Sam|Samuel|Kings|Kgs|Chron|Chronicles|Ezra|Ezr|Neh|Ne|Esth|Job|Job|Jb|Pslm|Ps|Psalms|Psa|Psm|Pss|Prov|Pr|Prv|Eccles|Ec|Song|So|Canticles|Song of Songs|SOS|Isa|Is|Jer|Je|Jr|Lam|La|Ezek|Eze|Ezk|Dan|Da|Dn|Hos|Ho|Joel|Joe|Jl|Amos|Am|Obad|Ob|Jnh|Jon|Micah|Mic|Nah|Na|Hab|Zeph|Zep|Zp|Haggai|Hag|Hg|Zech|Zec|Zc|Mal|Mal|Ml|Matt|Mrk|Mk|Luk|Lk|John|Jn|Jhn|Acts|Ac|Rom|Ro|Rm|Co|Cor|Corinthians|Gal|Ga|Ephes|Eph|Php|Col|Col|Thes|Thess|Thessalonians|Ti|Tim|Timothy|Titus|Tit|Philem|Phm|Phlm|Phile|Hebrews|Heb|He|James|Jas|Jm|Pe|Pet|Pt|Peter|Jn|Jo|Joh|Jhn|John|Jude|Jd|Jud|Jud|Rev|The Revelation|Genesis|Exodus|Leviticus|Numbers|Deuteronomy|Joshua|Judges|Ruth|Samuel|Kings|Chronicles|Ezra|Nehemiah|Esther|Job|Psalms|Psalm|Proverbs|Ecclesiastes|Song of Solomon|Isaiah|Jeremiah|Lamentations|Ezekiel|Daniel|Hosea|Joel|Amos|Obadiah|Jonah|Micah|Nahum|Habakkuk|Zephaniah|Haggai|Zechariah|Malachi|Matthew|Mark|Luke|John|Acts|Romans|Corinthians|Galatians|Ephesians|Philippians|Phil|Colossians|Thessalonians|Timothy|Titus|Philemon|Hebrews|James|Peter|John|Revelation|Re|Ap))/gim
|
|
3
|
+
const EzraAbbrv = /(Ez)(?![a-zA-Z])/gim
|
|
3
4
|
const chapterRegex = /(\d+)(?=[:.])/gim
|
|
4
5
|
const verseRegex = /(?<=[:.])[\d: .\-]+(?:, ?[\d\-]+)*(?<![ .])/gim
|
|
5
6
|
const chapterRange = /.?\s?(?:[-—–])\s?/gm
|
|
6
7
|
const chapterRangeVerseRegex = /(?:.\d+)?/gm
|
|
7
8
|
const chapterVerseRange =
|
|
8
9
|
/(.?\s?\d+((?:[:.]\d+)?(\s?[-–—]\s?)?(?:\d+)(?:(,\s?\d+)*)?\S([:.]?\d+)?(,?\s?\d+[–—-]\s?\d+,?\d+)?)?(?:[:.]\d+)?(?:[abcde])?(?:,\d+)*(?:[-–—]\d?\s?)?)(?:[:.]\d+[–-—]\s?\d+,?\s?\d+)?/gim
|
|
9
|
-
const scripturesRegex = new RegExp(`(${bookRegex.source})(${chapterVerseRange.source})`, "gmi")
|
|
10
|
-
module.exports.bookRegex = bookRegex
|
|
10
|
+
const scripturesRegex = new RegExp(`(${bookRegex.source}|${EzraAbbrv.source})(${chapterVerseRange.source})`, "gmi")
|
|
11
|
+
module.exports.bookRegex = new RegExp(`(${bookRegex.source}|${EzraAbbrv.source})`, "gmi") // bookRegex
|
|
11
12
|
module.exports.chapterRegex = chapterRegex
|
|
12
13
|
module.exports.scripturesRegex = scripturesRegex
|
|
13
14
|
module.exports.verseRegex = verseRegex
|