codexparser 0.1.85 → 0.1.87
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/.trunk/trunk.yaml +2 -2
- package/package.json +1 -1
- package/src/CodexParser.js +16 -53
- package/src/versifications/numbers.js +15 -0
package/.trunk/trunk.yaml
CHANGED
|
@@ -17,11 +17,11 @@ runtimes:
|
|
|
17
17
|
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
|
|
18
18
|
lint:
|
|
19
19
|
enabled:
|
|
20
|
-
- checkov@3.2.
|
|
20
|
+
- checkov@3.2.451
|
|
21
21
|
- git-diff-check
|
|
22
22
|
- markdownlint@0.45.0
|
|
23
23
|
- osv-scanner@2.0.3
|
|
24
|
-
- prettier@3.6.
|
|
24
|
+
- prettier@3.6.2
|
|
25
25
|
- trufflehog@3.89.2
|
|
26
26
|
actions:
|
|
27
27
|
disabled:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.87",
|
|
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
|
@@ -24,28 +24,26 @@ class CodexParser {
|
|
|
24
24
|
* Initializes the parser with default properties and data.
|
|
25
25
|
*/
|
|
26
26
|
constructor(config = {}) {
|
|
27
|
-
this.found = []
|
|
28
|
-
this.passages = []
|
|
29
|
-
this.bible = bible
|
|
30
|
-
this.bookRegex = bookRegex
|
|
31
|
-
this.chapterRegex = chapterRegex
|
|
32
|
-
this.verseRegex = verseRegex
|
|
33
|
-
this.scripturesRegex = scripturesRegex
|
|
34
|
-
this.abbreviations = abbreviations
|
|
35
|
-
this.sblAbbreviations = sblAbbreviations
|
|
36
|
-
this.versificationDifferences = versified
|
|
27
|
+
this.found = []
|
|
28
|
+
this.passages = []
|
|
29
|
+
this.bible = bible
|
|
30
|
+
this.bookRegex = bookRegex
|
|
31
|
+
this.chapterRegex = chapterRegex
|
|
32
|
+
this.verseRegex = verseRegex
|
|
33
|
+
this.scripturesRegex = scripturesRegex
|
|
34
|
+
this.abbreviations = abbreviations
|
|
35
|
+
this.sblAbbreviations = sblAbbreviations
|
|
36
|
+
this.versificationDifferences = versified
|
|
37
37
|
this.singleChapterBook = [
|
|
38
|
-
// Books with a single chapter and their verse counts
|
|
39
38
|
sch("Jude", 25),
|
|
40
39
|
sch("2 John", 13),
|
|
41
40
|
sch("3 John", 15),
|
|
42
41
|
sch("Obadiah", 21),
|
|
43
42
|
sch("Philemon", 25),
|
|
44
43
|
]
|
|
45
|
-
this.chapterVerses = chapter_verses
|
|
46
|
-
this.error = false
|
|
47
|
-
this.version = null
|
|
48
|
-
// Reference type constants
|
|
44
|
+
this.chapterVerses = chapter_verses
|
|
45
|
+
this.error = false
|
|
46
|
+
this.version = null
|
|
49
47
|
this.SINGLE_CHAPTER = "single_chapter"
|
|
50
48
|
this.CHAPTER_VERSE = "chapter_verse"
|
|
51
49
|
this.CHAPTER_VERSE_RANGE = "chapter_verse_range"
|
|
@@ -96,8 +94,6 @@ class CodexParser {
|
|
|
96
94
|
this.found = []
|
|
97
95
|
// Minimal normalization: fix periods before numbers, remove trailing periods
|
|
98
96
|
let normalizedText = text.replace(/\.(?=\d)/g, ":").replace(/(\b[A-Za-z]+)\.(?=\s|$)/g, "$1")
|
|
99
|
-
console.log(`Input text: ${text}`)
|
|
100
|
-
console.log(`Normalized text: ${normalizedText}`)
|
|
101
97
|
const lowercaseBibleFullNames = fullNames.map((book) => book.toLowerCase())
|
|
102
98
|
const lowercaseBibleAbbreviations = abbreviations.map((abbr) => abbr.toLowerCase())
|
|
103
99
|
const lowerCaseText = normalizedText.toLowerCase()
|
|
@@ -127,8 +123,6 @@ class CodexParser {
|
|
|
127
123
|
}
|
|
128
124
|
if (i >= lowerCaseText.length) break
|
|
129
125
|
|
|
130
|
-
console.log(`Scanning at index ${i}: ${lowerCaseText.slice(i, i + 10)}...`)
|
|
131
|
-
|
|
132
126
|
for (let j = 0; j < lowercaseBibleFullNames.length; j++) {
|
|
133
127
|
const book = lowercaseBibleFullNames[j]
|
|
134
128
|
if (lowerCaseText.startsWith(book, i) && book.length > matchedLength) {
|
|
@@ -150,16 +144,14 @@ class CodexParser {
|
|
|
150
144
|
}
|
|
151
145
|
|
|
152
146
|
if (foundBook) {
|
|
153
|
-
console.log(`Found book: ${foundBook} at index ${bookStartIndex}, length ${matchedLength}`)
|
|
154
147
|
i += matchedLength
|
|
155
148
|
let chapterVerse = ""
|
|
156
149
|
const references = []
|
|
157
|
-
let refStartIndex = bookStartIndex
|
|
158
|
-
let originalRefStartIndex = bookStartIndex
|
|
150
|
+
let refStartIndex = bookStartIndex
|
|
151
|
+
let originalRefStartIndex = bookStartIndex
|
|
159
152
|
|
|
160
153
|
while (i < normalizedText.length && isValidChapterVerseChar(normalizedText[i])) {
|
|
161
154
|
if (isNextBibleBook(i)) {
|
|
162
|
-
console.log(`Next book detected at index ${i}, stopping reference parsing`)
|
|
163
155
|
break
|
|
164
156
|
}
|
|
165
157
|
if (normalizedText[i] === ";") {
|
|
@@ -171,9 +163,6 @@ class CodexParser {
|
|
|
171
163
|
start: refStartIndex,
|
|
172
164
|
end: refEndIndex,
|
|
173
165
|
})
|
|
174
|
-
console.log(
|
|
175
|
-
`Reference found: ${formattedReference}, normalized indices ${refStartIndex}-${refEndIndex}`
|
|
176
|
-
)
|
|
177
166
|
}
|
|
178
167
|
chapterVerse = ""
|
|
179
168
|
refStartIndex = i + 1
|
|
@@ -195,9 +184,6 @@ class CodexParser {
|
|
|
195
184
|
start: refStartIndex,
|
|
196
185
|
end: refEndIndex,
|
|
197
186
|
})
|
|
198
|
-
console.log(
|
|
199
|
-
`Final reference found: ${formattedReference}, normalized indices ${refStartIndex}-${refEndIndex}`
|
|
200
|
-
)
|
|
201
187
|
}
|
|
202
188
|
}
|
|
203
189
|
|
|
@@ -207,9 +193,8 @@ class CodexParser {
|
|
|
207
193
|
text.indexOf(originalBookText, bookStartIndex) !== -1
|
|
208
194
|
? text.indexOf(originalBookText, bookStartIndex)
|
|
209
195
|
: bookStartIndex
|
|
210
|
-
console.log(`Original book text: ${originalBookText}, original start index: ${originalBookStartIndex}`)
|
|
211
196
|
|
|
212
|
-
references.forEach(({ ref, start, end }
|
|
197
|
+
references.forEach(({ ref, start, end }) => {
|
|
213
198
|
let type
|
|
214
199
|
if (ref.includes(":")) {
|
|
215
200
|
if (ref.includes("-")) {
|
|
@@ -248,9 +233,6 @@ class CodexParser {
|
|
|
248
233
|
text.indexOf(fullRefText, originalRefStartIndex) !== -1
|
|
249
234
|
? text.indexOf(fullRefText, originalRefStartIndex)
|
|
250
235
|
: originalBookStartIndex
|
|
251
|
-
console.log(
|
|
252
|
-
`Searching for fullRefText: ${fullRefText} at index ${originalRefStartIndex}, found at ${originalStartIndex}`
|
|
253
|
-
)
|
|
254
236
|
|
|
255
237
|
let originalEndIndex = originalStartIndex + fullRefText.length
|
|
256
238
|
let originalText = text.slice(originalStartIndex, originalEndIndex)
|
|
@@ -267,14 +249,6 @@ class CodexParser {
|
|
|
267
249
|
originalText = text.slice(originalStartIndex, originalEndIndex)
|
|
268
250
|
}
|
|
269
251
|
|
|
270
|
-
console.log(
|
|
271
|
-
`Reference ${
|
|
272
|
-
refIndex + 1
|
|
273
|
-
}: ${originalText}, original indices ${originalStartIndex}-${originalEndIndex}, type: ${type}, suffix: ${
|
|
274
|
-
suffix || "none"
|
|
275
|
-
}, search text: ${fullRefText}`
|
|
276
|
-
)
|
|
277
|
-
|
|
278
252
|
this.found.push({
|
|
279
253
|
book: foundBook,
|
|
280
254
|
reference: ref,
|
|
@@ -290,7 +264,6 @@ class CodexParser {
|
|
|
290
264
|
}
|
|
291
265
|
}
|
|
292
266
|
|
|
293
|
-
console.log(`Found references: ${JSON.stringify(this.found, null, 2)}`)
|
|
294
267
|
return this
|
|
295
268
|
}
|
|
296
269
|
|
|
@@ -340,7 +313,6 @@ class CodexParser {
|
|
|
340
313
|
|
|
341
314
|
// Clean reference for parsing
|
|
342
315
|
let cleanReference = passage.reference.replace(/\s*(LXX|MT)$/i, "").trim()
|
|
343
|
-
console.log(`Parsing reference: ${cleanReference}, type: ${passage.type}`)
|
|
344
316
|
if (cleanReference.endsWith(",")) {
|
|
345
317
|
cleanReference = cleanReference.slice(0, -1).trim()
|
|
346
318
|
}
|
|
@@ -348,7 +320,6 @@ class CodexParser {
|
|
|
348
320
|
// Handle book-only or empty references
|
|
349
321
|
if (!cleanReference && this.config.booksOnly) {
|
|
350
322
|
parsedPassage.type = "book_only"
|
|
351
|
-
console.log(`Book-only reference: ${book}`)
|
|
352
323
|
} else if (!cleanReference || cleanReference.match(/^\d+\s*[:;]?\s*$/)) {
|
|
353
324
|
const chapterMatch = cleanReference.match(/\d+/) || ["1"]
|
|
354
325
|
const chapter = Number(chapterMatch[0])
|
|
@@ -360,18 +331,13 @@ class CodexParser {
|
|
|
360
331
|
const endVerse = chapterVerses[chapterVerses.length - 1]
|
|
361
332
|
parsedPassage.verses = [`${startVerse}-${endVerse}`]
|
|
362
333
|
}
|
|
363
|
-
console.log(`Single chapter: ${chapter}, verses: ${parsedPassage.verses}`)
|
|
364
334
|
} else if (passage.type === "comma_separated_verses") {
|
|
365
335
|
// Handle comma-separated verses (e.g., "1:7,18")
|
|
366
336
|
const [chapter, verses] = cleanReference.split(":")
|
|
367
337
|
parsedPassage.chapter = Number(chapter)
|
|
368
338
|
parsedPassage.verses = verses.split(",").map((v) => v.trim())
|
|
369
|
-
console.log(`Comma-separated verses: chapter ${chapter}, verses ${parsedPassage.verses}`)
|
|
370
339
|
} else {
|
|
371
340
|
this.parseReferenceParts(parsedPassage, cleanReference)
|
|
372
|
-
console.log(
|
|
373
|
-
`Parsed with parseReferenceParts: chapter ${parsedPassage.chapter}, verses ${parsedPassage.verses}`
|
|
374
|
-
)
|
|
375
341
|
}
|
|
376
342
|
|
|
377
343
|
parsedPassage.passages = this.populate(parsedPassage)
|
|
@@ -391,7 +357,6 @@ class CodexParser {
|
|
|
391
357
|
} else {
|
|
392
358
|
parsedPassage.abbr = parsedPassage.original
|
|
393
359
|
}
|
|
394
|
-
console.log(`Abbreviation set: ${parsedPassage.abbr}`)
|
|
395
360
|
|
|
396
361
|
if (parsedPassage.type === this.MULTI_CHAPTER_RANGE) {
|
|
397
362
|
this.handleMultiChapterRange(parsedPassage, cleanReference)
|
|
@@ -417,7 +382,6 @@ class CodexParser {
|
|
|
417
382
|
chapter: lastPassage.chapter,
|
|
418
383
|
verse: lastPassage.verse,
|
|
419
384
|
}
|
|
420
|
-
console.log(`Start: ${JSON.stringify(parsedPassage.start)}, End: ${JSON.stringify(parsedPassage.end)}`)
|
|
421
385
|
}
|
|
422
386
|
|
|
423
387
|
if (!parsedPassage.version) {
|
|
@@ -432,7 +396,6 @@ class CodexParser {
|
|
|
432
396
|
})
|
|
433
397
|
|
|
434
398
|
this.versification()
|
|
435
|
-
console.log(`Final passages: ${JSON.stringify(this.passages, null, 2)}`)
|
|
436
399
|
return this
|
|
437
400
|
}
|
|
438
401
|
/**
|
|
@@ -69,6 +69,21 @@ module.exports = {
|
|
|
69
69
|
mt: "1:25",
|
|
70
70
|
eng: "1:25",
|
|
71
71
|
},
|
|
72
|
+
"6:24": {
|
|
73
|
+
lxx: "6:25",
|
|
74
|
+
mt: "6:24",
|
|
75
|
+
eng: "6:24",
|
|
76
|
+
},
|
|
77
|
+
"6:25": {
|
|
78
|
+
lxx: "6:26",
|
|
79
|
+
mt: "6:25",
|
|
80
|
+
eng: "6:25",
|
|
81
|
+
},
|
|
82
|
+
"6:26": {
|
|
83
|
+
lxx: "6:27",
|
|
84
|
+
mt: "6:26",
|
|
85
|
+
eng: "6:26",
|
|
86
|
+
},
|
|
72
87
|
"16:36": {
|
|
73
88
|
lxx: "17:1",
|
|
74
89
|
mt: "17:1",
|