codexparser 0.0.46 → 0.0.47
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/all-scripture-test.js +17 -8
- package/chapter-range-test.js +5 -0
- package/package.json +1 -1
- package/src/CodexParser.js +2 -2
- package/src/regex.js +1 -1
package/all-scripture-test.js
CHANGED
|
@@ -2,12 +2,21 @@ const CodexParser = require("./src/CodexParser.js")
|
|
|
2
2
|
|
|
3
3
|
const parser = new CodexParser()
|
|
4
4
|
const text =
|
|
5
|
-
"Joel 10:13 The passages Luke 2:32 and Lk 1:23 that we are looking at tonight 1 Cor 12:34 2 Cor 3:4 are found Jude 6, in Jude 5, Genesis 2:1 - 3:19, 1 John 3:16-17,
|
|
6
|
-
const single = "Ge 27.27-29,
|
|
5
|
+
"Joel 10:13 The passages Luke 2:32 and Lk 1:23 that we are looking at tonight 1 Cor 12:34 2 Cor 3:4 are found Jude 6, in Jude 5, Genesis 2:1 - 3:19, 1 John 3:16-17, 1 Peter 1:1, and Romans 10:13, 15, 17. Please turn in your Bibles. Ps 109:4,5,6,8. Isaiah 61.2-3 Mt 5.4"
|
|
6
|
+
const single = "Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3"
|
|
7
7
|
const jd = "Jd. 5"
|
|
8
|
-
const cor = "
|
|
9
|
-
const
|
|
10
|
-
passages.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const cor = "1 Cor 12:34 2 Cor 3:4"
|
|
9
|
+
const noSpace = 'Re13.8'
|
|
10
|
+
const passages = parser.parse(single)
|
|
11
|
+
console.log(passages)
|
|
12
|
+
|
|
13
|
+
const jude = parser.parse(jd)
|
|
14
|
+
console.log(jude)
|
|
15
|
+
const textParser = parser.parse(cor)
|
|
16
|
+
console.log(textParser)
|
|
17
|
+
|
|
18
|
+
const fullText = parser.parse(text)
|
|
19
|
+
console.log(fullText)
|
|
20
|
+
|
|
21
|
+
const noSpaceText = parser.parse(noSpace)
|
|
22
|
+
console.log(noSpaceText)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47",
|
|
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
|
@@ -80,7 +80,7 @@ class CodexParser {
|
|
|
80
80
|
const found = this.found.filter((passage) => passage.start.b === book)
|
|
81
81
|
booksWithResults.push(found)
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
console.log(booksWithResults[0][0])
|
|
84
84
|
for (let i = 0; i < booksWithResults.length; i++) {
|
|
85
85
|
const initialPassage = booksWithResults[i].shift()
|
|
86
86
|
const shouldBeRange = initialPassage.osis.match(/[-–—]/)
|
|
@@ -102,7 +102,7 @@ class CodexParser {
|
|
|
102
102
|
firstPassage.to = {
|
|
103
103
|
book: this.bookify(initialPassage.end.b),
|
|
104
104
|
chapter: initialPassage.end.c,
|
|
105
|
-
verses: [initialPassage.
|
|
105
|
+
verses: [initialPassage.end.v],
|
|
106
106
|
}
|
|
107
107
|
} else {
|
|
108
108
|
firstPassage.verses = [initialPassage.start.v + "-" + initialPassage.end.v]
|
package/src/regex.js
CHANGED
|
@@ -4,7 +4,7 @@ const verseRegex = /\b[:.].+\b/gm
|
|
|
4
4
|
const chapterRange = /.?\s?(?:[-—–])\s?/gm
|
|
5
5
|
const chapterRangeVerseRegex = /(?:.\d+)?/gm
|
|
6
6
|
const chapterVerseRange =
|
|
7
|
-
/.?\s
|
|
7
|
+
/.?\s?\d+((?:[:.]\d+)?(\s?[-–—]\s?)?(?:\d+)(?:(,\s?\d+)*)?\S([:.]?\d+)?(,\s?\d+[–—-]\s?\d+)?)?(?:[:.]\d+)?(?:[abcde])?(?:,\d+)*(?:[-–—]\d?\s?)?/gim
|
|
8
8
|
const scripturesRegex = new RegExp(`(${bookRegex.source})(${chapterVerseRange.source})`, "gmi")
|
|
9
9
|
module.exports.bookRegex = bookRegex
|
|
10
10
|
module.exports.chapterRegex = chapterRegex
|