codexparser 0.0.18 → 0.0.19

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
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": {
@@ -23,7 +23,16 @@ class CodexParser {
23
23
  * @return {array} The found passages from the text.
24
24
  */
25
25
  scan(text) {
26
+ const judeRegex = /(?:[j|J][d|ude]+.?\s?\d+)/gim
27
+ const jude = text.match(judeRegex)
26
28
  this.found = text.match(this.scripturesRegex)
29
+ if (!this.found) {
30
+ this.found = []
31
+ }
32
+ if (jude) {
33
+ this.found.push(...jude)
34
+ }
35
+ console.log(this.found)
27
36
  return this.found
28
37
  }
29
38
 
@@ -42,8 +51,14 @@ class CodexParser {
42
51
  for (let i = 0; i < this.found.length; i++) {
43
52
  const hasChapterRange = this.found[i].match(/(?<=-\s?)\b\d+[.:].+\b/)
44
53
  const book = this.found[i].match(this.bookRegex)
45
- const chapter = this.found[i].replace(book[0], "").match(this.chapterRegex)
46
- const verse = this.found[i].match(this.verseRegex)[0].replace(/[:.]/, "").trim()
54
+ let verse,
55
+ chapter = this.found[i].replace(book[0], "").match(this.chapterRegex)
56
+ if (this.found[i].match(this.verseRegex))
57
+ verse = this.found[i].match(this.verseRegex)[0].replace(/[:.]/, "").trim()
58
+ else {
59
+ verse = chapter
60
+ chapter = "1"
61
+ }
47
62
  const passage = {
48
63
  original: this.found[i],
49
64
  book: this.bookify(book),
@@ -60,7 +75,10 @@ class CodexParser {
60
75
  passage.to.verses = passage.to.verses.split(/,/).filter(Boolean)
61
76
  passage.to.testament = this.bible.old.includes(passage.to.book) ? "old" : "new"
62
77
  }
63
- passage.verses = passage.verses.split(/,/).filter(Boolean)
78
+ passage.verses =
79
+ typeof passage.verses !== "object"
80
+ ? passage.verses.split(/,/).filter(Boolean)
81
+ : passage.verses.filter((item) => item.trim())
64
82
  passage.testament = this.bible.old.includes(passage.book) ? "old" : "new"
65
83
  passage.scripture = this.scripturize(passage)
66
84
  this.passages.push(passage)
package/src/regex.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const bookRegex =
2
- /(?:(?:[gG]e(?:[a-zA-Z]+)?|[eE]x(?:[a-zA-Z]+)?|[lL]e(?:[a-zA-Z]+)?|[nN]u(?:[a-zA-Z]+)?|[dD]e(?:[a-zA-Z]+)?|[jJ]o(?:[a-zA-Z]+)?|[jJ]u(?:[a-zA-Z]+)?|[rR]u(?:[a-zA-Z]+)?|1\s?[sS](?:[a-zA-Z]+)?|2\s?[sS](?:[a-zA-Z]+)?|1\s?[kK](?:[a-zA-Z]+)?|2\s?[kK](?:[a-zA-Z]+)?|1\s?[cC]hr(?:[a-zA-Z]+)?|2\s?[cC]hr(?:[a-zA-Z]+)?|[eE]z(?:[a-zA-Z]+)?|[nN]e(?:[a-zA-Z]+)?|[eE]s(?:[a-zA-Z]+)?|[jJ](?:[a-zA-Z]+)?|[pP]s(?:[a-zA-Z]+)?|[pP]r(?:[a-zA-Z]+)?|[eE|Qoh](?:[a-zA-Z]+)?|[sS]o(?:[a-zA-Z]+)?|[iI]s(?:[a-zA-Z]+)?|[jJ]e(?:[a-zA-Z]+)?|[lL]a(?:[a-zA-Z]+)?|[eE]z(?:[a-zA-Z]+)?|[dD](?:[a-zA-Z]+)?|[hH]o(?:[a-zA-Z]+)?|[jJ](?:[a-zA-Z]+)?|[aA](?:[a-zA-Z]+)?|[oO](?:[a-zA-Z]+)?|[jJ](?:[a-zA-Z]+)?|[mM](?:[a-zA-Z]+)?|[nN](?:[a-zA-Z]+)?|[hH]a(?:[a-zA-Z]+)?|[zZ](?:[a-zA-Z]+)?|[hH]a(?:[a-zA-Z]+)?|[zZ]e(?:[a-zA-Z]+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\b(?:\.?\s?\d+[:|\.]?)\b/gm
4
4
  const verseRegex = /\b[:.](\d+(?:,?\s*?\d+?|-|–|—\d+)*)?\d+\b/gm
5
5
  const chapterRange = /\s?(?:[-|—|–])\s?/gm
package/test.js CHANGED
@@ -2,8 +2,12 @@ const CodexParser = require("./src/CodexParser.js")
2
2
 
3
3
  const parser = new CodexParser()
4
4
  const text =
5
- "The passages that we are looking at tonight are found in 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."
5
+ "The passages that we are looking at tonight 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."
6
6
  const single = "Ge 27.27-29,89-40 Heb 11.20"
7
- const passages = parser.parse(text)
7
+ const jd = "Jd. 5"
8
+ const passages = parser.parse(single)
8
9
  console.log(passages)
9
-
10
+ const textParser = parser.parse(text)
11
+ console.log(textParser)
12
+ const jude = parser.parse(jd)
13
+ console.log(jude)