codexparser 0.0.65 → 0.0.68

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.
@@ -9,14 +9,11 @@ const parser = new CodexParser({
9
9
  invalid_sequence_strategy: "include",
10
10
  invalid_passage_strategy: "include",
11
11
  })
12
- const text =
13
- "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"
12
+ const text = `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`
14
13
  const single = "Ge 27.27-29,89-40 Heb 11.20 Heb. 12.17 Jonah 3"
15
14
  const jd = "Jd. 5"
16
15
  const cor = "1 Cor 12:4 2 Cor 3:4"
17
16
  const noSpace = "Re13.8 "
18
17
  const ezra = " Ez 1:3"
19
18
  const passages = parser.parse(text + single + jd + cor + noSpace + ezra)
20
- passages.getPassages().forEach((passage) => {
21
- dump(passage)
22
- })
19
+ dump(passages.getPassages())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.0.65",
3
+ "version": "0.0.68",
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": {
@@ -89,63 +89,53 @@ class CodexParser {
89
89
  }
90
90
  this.passages = []
91
91
  this.scan(reference)
92
- const books = []
93
92
  for (let i = 0; i < this.found.length; i++) {
94
- books.push(this.found[i].start.b)
95
- }
96
- const uniqueBooks = [...new Set(books)]
97
-
98
- const booksWithResults = []
99
- for (const book of uniqueBooks) {
100
- const found = this.found.filter((passage) => passage.start.b === book)
101
- booksWithResults.push(found)
102
- }
103
-
104
- for (let i = 0; i < booksWithResults.length; i++) {
105
- const results = booksWithResults[i]
106
- for (let j = 0; j < results.length; j++) {
107
- const result = results[j]
108
-
109
- const passage = {
110
- book: this.bookify(result.start.b),
111
- chapter: result.start.c,
112
- verses: this.versify(result),
113
- type: result.type,
114
- }
115
- passage.testament = this.bible.old.includes(passage.book) ? "old" : "new"
116
- let next = results[j + 1]
117
- while (next && next.type === "integer" && next.end.c === result.start.c) {
93
+ const result = this.found[i]
94
+ const passage = {
95
+ book: this.bookify(result.start.b),
96
+ chapter: result.start.c,
97
+ verses: this.versify(result),
98
+ type: result.type,
99
+ }
100
+ passage.testament = this.bible.old.includes(passage.book) ? "old" : "new"
101
+ let next = this.found[i + 1]
102
+ if (next && next.type === "integer" && next.start.b === result.end.b && next.end.c === result.start.c) {
103
+ while (
104
+ next &&
105
+ next.type === "integer" &&
106
+ next.start.b === result.end.b &&
107
+ next.end.c === result.start.c
108
+ ) {
118
109
  passage.verses.push(next.start.v)
119
110
  if (next.end.v !== next.start.v) passage.verses.push(next.end.v)
120
111
  passage.subType = next.type
121
- j++
122
- next = results[j + 1]
112
+ i++
113
+ next = this.found[i + 1]
123
114
  }
124
- if (passage.type === "range") {
125
- if (result.start.c !== result.end.c) {
126
- passage.verses = [result.start.v]
127
- passage.to = {
128
- book: this.bookify(result.end.b),
129
- chapter: result.end.c,
130
- verses: result.end.v,
131
- }
115
+ }
116
+ if (passage.type === "range") {
117
+ if (result.start.c !== result.end.c) {
118
+ passage.verses = [result.start.v]
119
+ passage.to = {
120
+ book: this.bookify(result.end.b),
121
+ chapter: result.end.c,
122
+ verses: result.end.v,
132
123
  }
133
124
  }
134
- passage.original = result.osis
135
- passage.scripture = this.scripturize(passage)
136
- passage.indices = result.indices
137
- passage.entities = result.entities
138
- if (passage.entities[0].translations) {
139
- passage.version = {
140
- name: passage.entities[0].translations[0].translation,
141
- alias: passage.entities[0].translations[0].alias,
142
- abbreviation: passage.entities[0].translations[0].osis
143
- }
125
+ }
126
+ passage.original = result.osis
127
+ passage.scripture = this.scripturize(passage)
128
+ passage.indices = result.indices
129
+ passage.entities = result.entities
130
+ if (passage.entities[0].translations) {
131
+ passage.version = {
132
+ name: passage.entities[0].translations[0].translation,
133
+ alias: passage.entities[0].translations[0].alias,
134
+ abbreviation: passage.entities[0].translations[0].osis,
144
135
  }
145
- this.passages.push(passage)
146
136
  }
137
+ this.passages.push(passage)
147
138
  }
148
- this.passages.sort((a, b) => a.chapter - b.chapter)
149
139
  this.found = []
150
140
  return this
151
141
  }
@@ -11,5 +11,5 @@ parser.options({
11
11
  invalid_sequence_strategy: "include",
12
12
  single_chapter_1_strategy: "verse",
13
13
  })
14
- const result = parser.parse("Lk 1.47 2 Cor 7.6")
14
+ const result = parser.parse("Ex 9.16 LXX")
15
15
  dump(result.getPassages())