codexparser 0.0.61 → 0.0.63
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/.babelrc +2 -4
- package/package.json +5 -4
- package/regex-tester.js +10 -5
- package/src/CodexParser.js +10 -7
- package/src/abbr.js +7 -1
- package/src/regex.js +2 -2
- package/src/toc.js +0 -1
- package/sub-verse-scripture-test.js +1 -1
- package/webpack.config.js +10 -0
package/.babelrc
CHANGED
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.63",
|
|
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": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"webpack": "webpack --mode=production",
|
|
9
|
-
"build": "browserify src/CodexParser.js -
|
|
9
|
+
"build": "browserify ./src/CodexParser.js -o ./dist/bundle.js"
|
|
10
10
|
},
|
|
11
11
|
"author": "Jeremy Menicucci",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@babel/cli": "^7.23.9",
|
|
15
|
-
"@babel/core": "^7.24.
|
|
16
|
-
"@babel/preset-env": "^7.24.
|
|
15
|
+
"@babel/core": "^7.24.9",
|
|
16
|
+
"@babel/preset-env": "^7.24.8",
|
|
17
17
|
"@babel/preset-react": "^7.23.3",
|
|
18
18
|
"axios": "^1.7.2",
|
|
19
19
|
"babel-loader": "^9.1.3",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"fs": "^0.0.1-security",
|
|
22
22
|
"glob": "^10.4.1",
|
|
23
23
|
"path": "^0.12.7",
|
|
24
|
+
"terser-webpack-plugin": "^5.3.10",
|
|
24
25
|
"uglify-es": "^3.3.9",
|
|
25
26
|
"uglifyify": "^5.0.0",
|
|
26
27
|
"webpack": "^5.90.3",
|
package/regex-tester.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
const CodexParser = require("./src/CodexParser")
|
|
2
|
+
const util = require("util")
|
|
3
|
+
|
|
4
|
+
const dump = (item) => {
|
|
5
|
+
console.log(util.inspect(item, { depth: null, colors: true }))
|
|
6
|
+
}
|
|
2
7
|
|
|
3
8
|
const parser = new CodexParser()
|
|
4
9
|
const passage = "jer 9.24 1 cor 1.31 Jd 1"
|
|
5
|
-
let text = `Joel 10:13 The passages Luke 2:32 and Lk 1:23 that we are looking at tonight 1 Cor 12:34 2 Cor 3:4 are found Jude 6, in Jude 5, Genesis 2:1 - 3:19
|
|
10
|
+
let text = `Joel 10:13 The passages Luke 2:32 and Lk 1:23 that we are looking at tonight 1 Cor 12:34 2 Cor 3:4 are found Jude 6, in Jude 5, Genesis 2:1 - 3:19. 1 John 3:16-17, 1 Peter 1:1, and Romans 10:13, 15, 17. Please turn in your Bibles. Ps 109:4,5,6,8. Isaiah 61.2-3 Mt 5.4
|
|
6
11
|
|
|
7
12
|
Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3
|
|
8
13
|
|
|
@@ -15,13 +20,13 @@ Leviticus 16:6 He 5.3 He 7.27
|
|
|
15
20
|
|
|
16
21
|
Hos 10:1-3, 8 and 1 John 2:23
|
|
17
22
|
|
|
18
|
-
exod15.18. 2 Cor 12:23 Malachi 3:32 Hebrews 9:20; 10:29; 13:20 `
|
|
23
|
+
exod15.18. 2 Cor 12:23 Malachi 3:32 Hebrews 9:20; 10:29; 13:20 2 Kings 4:8,17-37 Psalm 113-118`
|
|
19
24
|
|
|
20
25
|
const philemon = "Phlm 1 Phlm 1:2 Philemon 1:3 Phil 2:3 Phile 7"
|
|
21
26
|
|
|
22
27
|
const ez = "Ezekiel 12:3 Ezek 1:2 Ezk 2:2 Ezra 1:1 Ezr 1:2 Ez 3:4-5"
|
|
23
28
|
|
|
24
|
-
const noSpace = "
|
|
29
|
+
const noSpace = "1 Thess 2.15-16"
|
|
25
30
|
|
|
26
|
-
parser.regex(
|
|
27
|
-
|
|
31
|
+
parser.regex(text).regexParser()
|
|
32
|
+
dump(parser.getPassages())
|
package/src/CodexParser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const bible = require("./bible")
|
|
2
2
|
const { bookRegex, chapterRegex, verseRegex, scripturesRegex } = require("./regex")
|
|
3
3
|
const abbrevations = require("./abbr")
|
|
4
|
-
const toc = require("./toc")
|
|
4
|
+
//const toc = require("./toc")
|
|
5
5
|
const crawler = require("bible-passage-reference-parser/js/en_bcv_parser").bcv_parser
|
|
6
6
|
const util = require("util")
|
|
7
7
|
|
|
@@ -19,7 +19,7 @@ class CodexParser {
|
|
|
19
19
|
this.verseRegex = verseRegex
|
|
20
20
|
this.scripturesRegex = scripturesRegex
|
|
21
21
|
this.abbrevations = abbrevations
|
|
22
|
-
this.toc = toc
|
|
22
|
+
//this.toc = toc
|
|
23
23
|
this.crawler = new crawler()
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -273,7 +273,6 @@ class CodexParser {
|
|
|
273
273
|
|
|
274
274
|
regex(text) {
|
|
275
275
|
this.found = text.match(this.scripturesRegex)
|
|
276
|
-
console.log(this.found)
|
|
277
276
|
return this
|
|
278
277
|
}
|
|
279
278
|
|
|
@@ -282,8 +281,8 @@ class CodexParser {
|
|
|
282
281
|
for (let i = 0; i < this.found.length; i++) {
|
|
283
282
|
let verse, chapter
|
|
284
283
|
const hasChapterRange = this.found[i].match(/(?<=-\s?)\b\d+[.:].+\b/)
|
|
284
|
+
console.log(hasChapterRange)
|
|
285
285
|
const book = this.found[i].match(this.bookRegex)
|
|
286
|
-
console.log("Book that is found is ", book, this.bookify(book))
|
|
287
286
|
if (book === null) continue
|
|
288
287
|
chapter = this.found[i].replace(book[0], "").match(this.chapterRegex)
|
|
289
288
|
|
|
@@ -300,8 +299,12 @@ class CodexParser {
|
|
|
300
299
|
verse = this.found[i].split(" ")[1]
|
|
301
300
|
chapter = "1"
|
|
302
301
|
} else {
|
|
303
|
-
if (this.found[i].match(this.verseRegex))
|
|
302
|
+
if (this.found[i].match(this.verseRegex) && !hasChapterRange)
|
|
304
303
|
verse = this.found[i].match(this.verseRegex)[0].replace(/[:.]/, "").trim()
|
|
304
|
+
else if (this.found[i].match(this.verseRegex) && hasChapterRange)
|
|
305
|
+
verse = this.found[i].match(this.verseRegex)
|
|
306
|
+
? this.found[i].match(this.verseRegex)[0].split("-")[0].trim()
|
|
307
|
+
: ["Empty"]
|
|
305
308
|
}
|
|
306
309
|
if (!verse && this.found[i].match(/\d+/)) {
|
|
307
310
|
chapter = this.found[i].match(/\d+/)[0]
|
|
@@ -317,8 +320,8 @@ class CodexParser {
|
|
|
317
320
|
if (hasChapterRange) {
|
|
318
321
|
passage.to = {
|
|
319
322
|
book: passage.book,
|
|
320
|
-
chapter: hasChapterRange[0].match(this.chapterRegex),
|
|
321
|
-
verses: hasChapterRange[0].match(this.verseRegex)[0]
|
|
323
|
+
chapter: hasChapterRange[0].match(this.chapterRegex)[0],
|
|
324
|
+
verses: hasChapterRange[0].match(this.verseRegex)[0],
|
|
322
325
|
}
|
|
323
326
|
passage.to.verses = passage.to.verses.split(/,/).filter(Boolean)
|
|
324
327
|
passage.to.testament = this.bible.old.includes(passage.to.book) ? "old" : "new"
|
package/src/abbr.js
CHANGED
|
@@ -161,6 +161,7 @@ const abbrevations = {
|
|
|
161
161
|
Matt: "Matthew",
|
|
162
162
|
Mt: "Matthew",
|
|
163
163
|
Mark: "Mark",
|
|
164
|
+
Mc: "Mark",
|
|
164
165
|
Mrk: "Mark",
|
|
165
166
|
Mar: "Mark",
|
|
166
167
|
Mk: "Mark",
|
|
@@ -203,18 +204,22 @@ const abbrevations = {
|
|
|
203
204
|
Eph: "Ephesians",
|
|
204
205
|
Ephes: "Ephesians",
|
|
205
206
|
Php: "Philippians",
|
|
207
|
+
Phil: "Philippians",
|
|
206
208
|
Pp: "Philippians",
|
|
207
209
|
Col: "Colossians",
|
|
208
210
|
Co: "Colossians",
|
|
209
211
|
"1Thess": "1 Thessalonians",
|
|
210
212
|
"1 Thess": "1 Thessalonians",
|
|
213
|
+
"1Thes": "1 Thessalonians",
|
|
214
|
+
"1 Thes": "1 Thessalonians",
|
|
211
215
|
"1 Th": "1 Thessalonians",
|
|
212
216
|
"1Th": "1 Thessalonians",
|
|
213
217
|
"2Thess": "2 Thessalonians",
|
|
214
218
|
"2 Thess": "2 Thessalonians",
|
|
219
|
+
"2Thes": "2 Thessalonians",
|
|
220
|
+
"2 Thes": "2 Thessalonians",
|
|
215
221
|
"2 Th": "2 Thessalonians",
|
|
216
222
|
"2Th": "2 Thessalonians",
|
|
217
|
-
"2Thess": "2 Thessalonians",
|
|
218
223
|
"1Tim": "1 Timothy",
|
|
219
224
|
"1 Ti": "1 Timothy",
|
|
220
225
|
"1 Tm": "1 Timothy",
|
|
@@ -231,6 +236,7 @@ const abbrevations = {
|
|
|
231
236
|
Ti: "Titus",
|
|
232
237
|
Phlm: "Philemon",
|
|
233
238
|
Phm: "Philemon",
|
|
239
|
+
Philem: "Philemon",
|
|
234
240
|
Hebr: "Hebrews",
|
|
235
241
|
Heb: "Hebrews",
|
|
236
242
|
He: "Hebrews",
|
package/src/regex.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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|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
|
|
2
|
+
/((?:(I+|1st|2nd|3rd|First|Second|Third|[123])\s?)?(Gen|Ge|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|Matt|Mt|Mc|Mark|Luke|John|Acts|Romans|Corinthians|Galatians|Ephesians|Philippians|Phil|Colossians|Thessalonians|Timothy|Titus|Philemon|Hebrews|James|Peter|John|Revelation|Re|Ap))/gim
|
|
3
3
|
const EzraAbbrv = /(Ez)(?![a-zA-Z])/gim
|
|
4
4
|
const chapterRegex = /(\d+)(?=[:.])/gim
|
|
5
5
|
const verseRegex = /(?<=[:.])[\d: .\-]+(?:, ?[\d\-]+)*(?<![ .])/gim
|
|
6
6
|
const chapterRange = /.?\s?(?:[-—–])\s?/gm
|
|
7
7
|
const chapterRangeVerseRegex = /(?:.\d+)?/gm
|
|
8
8
|
const chapterVerseRange =
|
|
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
|
+
/(.?\s?\d+((?:[:.]\d+)?(\s?[-–—]\s?)?(?:\d+)(?:(,\s?\d+)*)?\S([:.]?\d+)?(,?\s?\d+[–—-]\s?\d+,?\d+)?)?(?:[:.]\d+)?(?:[abcde])?(?:,\s?\d+)*(?:[-–—]\d?\s?)?)(?:[:.]\d+[–-—]\s?\d+,?\s?\d+)?/gim
|
|
10
10
|
const scripturesRegex = new RegExp(`(${bookRegex.source}|${EzraAbbrv.source})(${chapterVerseRange.source})`, "gmi")
|
|
11
11
|
module.exports.bookRegex = new RegExp(`(${bookRegex.source}|${EzraAbbrv.source})`, "gmi") // bookRegex
|
|
12
12
|
module.exports.chapterRegex = chapterRegex
|
package/src/toc.js
CHANGED
|
@@ -8,5 +8,5 @@ const string = "Malachi 3:32"
|
|
|
8
8
|
const parser = new BibleParser()
|
|
9
9
|
parser.options({ invalid_passage_strategy: "include", invalid_sequence_strategy: "include" })
|
|
10
10
|
console.log(parser)
|
|
11
|
-
const result = parser.parse(
|
|
11
|
+
const result = parser.parse("Psalms 113-118")
|
|
12
12
|
dump(result.getPassages())
|
package/webpack.config.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
const path = require("path")
|
|
2
|
+
const TerserPlugin = require("terser-webpack-plugin")
|
|
2
3
|
|
|
3
4
|
module.exports = {
|
|
5
|
+
mode: "production",
|
|
4
6
|
entry: {
|
|
5
7
|
main: "./src/CodexParser.js",
|
|
6
8
|
},
|
|
9
|
+
optimization: {
|
|
10
|
+
minimize: true,
|
|
11
|
+
minimizer: [new TerserPlugin()],
|
|
12
|
+
},
|
|
7
13
|
output: {
|
|
8
14
|
filename: "CodexParser.js",
|
|
9
15
|
path: path.resolve(__dirname, "dist"),
|
|
@@ -14,6 +20,7 @@ module.exports = {
|
|
|
14
20
|
},
|
|
15
21
|
globalObject: "typeof self !== 'undefined' ? self : this",
|
|
16
22
|
},
|
|
23
|
+
target: "web",
|
|
17
24
|
module: {
|
|
18
25
|
rules: [
|
|
19
26
|
{
|
|
@@ -21,6 +28,9 @@ module.exports = {
|
|
|
21
28
|
exclude: /node_modules/,
|
|
22
29
|
use: {
|
|
23
30
|
loader: "babel-loader",
|
|
31
|
+
options: {
|
|
32
|
+
presets: ["@babel/preset-env"],
|
|
33
|
+
},
|
|
24
34
|
},
|
|
25
35
|
},
|
|
26
36
|
],
|