codexparser 0.1.13 → 0.1.14

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.13",
3
+ "version": "0.1.14",
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": {
@@ -137,6 +137,7 @@ class CodexParser {
137
137
  // Look ahead to check if a number or space + number follows the abbreviation
138
138
  const afterAbbreviation = lowerCaseText.substring(i + abbreviationWithDot.length).trim()
139
139
  if (/^\d+/.test(afterAbbreviation)) {
140
+ // Check if there is a number (chapter/verse)
140
141
  foundBook = abbreviations[k] // Store the abbreviation without the dot
141
142
  foundIndex = i // Record the index where the abbreviation is found
142
143
  matchedLength = abbreviationWithDot.length // Update the length of the match to include the dot
@@ -151,6 +152,7 @@ class CodexParser {
151
152
  // Look ahead to check if a number or space + number follows the abbreviation
152
153
  const afterAbbreviation = lowerCaseText.substring(i + abbreviation.length).trim()
153
154
  if (/^\d+/.test(afterAbbreviation)) {
155
+ // Check if there is a number (chapter/verse)
154
156
  if (abbreviation.length > matchedLength) {
155
157
  foundBook = abbreviations[k] // Store the abbreviation without the dot
156
158
  foundIndex = i // Record the index where the abbreviation is found
@@ -168,11 +170,6 @@ class CodexParser {
168
170
  let chapterVerse = ""
169
171
  const references = []
170
172
 
171
- // Function to decide if we should split the reference (based on finding a colon with space or semicolon)
172
- const shouldSplitReference = (nextChar) => {
173
- return nextChar === ":" && text[i - 1] === " " // Split if a space is found with a colon
174
- }
175
-
176
173
  // Loop to find all chapter and verse references in the current book
177
174
  while (i < text.length && isValidChapterVerseChar(text[i])) {
178
175
  // Look ahead to see if the next characters form a new Bible book
@@ -180,8 +177,9 @@ class CodexParser {
180
177
  break // Stop adding to chapterVerse if a new Bible book is found
181
178
  }
182
179
 
183
- // If we hit a semicolon or space with a new reference, process the current reference
184
- if (text[i] === ";" || shouldSplitReference(text[i + 1])) {
180
+ // If we hit a semicolon, it means a new reference starts
181
+ // || text[i] === " "
182
+ if (text[i] === ";") {
185
183
  const formattedReference = chapterVerse
186
184
  .trim()
187
185
  .replace(/\./g, ":")
@@ -225,6 +223,7 @@ class CodexParser {
225
223
  i++
226
224
  }
227
225
  }
226
+ dd(this.found)
228
227
  return this // Return this instance for method chaining
229
228
  }
230
229
 
@@ -492,7 +491,7 @@ class CodexParser {
492
491
  },
493
492
  }
494
493
  }
495
-
494
+ dd(passage.verses)
496
495
  return true
497
496
  }
498
497
  _handleVersion(version) {