codexparser 0.1.9 → 0.1.11
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 +1 -1
- package/src/CodexParser.js +32 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
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/src/CodexParser.js
CHANGED
|
@@ -168,47 +168,60 @@ class CodexParser {
|
|
|
168
168
|
if (foundBook !== null) {
|
|
169
169
|
i += matchedLength // Skip ahead by the length of the found book
|
|
170
170
|
let chapterVerse = ""
|
|
171
|
+
const references = []
|
|
171
172
|
|
|
173
|
+
// Loop to find all chapter and verse references in the current book
|
|
172
174
|
while (i < text.length && isValidChapterVerseChar(text[i])) {
|
|
173
175
|
// Look ahead to see if the next characters form a new Bible book
|
|
174
176
|
if (isNextBibleBook(i)) {
|
|
175
|
-
// Stop adding to chapterVerse if a new Bible book is found
|
|
176
|
-
|
|
177
|
+
break // Stop adding to chapterVerse if a new Bible book is found
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// If we hit a semicolon, it means a new reference starts
|
|
181
|
+
if (text[i] === ";" || text[i] === " ") {
|
|
182
|
+
const formattedReference = chapterVerse
|
|
183
|
+
.trim()
|
|
184
|
+
.replace(/\./g, ":")
|
|
185
|
+
.replace(/[^a-zA-Z0-9]+$/, "")
|
|
186
|
+
if (formattedReference.length > 0) {
|
|
187
|
+
references.push(formattedReference) // Add the current reference to the list
|
|
188
|
+
}
|
|
189
|
+
chapterVerse = "" // Reset for the next reference
|
|
190
|
+
i++
|
|
191
|
+
continue
|
|
177
192
|
}
|
|
178
193
|
|
|
179
194
|
chapterVerse += text[i]
|
|
180
195
|
i++
|
|
181
196
|
}
|
|
182
197
|
|
|
183
|
-
//
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
198
|
+
// Process the last found chapter and verse (if any)
|
|
199
|
+
if (chapterVerse.trim().length > 0) {
|
|
200
|
+
const formattedReference = chapterVerse
|
|
201
|
+
.trim()
|
|
202
|
+
.replace(/\./g, ":")
|
|
203
|
+
.replace(/[^a-zA-Z0-9]+$/, "")
|
|
204
|
+
if (formattedReference.length > 0) {
|
|
205
|
+
references.push(formattedReference)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
188
208
|
|
|
189
209
|
// Detect if a suffix (LXX or MT) exists after the chapter/verse
|
|
190
210
|
const suffix = detectSuffix(i)
|
|
191
211
|
|
|
192
|
-
|
|
212
|
+
// Add each reference as a separate object
|
|
213
|
+
references.forEach((ref) => {
|
|
193
214
|
this.found.push({
|
|
194
215
|
book: foundBook,
|
|
195
|
-
reference:
|
|
216
|
+
reference: ref,
|
|
196
217
|
index: foundIndex,
|
|
197
|
-
version: suffix || null,
|
|
218
|
+
version: suffix || null,
|
|
198
219
|
})
|
|
199
|
-
}
|
|
200
|
-
this.found.push({
|
|
201
|
-
book: foundBook,
|
|
202
|
-
reference: null,
|
|
203
|
-
index: foundIndex,
|
|
204
|
-
version: suffix || null, // Store the version (LXX, MT) if found, otherwise null
|
|
205
|
-
})
|
|
206
|
-
}
|
|
220
|
+
})
|
|
207
221
|
} else {
|
|
208
222
|
i++
|
|
209
223
|
}
|
|
210
224
|
}
|
|
211
|
-
|
|
212
225
|
return this // Return this instance for method chaining
|
|
213
226
|
}
|
|
214
227
|
|