codexparser 0.0.61 → 0.0.62

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.61",
3
+ "version": "0.0.62",
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
@@ -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, 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
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`
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 = "1pet2.6"
29
+ const noSpace = "1 Thess 2.15-16"
25
30
 
26
- parser.regex("1sam1:1").regexParser()
27
- console.log(parser.getPassages())
31
+ parser.regex(text).regexParser()
32
+ dump(parser.getPassages())
@@ -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
 
@@ -283,7 +282,6 @@ class CodexParser {
283
282
  let verse, chapter
284
283
  const hasChapterRange = this.found[i].match(/(?<=-\s?)\b\d+[.:].+\b/)
285
284
  const book = this.found[i].match(this.bookRegex)
286
- console.log("Book that is found is ", book, this.bookify(book))
287
285
  if (book === null) continue
288
286
  chapter = this.found[i].replace(book[0], "").match(this.chapterRegex)
289
287
 
@@ -300,8 +298,12 @@ class CodexParser {
300
298
  verse = this.found[i].split(" ")[1]
301
299
  chapter = "1"
302
300
  } else {
303
- if (this.found[i].match(this.verseRegex))
301
+ if (this.found[i].match(this.verseRegex) && !hasChapterRange)
304
302
  verse = this.found[i].match(this.verseRegex)[0].replace(/[:.]/, "").trim()
303
+ else if (this.found[i].match(this.verseRegex) && hasChapterRange)
304
+ verse = this.found[i].match(this.verseRegex)
305
+ ? this.found[i].match(this.verseRegex)[0].split("-")[0].trim()
306
+ : ["Empty"]
305
307
  }
306
308
  if (!verse && this.found[i].match(/\d+/)) {
307
309
  chapter = this.found[i].match(/\d+/)[0]
@@ -317,8 +319,8 @@ class CodexParser {
317
319
  if (hasChapterRange) {
318
320
  passage.to = {
319
321
  book: passage.book,
320
- chapter: hasChapterRange[0].match(this.chapterRegex),
321
- verses: hasChapterRange[0].match(this.verseRegex)[0].replace(/[:.]/, "").trim(),
322
+ chapter: hasChapterRange[0].match(this.chapterRegex)[0],
323
+ verses: hasChapterRange[0].match(this.verseRegex)[0],
322
324
  }
323
325
  passage.to.verses = passage.to.verses.split(/,/).filter(Boolean)
324
326
  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",
@@ -208,13 +209,16 @@ const abbrevations = {
208
209
  Co: "Colossians",
209
210
  "1Thess": "1 Thessalonians",
210
211
  "1 Thess": "1 Thessalonians",
212
+ "1Thes": "1 Thessalonians",
213
+ "1 Thes": "1 Thessalonians",
211
214
  "1 Th": "1 Thessalonians",
212
215
  "1Th": "1 Thessalonians",
213
216
  "2Thess": "2 Thessalonians",
214
217
  "2 Thess": "2 Thessalonians",
218
+ "2Thes": "2 Thessalonians",
219
+ "2 Thes": "2 Thessalonians",
215
220
  "2 Th": "2 Thessalonians",
216
221
  "2Th": "2 Thessalonians",
217
- "2Thess": "2 Thessalonians",
218
222
  "1Tim": "1 Timothy",
219
223
  "1 Ti": "1 Timothy",
220
224
  "1 Tm": "1 Timothy",
@@ -231,6 +235,7 @@ const abbrevations = {
231
235
  Ti: "Titus",
232
236
  Phlm: "Philemon",
233
237
  Phm: "Philemon",
238
+ Philem: "Philemon",
234
239
  Hebr: "Hebrews",
235
240
  Heb: "Hebrews",
236
241
  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