codexparser 0.0.2 → 0.0.3
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 -3
- package/src/regex.js +2 -2
- package/test.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexparser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
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
|
@@ -42,9 +42,9 @@ class CodexParser {
|
|
|
42
42
|
const chapter = this.found[i].replace(book[0], "").match(this.chapterRegex)
|
|
43
43
|
const passage = {
|
|
44
44
|
original: this.found[i],
|
|
45
|
-
book: book[0].charAt(0).toUpperCase() + book[0].slice(1),
|
|
46
|
-
chapter: chapter[0].replace(
|
|
47
|
-
verses: this.found[i].match(this.verseRegex)[0].replace(
|
|
45
|
+
book: this.bookify(book[0].charAt(0).toUpperCase() + book[0].slice(1)),
|
|
46
|
+
chapter: chapter[0].replace(/[:.]/, "").trim(),
|
|
47
|
+
verses: this.found[i].match(this.verseRegex)[0].replace(/[:.]/, "").trim(),
|
|
48
48
|
}
|
|
49
49
|
passage.verses = passage.verses.split(/,/).filter(Boolean)
|
|
50
50
|
passage.testament = this.bible.old.includes(passage.book) ? "old" : "new"
|
|
@@ -53,6 +53,22 @@ class CodexParser {
|
|
|
53
53
|
this.found = []
|
|
54
54
|
return this.passages
|
|
55
55
|
}
|
|
56
|
+
bookify(book) {
|
|
57
|
+
let bookified
|
|
58
|
+
bookified = this.bible.new.find(
|
|
59
|
+
(b) =>
|
|
60
|
+
b.charAt(0).toLowerCase() === book.charAt(0).toLowerCase() &&
|
|
61
|
+
b.toLowerCase().includes(book.toLowerCase())
|
|
62
|
+
)
|
|
63
|
+
if (!bookified) {
|
|
64
|
+
bookified = this.bible.old.find(
|
|
65
|
+
(b) =>
|
|
66
|
+
b.charAt(0).toLowerCase() === book.charAt(0).toLowerCase() &&
|
|
67
|
+
b.toLowerCase().includes(book.toLowerCase())
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
return bookified
|
|
71
|
+
}
|
|
56
72
|
//TODO: Need to create a bookfiy function that will convert abbreviated books into full books
|
|
57
73
|
/**
|
|
58
74
|
* Returns the passages stored in the object.
|
package/src/regex.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const bookRegex =
|
|
2
|
-
/(?:(?:[gG]
|
|
2
|
+
/(?:(?:[gG]e(?:[a-zA-Z])?|[eE]x(?:[a-zA-Z])?|[lL]e(?:[a-zA-Z])?|[nN]u(?:[a-zA-Z])?|[dD]e(?:[a-zA-Z])?|[jJ]o(?:[a-zA-Z])?|[jJ]u(?:[a-zA-Z])?|[rR]u(?:[a-zA-Z])?|1 [sS](?:[a-zA-Z])?|2 [sS](?:[a-zA-Z])?|1 [kK](?:[a-zA-Z])?|2 [kK](?:[a-zA-Z])?|1 [cC]hr(?:[a-zA-Z])?|2 [cC]hr(?:[a-zA-Z])?|[eE]z(?:[a-zA-Z])?|[nN]e(?:[a-zA-Z])?|[eE]s(?:[a-zA-Z])?|[jJ](?:[a-zA-Z])?|[pP]s(?:[a-zA-Z])?|[pP]r(?:[a-zA-Z])?|[eE]cc(?:[a-zA-Z])?|[sS]o(?:[a-zA-Z])?|[iI]s(?:[a-zA-Z])?|[jJ]e(?:[a-zA-Z])?|[lL]a(?:[a-zA-Z])?|[eE]z(?:[a-zA-Z])?|[dD](?:[a-zA-Z])?|[hH]o(?:[a-zA-Z])?|[jJ](?:[a-zA-Z])?|[aA](?:[a-zA-Z])?|[oO](?:[a-zA-Z])?|[jJ](?:[a-zA-Z])?|[mM](?:[a-zA-Z])?|[nN](?:[a-zA-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 [tT]i|2 [tT]i|[tT]it|[pP]hm|[hH]eb|[jJ]am|1 [pP]e|2 [pP]e|1 [jJ]o|2 [jJ]o|3 [jJ]o|[jJ]ud|[rR]ev))/gim
|
|
5
5
|
const chapterRegex = /(?:\s?\d+:?)/g
|
|
6
|
-
const verseRegex = /\b
|
|
6
|
+
const verseRegex = /\b[:|.]\s*?(\d+(?:,?\s*?\d+?|-|–|—\d+)*)?\d+(?!p|j|k|s|c|t)\b/g
|
|
7
7
|
const scripturesRegex = new RegExp(`(${bookRegex.source})(${chapterRegex.source})?(${verseRegex.source})`, "gm")
|
|
8
8
|
const abbrScripturesRegex = new RegExp(`(${bookAbbrRegex.source})(${chapterRegex.source})?(${verseRegex.source})`, "gm")
|
|
9
9
|
|
package/test.js
CHANGED
|
@@ -3,7 +3,7 @@ const CodexParser = require("./src/CodexParser.js")
|
|
|
3
3
|
const parser = new CodexParser()
|
|
4
4
|
const text =
|
|
5
5
|
"The passages that we are looking at tonight are found in 1 John 3:16-17, 1 Peter 1:1, and Romans 10:13, 15, 17. Please turn in your Bibles."
|
|
6
|
-
const single = "
|
|
7
|
-
parser.parse(
|
|
6
|
+
const single = "Ju 2.9"
|
|
7
|
+
parser.parse(single)
|
|
8
8
|
//parser.parse(single)
|
|
9
9
|
console.log(parser.getPassages())
|