codexparser 0.0.63 → 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.
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.0.63",
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": {
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())
@@ -1,5 +1,5 @@
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
4
  //const toc = require("./toc")
5
5
  const crawler = require("bible-passage-reference-parser/js/en_bcv_parser").bcv_parser
@@ -19,6 +19,7 @@ class CodexParser {
19
19
  this.verseRegex = verseRegex
20
20
  this.scripturesRegex = scripturesRegex
21
21
  this.abbrevations = abbrevations
22
+ this.EzraAbbrv = EzraAbbrv
22
23
  //this.toc = toc
23
24
  this.crawler = new crawler()
24
25
  }
@@ -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,
@@ -340,4 +347,8 @@ class CodexParser {
340
347
  }
341
348
  }
342
349
 
350
+ if (typeof window !== "undefined" && window) {
351
+ if (!window.CodexParser) window.CodexParser = CodexParser
352
+ }
353
+
343
354
  module.exports = CodexParser
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
@@ -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("Psalms 113-118")
10
+ const result = parser.parse("Philippians 4:18")
12
11
  dump(result.getPassages())