codexparser 0.0.62 → 0.0.64

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 CHANGED
@@ -1,7 +1,5 @@
1
1
  {
2
2
  "presets": [
3
- "@babel/preset-env",
4
- "@babel/preset-react"
5
- ],
6
- "plugins": []
3
+ "@babel/preset-env"
4
+ ]
7
5
  }
@@ -14,8 +14,9 @@ const text =
14
14
  const single = "Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3"
15
15
  const jd = "Jd. 5"
16
16
  const cor = "1 Cor 12:4 2 Cor 3:4"
17
- const noSpace = "Re13.8"
18
- const passages = parser.parse(text + single + jd + cor + noSpace)
17
+ const noSpace = "Re13.8 "
18
+ const ezra = " Ez 1:3"
19
+ const passages = parser.parse(text + single + jd + cor + noSpace + ezra)
19
20
  passages.getPassages().forEach((passage) => {
20
21
  dump(passage)
21
22
  })
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.0.62",
3
+ "version": "0.0.64",
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 -t | uglifyjs > dist/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.0",
16
- "@babel/preset-env": "^7.24.0",
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/quicktest.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const BibleParser = require("./src/CodexParser.js")
2
- const string = "Rev 12:18"
2
+ const string = "Ezra 1:20 Ezk 23:22"
3
3
  const parser = new BibleParser()
4
4
  const result = parser.parse(string)
5
5
  console.log(result.getPassages())
package/regex-tester.js CHANGED
@@ -20,7 +20,7 @@ Leviticus 16:6 He 5.3 He 7.27
20
20
 
21
21
  Hos 10:1-3, 8 and 1 John 2:23
22
22
 
23
- exod15.18. 2 Cor 12:23 Malachi 3:32 Hebrews 9:20; 10:29; 13:20 2 Kings 4:8,17-37`
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`
24
24
 
25
25
  const philemon = "Phlm 1 Phlm 1:2 Philemon 1:3 Phil 2:3 Phile 7"
26
26
 
@@ -1,7 +1,7 @@
1
1
  const bible = require("./bible")
2
- const { bookRegex, chapterRegex, verseRegex, scripturesRegex } = require("./regex")
2
+ const { bookRegex, chapterRegex, verseRegex, scripturesRegex, EzraAbbrv } = 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,8 @@ class CodexParser {
19
19
  this.verseRegex = verseRegex
20
20
  this.scripturesRegex = scripturesRegex
21
21
  this.abbrevations = abbrevations
22
- this.toc = toc
22
+ this.EzraAbbrv = EzraAbbrv
23
+ //this.toc = toc
23
24
  this.crawler = new crawler()
24
25
  }
25
26
 
@@ -58,6 +59,11 @@ class CodexParser {
58
59
  const match = matches[i]
59
60
  text = text.substring(0, match.index) + match.book + text.substring(match.index + match.abbr.length)
60
61
  }
62
+ const bookShouldBeEra = text.match(this.EzraAbbrv)
63
+
64
+ if (bookShouldBeEra) {
65
+ text = text.replace(this.EzraAbbrv, "Ezra")
66
+ }
61
67
  const passages = this.crawler.parse(text).parsed_entities()
62
68
 
63
69
  for (let j = 0; j < passages.length; j++) {
@@ -99,6 +105,7 @@ class CodexParser {
99
105
  const results = booksWithResults[i]
100
106
  for (let j = 0; j < results.length; j++) {
101
107
  const result = results[j]
108
+
102
109
  const passage = {
103
110
  book: this.bookify(result.start.b),
104
111
  chapter: result.start.c,
@@ -281,6 +288,7 @@ class CodexParser {
281
288
  for (let i = 0; i < this.found.length; i++) {
282
289
  let verse, chapter
283
290
  const hasChapterRange = this.found[i].match(/(?<=-\s?)\b\d+[.:].+\b/)
291
+ console.log(hasChapterRange)
284
292
  const book = this.found[i].match(this.bookRegex)
285
293
  if (book === null) continue
286
294
  chapter = this.found[i].replace(book[0], "").match(this.chapterRegex)
@@ -339,4 +347,8 @@ class CodexParser {
339
347
  }
340
348
  }
341
349
 
350
+ if (typeof window !== "undefined" && window) {
351
+ if (!window.CodexParser) window.CodexParser = CodexParser
352
+ }
353
+
342
354
  module.exports = CodexParser
package/src/abbr.js CHANGED
@@ -204,6 +204,7 @@ const abbrevations = {
204
204
  Eph: "Ephesians",
205
205
  Ephes: "Ephesians",
206
206
  Php: "Philippians",
207
+ Phil: "Philippians",
207
208
  Pp: "Philippians",
208
209
  Col: "Colossians",
209
210
  Co: "Colossians",
package/src/regex.js CHANGED
@@ -12,3 +12,4 @@ module.exports.bookRegex = new RegExp(`(${bookRegex.source}|${EzraAbbrv.source})
12
12
  module.exports.chapterRegex = chapterRegex
13
13
  module.exports.scripturesRegex = scripturesRegex
14
14
  module.exports.verseRegex = verseRegex
15
+ module.exports.EzraAbbrv = EzraAbbrv
package/src/toc.js CHANGED
@@ -1,3 +1,2 @@
1
- const fs = require("fs")
2
1
  const bible = JSON.parse(fs.readFileSync(__dirname + "/../bibles/updated_kjv.json", "utf8"))
3
2
  module.exports.bible = bible
@@ -7,6 +7,5 @@ const dump = (item) => {
7
7
  const string = "Malachi 3:32"
8
8
  const parser = new BibleParser()
9
9
  parser.options({ invalid_passage_strategy: "include", invalid_sequence_strategy: "include" })
10
- console.log(parser)
11
- const result = parser.parse(string)
10
+ const result = parser.parse("Philippians 4:18")
12
11
  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
  ],