codexparser 0.1.47 → 0.1.49

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.1.47",
3
+ "version": "0.1.49",
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": {
@@ -4,6 +4,7 @@ const { bookRegex, chapterRegex, verseRegex, scripturesRegex } = require("./rege
4
4
  const abbrevations = require("./abbr")
5
5
  const dump = require("./functions").dump
6
6
  const dd = require("./functions").dd
7
+ const sch = require("./functions").sch
7
8
  const chapter_verses = require("./chapterVerseCombine")
8
9
 
9
10
  class CodexParser {
@@ -18,32 +19,13 @@ class CodexParser {
18
19
  this.abbreviations = abbrevations
19
20
  this.versificationDifferences = versified
20
21
  this.singleChapterBook = [
21
- {
22
- Jude: {
23
- 1: Array.from({ length: 25 }, (_, i) => i + 1),
24
- }, // Jude has 25 verses
25
- },
26
- {
27
- "2 John": {
28
- 1: Array.from({ length: 13 }, (_, i) => i + 1),
29
- }, // 2 John has 13 verses
30
- },
31
- {
32
- "3 John": {
33
- 1: Array.from({ length: 15 }, (_, i) => i + 1),
34
- }, // 3 John has 15 verses
35
- },
36
- {
37
- Obadiah: {
38
- 1: Array.from({ length: 21 }, (_, i) => i + 1),
39
- }, // Obadiah has 21 verses
40
- },
41
- {
42
- Philemon: {
43
- 1: Array.from({ length: 25 }, (_, i) => i + 1),
44
- }, // Philemon has 25 verses
45
- },
22
+ sch("Jude", 25),
23
+ sch("2 John", 13),
24
+ sch("3 John", 15),
25
+ sch("Obadiah", 21),
26
+ sch("Philemon", 25),
46
27
  ]
28
+
47
29
  this.chapterVerses = chapter_verses
48
30
  this.error = false
49
31
  this.version = null
@@ -302,7 +284,7 @@ class CodexParser {
302
284
  ? part.split(separator)
303
285
  : [parsedPassage.chapter, part]
304
286
 
305
- if (separator !== ":") {
287
+ if (separator.trim() !== ":" && !parsedPassage.chapter) {
306
288
  if (singleChapterBook) {
307
289
  parsedPassage.chapter = 1
308
290
  parsedPassage.verses.push(versePart) // Add single verse to array
@@ -438,6 +420,7 @@ class CodexParser {
438
420
  */
439
421
  populate(parsedPassage) {
440
422
  const passages = []
423
+
441
424
  const { book, chapter, verses, type, to } = parsedPassage
442
425
  const version = parsedPassage.version ? parsedPassage.version.abbreviation : "eng"
443
426
  this._setVersion(book, chapter, version) // Set version data if needed
@@ -451,11 +434,10 @@ class CodexParser {
451
434
  }
452
435
  } else if (type === "comma_separated_verses") {
453
436
  // Handle explicitly mentioned verses (e.g., 3:1,3,6)
454
- if (this.chapterVerses[book] && this.chapterVerses[book][chapter]) {
455
- verses.forEach((verse) => {
456
- passages.push({ book, chapter: Number(chapter), verse: Number(verse) })
457
- })
458
- }
437
+
438
+ verses.forEach((verse) => {
439
+ passages.push({ book, chapter: Number(chapter), verse: Number(verse) })
440
+ })
459
441
  } else if (type === "chapter_range") {
460
442
  // Handle ranges of chapters (e.g., 3-5)
461
443
  for (let currentChapter = chapter; currentChapter <= to.chapter; currentChapter++) {
@@ -586,9 +568,10 @@ class CodexParser {
586
568
 
587
569
  // Start constructing the passage string
588
570
  let combined = `${passage.book}`
589
-
571
+
590
572
  if (passage.type === "multi_chapter_verse_range" && passage.to) {
591
573
  // Multi-chapter verse range
574
+
592
575
  combined += ` ${formatChapterVerse(passage.chapter, passage.verses)}-${formatChapterVerse(
593
576
  passage.to.chapter,
594
577
  passage.to.verses
@@ -700,6 +683,7 @@ class CodexParser {
700
683
 
701
684
  // Handle multi-chapter ranges
702
685
  if (firstChapter !== lastChapter) {
686
+
703
687
  combined.type = "multi_chapter_verse_range"
704
688
  combined.to = {
705
689
  book: combined.book,
@@ -708,7 +692,7 @@ class CodexParser {
708
692
  }
709
693
  combined.original = `${combined.book} ${firstChapter}:${combined.verses.join(
710
694
  ","
711
- )}-${lastChapter}:${combined.to.verses.join(",")}`
695
+ )}; ${lastChapter}:${combined.to.verses.join(",")}`
712
696
  } else {
713
697
  // Single-chapter range or comma-separated
714
698
  if (combined.verses.length > 1) {
@@ -720,13 +704,15 @@ class CodexParser {
720
704
  }
721
705
 
722
706
  // Build the scripture property
723
- const chapterString = chapterStrings.join(",")
707
+ const chapterString = chapterStrings.join(";")
724
708
  combined.scripture = {
725
709
  passage: `${combined.book} ${chapterString}`,
726
710
  cv: chapterString,
727
- hash: `${combined.book.toLowerCase()}_${chapterString.replace(/:/g, ".").replace(/,/g, ".")}`,
711
+ hash: `${combined.book.toLowerCase()}_${chapterString.replace(/:/g, ".").replace(/,|;/g, ".")}`,
712
+ }
713
+ if (combined.to === null) {
714
+ delete combined.to
728
715
  }
729
-
730
716
  return combined
731
717
  }
732
718
 
package/src/functions.js CHANGED
@@ -10,7 +10,18 @@ function dd(message) {
10
10
  process.exit(1)
11
11
  }
12
12
 
13
+
14
+ function sch(bookName, verseCount) {
15
+ return {
16
+ [bookName]: {
17
+ 1: Array.from({ length: verseCount }, (_, i) => i + 1),
18
+ },
19
+ }
20
+ }
21
+
22
+
13
23
  module.exports = {
14
24
  dump,
15
25
  dd,
26
+ sch
16
27
  }