codexparser 0.0.22 → 0.0.24

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.
@@ -3,7 +3,7 @@ const CodexParser = require("./src/CodexParser.js")
3
3
  const parser = new CodexParser()
4
4
  const text =
5
5
  "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."
6
- const single = "Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17"
6
+ const single = "Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3"
7
7
  const jd = "Jd. 5"
8
8
  const cor = "1 Cor 12:34 2 Cor 3:4"
9
9
  const passages = parser.parse(single)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
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": {
@@ -50,17 +50,21 @@ class CodexParser {
50
50
  for (let i = 0; i < this.found.length; i++) {
51
51
  const hasChapterRange = this.found[i].match(/(?<=-\s?)\b\d+[.:].+\b/)
52
52
  const book = this.found[i].match(this.bookRegex)
53
- if(book === null) continue
53
+ if (book === null) continue
54
54
  let verse,
55
55
  chapter = this.found[i].replace(book[0], "").match(this.chapterRegex)
56
56
  if (this.found[i].match(this.verseRegex))
57
57
  verse = this.found[i].match(this.verseRegex)[0].replace(/[:.]/, "").trim()
58
58
  else {
59
- verse = chapter
60
- chapter = "1"
59
+ if (this.bookify(book).toLowerCase() === "jude" || this.bookify(book).toLowerCase() === "philemon") {
60
+ verse = chapter
61
+ chapter = "1"
62
+ } else {
63
+ verse = []
64
+ }
61
65
  }
62
66
  const passage = {
63
- original: this.found[i],
67
+ original: this.found[i].replace(/([.,])\1*$/, "").trim(),
64
68
  book: this.bookify(book),
65
69
  chapter: this.chapterify(chapter),
66
70
  verses: verse,
@@ -133,7 +137,8 @@ class CodexParser {
133
137
  */
134
138
  scripturize(passage) {
135
139
  const { book, chapter, verses, to } = passage
136
- const parts = [book, chapter, ":", verses]
140
+ const colon = verses.length !== 0 ? ":" : ""
141
+ const parts = [book, chapter, colon, verses]
137
142
  if (to) {
138
143
  parts.push("-", to.chapter, ":", to.verses)
139
144
  }
package/src/regex.js CHANGED
@@ -1,13 +1,11 @@
1
1
  const bookRegex = /(?:(I+|1st|2nd|3rd|First|Second|Third|[123])\s)?(Gen|Ge|Gn|Exo|Ex|Exod|Lev|Le|Lv|Num|Nu|Nm|Nb|Deut|Dt|Josh|Jos|Jsh|Judg|Jdg|Jg|Jdgs|Rth|Ru|Sam|Samuel|Kings|Kgs|Kin|Chron|Chronicles|Ezra|Ezr|Ez|Neh|Ne|Esth|Es|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|Mt|Mrk|Mk|Mr|Luk|Lk|John|Jn|Jhn|Acts|Ac|Rom|Ro|Rm|Co|Cor|Corinthians|Gal|Ga|Ephes|Eph|Phil|Php|Col|Col|Th|Thes|Thess|Thessalonians|Ti|Tim|Timothy|Titus|Tit|Philem|Phm|Hebrews|Heb|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|Colossians|Thessalonians|Timothy|Titus|Philemon|Hebrews|James|Peter|John|Revelation|Re|Ap)/gmi
2
2
  const chapterRegex = /\b(?:\.?\s?\d+[:|\.]?)\b/gm
3
- const verseRegex = /\b[:.](\d+(?:,?\s*?\d+?|-|–|—\d+)*)?\d+\b/gm
3
+ const verseRegex = /\b[:.](\d+(?:,?\s*?\d+?|-|–|—\d+)*)?\d+(?:[abcde])?\b/gm
4
4
  const chapterRange = /.?\s?(?:[-—–])\s?/gm
5
5
  const chapterRangeVerseRegex = /(?:.\d+)?/gm
6
6
  const chapterVerseRange =
7
- /.?\s?\d+((?:[:.]\d+)?(\s?[-–—]\s?)?(?:\d+)(?:(,\s\d+)*)?\S([:.]?\d+)?(,\s?\d+[–—-]\s?\d+)?)?(?:[:.]\d+)?/gim
7
+ /.?\s?\d+((?:[:.]\d+)?(\s?[-–—]\s?)?(?:\d+)(?:(,\s\d+)*)?\S([:.]?\d+)?(,\s?\d+[–—-]\s?\d+)?)?(?:[:.]\d+)?(?:[abcde])?/gim
8
8
  const scripturesRegex = new RegExp(`(${bookRegex.source})(${chapterVerseRange.source})`, "gmi")
9
-
10
- console.log(scripturesRegex)
11
9
  module.exports.bookRegex = bookRegex
12
10
  module.exports.chapterRegex = chapterRegex
13
11
  module.exports.scripturesRegex = scripturesRegex
@@ -0,0 +1,5 @@
1
+ const CodexParser = require("./src/CodexParser.js")
2
+
3
+ const parser = new CodexParser()
4
+ const text = parser.parse("Nehemiah 1:1d")
5
+ console.log(text)