codexparser 0.1.31 → 0.1.33
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 +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
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
|
@@ -231,6 +231,8 @@ class CodexParser {
|
|
|
231
231
|
this.scan(reference) // Call scan to populate this.found
|
|
232
232
|
|
|
233
233
|
this.passages = this.found.map((passage) => {
|
|
234
|
+
passage.reference =
|
|
235
|
+
passage.reference.match(/[:]/g)?.length > 1 ? passage.reference.replace(/[:]/, "") : passage.reference
|
|
234
236
|
const book = this.bookify(passage.book)
|
|
235
237
|
const testament = this.bible.old.find((bible) => bible === book) ? "old" : "new"
|
|
236
238
|
// Initialize the parsed passage object
|
|
@@ -617,6 +619,14 @@ class CodexParser {
|
|
|
617
619
|
})
|
|
618
620
|
})
|
|
619
621
|
|
|
622
|
+
// Sort the newObject.passages array by chapter first, then by verse
|
|
623
|
+
newObject.passages.sort((a, b) => {
|
|
624
|
+
if (a.chapter !== b.chapter) {
|
|
625
|
+
return a.chapter - b.chapter // Sort by chapter
|
|
626
|
+
}
|
|
627
|
+
return a.verse - b.verse // Sort by verse within the same chapter
|
|
628
|
+
})
|
|
629
|
+
|
|
620
630
|
// Prepare to build the final result
|
|
621
631
|
const chapterStrings = []
|
|
622
632
|
let firstChapter = null
|