codexparser 0.1.5 → 0.1.7
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 +19 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
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
|
@@ -134,20 +134,30 @@ class CodexParser {
|
|
|
134
134
|
isBoundaryOrNonAlphabetic(i - 1, lowerCaseText) &&
|
|
135
135
|
isBoundaryOrNonAlphabetic(i + abbreviationWithDot.length, lowerCaseText)
|
|
136
136
|
) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
// Look ahead to check if a number or space + number follows the abbreviation
|
|
138
|
+
const afterAbbreviation = lowerCaseText.substring(i + abbreviationWithDot.length).trim()
|
|
139
|
+
if (/^\d+/.test(afterAbbreviation)) {
|
|
140
|
+
// Check if there is a number (chapter/verse)
|
|
141
|
+
foundBook = abbreviations[k] // Store the abbreviation without the dot
|
|
142
|
+
foundIndex = i // Record the index where the abbreviation is found
|
|
143
|
+
matchedLength = abbreviationWithDot.length // Update the length of the match to include the dot
|
|
144
|
+
break // Exit once found
|
|
145
|
+
}
|
|
141
146
|
}
|
|
142
147
|
} else if (lowerCaseText.startsWith(abbreviation, i)) {
|
|
143
148
|
if (
|
|
144
149
|
isBoundaryOrNonAlphabetic(i - 1, lowerCaseText) &&
|
|
145
150
|
isBoundaryOrNonAlphabetic(i + abbreviation.length, lowerCaseText)
|
|
146
151
|
) {
|
|
147
|
-
if
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
// Look ahead to check if a number or space + number follows the abbreviation
|
|
153
|
+
const afterAbbreviation = lowerCaseText.substring(i + abbreviation.length).trim()
|
|
154
|
+
if (/^\d+/.test(afterAbbreviation)) {
|
|
155
|
+
// Check if there is a number (chapter/verse)
|
|
156
|
+
if (abbreviation.length > matchedLength) {
|
|
157
|
+
foundBook = abbreviations[k] // Store the abbreviation without the dot
|
|
158
|
+
foundIndex = i // Record the index where the abbreviation is found
|
|
159
|
+
matchedLength = abbreviation.length // Update the length of the match
|
|
160
|
+
}
|
|
151
161
|
}
|
|
152
162
|
}
|
|
153
163
|
}
|
|
@@ -178,9 +188,6 @@ class CodexParser {
|
|
|
178
188
|
|
|
179
189
|
// Detect if a suffix (LXX or MT) exists after the chapter/verse
|
|
180
190
|
const suffix = detectSuffix(i)
|
|
181
|
-
if (suffix) {
|
|
182
|
-
i += suffix.length // Move past the suffix
|
|
183
|
-
}
|
|
184
191
|
|
|
185
192
|
if (formattedReference.length > 0) {
|
|
186
193
|
this.found.push({
|
|
@@ -210,7 +217,7 @@ class CodexParser {
|
|
|
210
217
|
|
|
211
218
|
this.passages = this.found.map((passage) => {
|
|
212
219
|
const book = this.bookify(passage.book)
|
|
213
|
-
|
|
220
|
+
dump(passage)
|
|
214
221
|
// Initialize the parsed passage object
|
|
215
222
|
const parsedPassage = {
|
|
216
223
|
original: passage.book + " " + passage.reference,
|