codexparser 0.1.4 → 0.1.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/CodexParser.js +37 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
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": {
@@ -96,6 +96,12 @@ class CodexParser {
96
96
  return false
97
97
  }
98
98
 
99
+ // Function to detect suffixes like "LXX" or "MT"
100
+ const detectSuffix = (startIndex) => {
101
+ const suffixMatch = text.substring(startIndex).match(/\b(LXX|MT)\b/i)
102
+ return suffixMatch ? suffixMatch[0].toUpperCase() : null
103
+ }
104
+
99
105
  // Loop through the text and check for full names and abbreviations
100
106
  while (i < lowerCaseText.length) {
101
107
  let foundBook = null
@@ -170,17 +176,25 @@ class CodexParser {
170
176
  // Replace any periods within the reference with colons for easier parsing
171
177
  const formattedReference = chapterVerse.replace(/\./g, ":")
172
178
 
179
+ // Detect if a suffix (LXX or MT) exists after the chapter/verse
180
+ const suffix = detectSuffix(i)
181
+ if (suffix) {
182
+ i += suffix.length // Move past the suffix
183
+ }
184
+
173
185
  if (formattedReference.length > 0) {
174
186
  this.found.push({
175
187
  book: foundBook,
176
- reference: formattedReference, // Store the formatted reference
188
+ reference: formattedReference, // Store only the chapter/verse
177
189
  index: foundIndex,
190
+ version: suffix || null, // Store the version (LXX, MT) if found, otherwise null
178
191
  })
179
192
  } else {
180
193
  this.found.push({
181
194
  book: foundBook,
182
195
  reference: null,
183
196
  index: foundIndex,
197
+ version: suffix || null, // Store the version (LXX, MT) if found, otherwise null
184
198
  })
185
199
  }
186
200
  } else {
@@ -207,6 +221,7 @@ class CodexParser {
207
221
  type: null, // Set type based on reference
208
222
  testament: this.bible.old.find((bible) => bible === book) ? "old" : "new",
209
223
  index: passage.index,
224
+ version: this._handleVersion(passage.version),
210
225
  }
211
226
 
212
227
  // Split reference by commas to handle multiple ranges or verses (e.g., "Ge 27:27-29,39-41")
@@ -445,6 +460,27 @@ class CodexParser {
445
460
  },
446
461
  }
447
462
  }
463
+ return true
464
+ }
465
+ _handleVersion(version) {
466
+ if (!version) {
467
+ return null
468
+ }
469
+ if (version.toLowerCase() === "lxx") {
470
+ return {
471
+ name: "Septuagint",
472
+ value: "LXX",
473
+ abbreviation: "lxx",
474
+ }
475
+ }
476
+
477
+ if (version.toLowerCase() === "mt") {
478
+ return {
479
+ name: "Masoretic Text",
480
+ value: "MT",
481
+ abbreviation: "mt",
482
+ }
483
+ }
448
484
  }
449
485
  }
450
486