node-sword-interface 1.0.9 → 1.0.11
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/API.md +22 -8
- package/CMakeLists.txt +1 -6
- package/README.md +2 -3
- package/binding.gyp +1 -2
- package/index.js +20 -8
- package/package.json +1 -1
- package/scripts/build_sword.sh +3 -1
- package/src/napi_module/napi_sword_helper.cpp +7 -1
- package/src/napi_module/napi_sword_helper.hpp +1 -1
- package/src/napi_module/node_sword_interface.cpp +20 -0
- package/src/napi_module/node_sword_interface.hpp +1 -0
- package/src/sword_backend/common_defs.hpp +1 -0
- package/src/sword_backend/repository_interface.hpp +3 -0
- package/src/sword_backend/text_processor.cpp +29 -0
- package/src/sword_backend/text_processor.hpp +1 -0
package/API.md
CHANGED
|
@@ -51,6 +51,7 @@ This is the main class of node-sword-interface and it provides a set of static f
|
|
|
51
51
|
* [.getModuleDescription(moduleCode)](#NodeSwordInterface+getModuleDescription) ⇒ <code>String</code>
|
|
52
52
|
* [.enableMarkup()](#NodeSwordInterface+enableMarkup)
|
|
53
53
|
* [.getRawModuleEntry(moduleCode, key)](#NodeSwordInterface+getRawModuleEntry) ⇒ <code>String</code>
|
|
54
|
+
* [.getReferenceText(moduleCode, key)](#NodeSwordInterface+getReferenceText) ⇒ [<code>VerseObject</code>](#VerseObject)
|
|
54
55
|
* [.getChapterText(moduleCode, bookCode, chapter)](#NodeSwordInterface+getChapterText) ⇒ [<code>Array.<VerseObject></code>](#VerseObject)
|
|
55
56
|
* [.getBookText(moduleCode, bookCode, startVerseNr, verseCount)](#NodeSwordInterface+getBookText) ⇒ [<code>Array.<VerseObject></code>](#VerseObject)
|
|
56
57
|
* [.getVersesFromReferences(moduleCode, references)](#NodeSwordInterface+getVersesFromReferences) ⇒ [<code>Array.<VerseObject></code>](#VerseObject)
|
|
@@ -121,7 +122,7 @@ Note that the languages are returned as language codes.
|
|
|
121
122
|
| Param | Type | Default | Description |
|
|
122
123
|
| --- | --- | --- | --- |
|
|
123
124
|
| repositoryName | <code>String</code> | | The name of the given repository. |
|
|
124
|
-
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT) |
|
|
125
|
+
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY) |
|
|
125
126
|
|
|
126
127
|
<a name="NodeSwordInterface+getAllRepoModules"></a>
|
|
127
128
|
|
|
@@ -134,7 +135,7 @@ Returns all modules for the given repository (default: Bible modules).
|
|
|
134
135
|
| Param | Type | Default | Description |
|
|
135
136
|
| --- | --- | --- | --- |
|
|
136
137
|
| repositoryName | <code>String</code> | | The name of the given repository. |
|
|
137
|
-
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT) |
|
|
138
|
+
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY) |
|
|
138
139
|
|
|
139
140
|
<a name="NodeSwordInterface+getRepoModulesByLang"></a>
|
|
140
141
|
|
|
@@ -148,7 +149,7 @@ Returns all Bible modules for the given repository and language
|
|
|
148
149
|
| --- | --- | --- | --- |
|
|
149
150
|
| repositoryName | <code>String</code> | | The name of the given repository. |
|
|
150
151
|
| language | <code>String</code> | | The language code that shall be used as a filter. |
|
|
151
|
-
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT) |
|
|
152
|
+
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY) |
|
|
152
153
|
| headersFilter | <code>Boolean</code> | <code>false</code> | Whether only modules with Headers shall be returned. |
|
|
153
154
|
| strongsFilter | <code>Boolean</code> | <code>false</code> | Whether only modules with Strong's shall be returned. |
|
|
154
155
|
| hebrewStrongsKeys | <code>Boolean</code> | <code>false</code> | Whether only modules with Hebrew Strong's keys shall be returned (only applies to dictionaries). |
|
|
@@ -188,7 +189,7 @@ Returns all modules installed locally (default: Bible modules).
|
|
|
188
189
|
|
|
189
190
|
| Param | Type | Default | Description |
|
|
190
191
|
| --- | --- | --- | --- |
|
|
191
|
-
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT) |
|
|
192
|
+
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY) |
|
|
192
193
|
|
|
193
194
|
<a name="NodeSwordInterface+getRepoModuleCount"></a>
|
|
194
195
|
|
|
@@ -201,7 +202,7 @@ Returns the number of modules for a given repository (default: Bible modules).
|
|
|
201
202
|
| Param | Type | Default | Description |
|
|
202
203
|
| --- | --- | --- | --- |
|
|
203
204
|
| repositoryName | <code>String</code> | | The name of the given repository. |
|
|
204
|
-
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT) |
|
|
205
|
+
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY) |
|
|
205
206
|
|
|
206
207
|
<a name="NodeSwordInterface+getRepoLanguageModuleCount"></a>
|
|
207
208
|
|
|
@@ -215,7 +216,7 @@ Returns the number of modules for a given repository and language (default: Bibl
|
|
|
215
216
|
| --- | --- | --- | --- |
|
|
216
217
|
| repositoryName | <code>String</code> | | The name of the given repository. |
|
|
217
218
|
| language | <code>String</code> | | The language code that shall be used as a filter. |
|
|
218
|
-
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT) |
|
|
219
|
+
| moduleType | <code>String</code> | <code>BIBLE</code> | A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY) |
|
|
219
220
|
|
|
220
221
|
<a name="NodeSwordInterface+installModule"></a>
|
|
221
222
|
|
|
@@ -310,7 +311,7 @@ This influences the output for getChapterText, getBookText and getBibleText.
|
|
|
310
311
|
<a name="NodeSwordInterface+getRawModuleEntry"></a>
|
|
311
312
|
|
|
312
313
|
### nodeSwordInterface.getRawModuleEntry(moduleCode, key) ⇒ <code>String</code>
|
|
313
|
-
Returns the text of an entry for the given module and key.
|
|
314
|
+
Returns the raw text of an entry for the given module and key.
|
|
314
315
|
If no entry exists for the given key the return value is undefined.
|
|
315
316
|
|
|
316
317
|
**Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
|
|
@@ -320,6 +321,19 @@ If no entry exists for the given key the return value is undefined.
|
|
|
320
321
|
| moduleCode | <code>String</code> | The module code of the SWORD module. |
|
|
321
322
|
| key | <code>String</code> | The key of the entry. |
|
|
322
323
|
|
|
324
|
+
<a name="NodeSwordInterface+getReferenceText"></a>
|
|
325
|
+
|
|
326
|
+
### nodeSwordInterface.getReferenceText(moduleCode, key) ⇒ [<code>VerseObject</code>](#VerseObject)
|
|
327
|
+
Returns the text of an entry for the given module and key.
|
|
328
|
+
If no entry exists for the given key the return value is a verse with empty content.
|
|
329
|
+
|
|
330
|
+
**Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
|
|
331
|
+
|
|
332
|
+
| Param | Type | Description |
|
|
333
|
+
| --- | --- | --- |
|
|
334
|
+
| moduleCode | <code>String</code> | The module code of the SWORD module. |
|
|
335
|
+
| key | <code>String</code> | The key of the entry. |
|
|
336
|
+
|
|
323
337
|
<a name="NodeSwordInterface+getChapterText"></a>
|
|
324
338
|
|
|
325
339
|
### nodeSwordInterface.getChapterText(moduleCode, bookCode, chapter) ⇒ [<code>Array.<VerseObject></code>](#VerseObject)
|
|
@@ -614,7 +628,7 @@ An object representation of a SWORD module.
|
|
|
614
628
|
| Name | Type | Description |
|
|
615
629
|
| --- | --- | --- |
|
|
616
630
|
| name | <code>String</code> | The name/code of the SWORD module |
|
|
617
|
-
| type | <code>String</code> | The type of the SWORD module (Currently the following types are supported: Biblical Texts, Lexicons / Dictionaries) |
|
|
631
|
+
| type | <code>String</code> | The type of the SWORD module (Currently the following types are supported: Biblical Texts, Lexicons / Dictionaries, Commentaries) |
|
|
618
632
|
| description | <code>String</code> | The description of the SWORD module |
|
|
619
633
|
| language | <code>String</code> | The language code of the SWORD module |
|
|
620
634
|
| distributionLicense | <code>String</code> | The distribution license of the SWORD module |
|
package/CMakeLists.txt
CHANGED
|
@@ -14,17 +14,12 @@ include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/node_modules/no
|
|
|
14
14
|
|
|
15
15
|
link_directories(${CMAKE_SOURCE_DIR}/sword_build)
|
|
16
16
|
|
|
17
|
-
# ICU Components Reference:
|
|
18
|
-
# https://cmake.org/cmake/help/latest/module/FindICU.html
|
|
19
|
-
# ICU components = data, i18n, io, le, lx, test, tu and uc.
|
|
20
|
-
|
|
21
|
-
find_package(ICU COMPONENTS uc i18n data REQUIRED)
|
|
22
17
|
find_package(ZLIB REQUIRED)
|
|
23
18
|
find_package(CURL REQUIRED)
|
|
24
19
|
find_package(BZip2 REQUIRED)
|
|
25
20
|
|
|
26
21
|
set(SWORD_LIBRARY_NAME "libsword.a")
|
|
27
|
-
set(DEPENDENT_LIBS
|
|
22
|
+
set(DEPENDENT_LIBS ${ZLIB_LIBRARIES} ${CURL_LIBRARIES} ${BZIP2_LIBRARIES})
|
|
28
23
|
|
|
29
24
|
if (UNIX)
|
|
30
25
|
set(DEPENDENT_LIBS ${DEPENDENT_LIBS} pthread)
|
package/README.md
CHANGED
|
@@ -90,7 +90,6 @@ Before installing node-sword-interface you need to make sure that the following
|
|
|
90
90
|
- nodejs (A version that supports N-API version >= 4, like 8.16.0, 10.16.0 or 12.0.0 (see [N-API Version Matrix](https://nodejs.org/api/n-api.html#n_api_n_api_version_matrix)))
|
|
91
91
|
- Git
|
|
92
92
|
- Mac/Linux dependencies:
|
|
93
|
-
- ICU library with development headers
|
|
94
93
|
- CURL library with development headers
|
|
95
94
|
- CMake (for building the SWORD library)
|
|
96
95
|
|
|
@@ -102,14 +101,14 @@ These installation instructions are working on Debian/Ubuntu based Linux distrib
|
|
|
102
101
|
|
|
103
102
|
To install the dependencies issue the following command on a Debian/Ubuntu based distribution:
|
|
104
103
|
|
|
105
|
-
sudo apt-get install build-essential nodejs npm libcurl4-gnutls-dev
|
|
104
|
+
sudo apt-get install build-essential nodejs npm libcurl4-gnutls-dev zlib1g-dev pkg-config cmake subversion
|
|
106
105
|
|
|
107
106
|
#### Install dependencies on macOS
|
|
108
107
|
|
|
109
108
|
1. Install XCode from the App Store
|
|
110
109
|
2. Install Command Line Developer Tools (contains Compiler toolchain, git, etc.) by running this command:<br/> `xcode-select --install`
|
|
111
110
|
3. Install the homebrew package manager by running this command:<br/> `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
|
|
112
|
-
4. Install some packages with homebrew by running this command:<br/> `brew install pkg-config cmake npm
|
|
111
|
+
4. Install some packages with homebrew by running this command:<br/> `brew install pkg-config cmake npm`
|
|
113
112
|
|
|
114
113
|
#### Install dependencies on Windows
|
|
115
114
|
|
package/binding.gyp
CHANGED
|
@@ -82,8 +82,7 @@
|
|
|
82
82
|
],
|
|
83
83
|
"libraries": [
|
|
84
84
|
'<!@(./scripts/get_sword_library.sh \"../sword_build/libsword.a\")',
|
|
85
|
-
'<!@(pkg-config --libs libcurl)'
|
|
86
|
-
'<!@(pkg-config --libs icu-uc icu-io)'
|
|
85
|
+
'<!@(pkg-config --libs libcurl)'
|
|
87
86
|
],
|
|
88
87
|
"dependencies": [
|
|
89
88
|
"<!(node -p \"require('node-addon-api').gyp\")",
|
package/index.js
CHANGED
|
@@ -36,7 +36,7 @@ const nodeSwordInterfaceModule = require('./build/Release/node_sword_interface.n
|
|
|
36
36
|
* @typedef ModuleObject
|
|
37
37
|
* @type {Object}
|
|
38
38
|
* @property {String} name - The name/code of the SWORD module
|
|
39
|
-
* @property {String} type - The type of the SWORD module (Currently the following types are supported: Biblical Texts, Lexicons / Dictionaries)
|
|
39
|
+
* @property {String} type - The type of the SWORD module (Currently the following types are supported: Biblical Texts, Lexicons / Dictionaries, Commentaries)
|
|
40
40
|
* @property {String} description - The description of the SWORD module
|
|
41
41
|
* @property {String} language - The language code of the SWORD module
|
|
42
42
|
* @property {String} distributionLicense - The distribution license of the SWORD module
|
|
@@ -136,7 +136,7 @@ class NodeSwordInterface {
|
|
|
136
136
|
* Note that the languages are returned as language codes.
|
|
137
137
|
*
|
|
138
138
|
* @param {String} repositoryName - The name of the given repository.
|
|
139
|
-
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT)
|
|
139
|
+
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)
|
|
140
140
|
* @return {String[]} An array of strings with the languages codes for the Bible modules from the given repository.
|
|
141
141
|
*/
|
|
142
142
|
getRepoLanguages(repositoryName, moduleType="BIBLE") {
|
|
@@ -147,7 +147,7 @@ class NodeSwordInterface {
|
|
|
147
147
|
* Returns all modules for the given repository (default: Bible modules).
|
|
148
148
|
*
|
|
149
149
|
* @param {String} repositoryName - The name of the given repository.
|
|
150
|
-
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT)
|
|
150
|
+
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)
|
|
151
151
|
* @return {ModuleObject[]} An array of strings with the module codes for the Bible modules of the given repository.
|
|
152
152
|
*/
|
|
153
153
|
getAllRepoModules(repositoryName, moduleType="BIBLE") {
|
|
@@ -159,7 +159,7 @@ class NodeSwordInterface {
|
|
|
159
159
|
*
|
|
160
160
|
* @param {String} repositoryName - The name of the given repository.
|
|
161
161
|
* @param {String} language - The language code that shall be used as a filter.
|
|
162
|
-
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT)
|
|
162
|
+
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)
|
|
163
163
|
* @param {Boolean} headersFilter - Whether only modules with Headers shall be returned.
|
|
164
164
|
* @param {Boolean} strongsFilter - Whether only modules with Strong's shall be returned.
|
|
165
165
|
* @param {Boolean} hebrewStrongsKeys - Whether only modules with Hebrew Strong's keys shall be returned (only applies to dictionaries).
|
|
@@ -193,7 +193,7 @@ class NodeSwordInterface {
|
|
|
193
193
|
|
|
194
194
|
/**
|
|
195
195
|
* Returns all modules installed locally (default: Bible modules).
|
|
196
|
-
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT)
|
|
196
|
+
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)
|
|
197
197
|
* @return {ModuleObject[]} An array of ModuleObjects which represents the locally installed Bible modules.
|
|
198
198
|
*/
|
|
199
199
|
getAllLocalModules(moduleType="BIBLE") {
|
|
@@ -204,7 +204,7 @@ class NodeSwordInterface {
|
|
|
204
204
|
* Returns the number of modules for a given repository (default: Bible modules).
|
|
205
205
|
*
|
|
206
206
|
* @param {String} repositoryName - The name of the given repository.
|
|
207
|
-
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT)
|
|
207
|
+
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)
|
|
208
208
|
* @return {Number} The number of Bible modules for the given repository and module type.
|
|
209
209
|
*/
|
|
210
210
|
getRepoModuleCount(repositoryName, moduleType="BIBLE") {
|
|
@@ -216,7 +216,7 @@ class NodeSwordInterface {
|
|
|
216
216
|
*
|
|
217
217
|
* @param {String} repositoryName - The name of the given repository.
|
|
218
218
|
* @param {String} language - The language code that shall be used as a filter.
|
|
219
|
-
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT)
|
|
219
|
+
* @param {String} moduleType - A filter parameter that defines the moduleType (Options: BIBLE, DICT, COMMENTARY)
|
|
220
220
|
* @return {Number} The number of Bible modules for the given repository, language and module type.
|
|
221
221
|
*/
|
|
222
222
|
getRepoLanguageModuleCount(repositoryName, language, moduleType="BIBLE") {
|
|
@@ -330,7 +330,7 @@ class NodeSwordInterface {
|
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
/**
|
|
333
|
-
* Returns the text of an entry for the given module and key.
|
|
333
|
+
* Returns the raw text of an entry for the given module and key.
|
|
334
334
|
* If no entry exists for the given key the return value is undefined.
|
|
335
335
|
*
|
|
336
336
|
* @param {String} moduleCode - The module code of the SWORD module.
|
|
@@ -341,6 +341,18 @@ class NodeSwordInterface {
|
|
|
341
341
|
return this.nativeInterface.getRawModuleEntry(moduleCode, key);
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Returns the text of an entry for the given module and key.
|
|
346
|
+
* If no entry exists for the given key the return value is a verse with empty content.
|
|
347
|
+
*
|
|
348
|
+
* @param {String} moduleCode - The module code of the SWORD module.
|
|
349
|
+
* @param {String} key - The key of the entry.
|
|
350
|
+
* @return {VerseObject}
|
|
351
|
+
*/
|
|
352
|
+
getReferenceText(moduleCode, key) {
|
|
353
|
+
return this.nativeInterface.getReferenceText(moduleCode, key);
|
|
354
|
+
}
|
|
355
|
+
|
|
344
356
|
/**
|
|
345
357
|
* Returns the text of a chapter for the given module.
|
|
346
358
|
*
|
package/package.json
CHANGED
package/scripts/build_sword.sh
CHANGED
|
@@ -75,7 +75,9 @@ else
|
|
|
75
75
|
# macOS & Linux
|
|
76
76
|
|
|
77
77
|
cd sword_build
|
|
78
|
-
cmake -DLIBSWORD_LIBRARY_TYPE=Static -DCMAKE_CXX_STANDARD=11 -DCMAKE_BUILD_TYPE=Release
|
|
78
|
+
cmake -DLIBSWORD_LIBRARY_TYPE=Static -DCMAKE_CXX_STANDARD=11 -DCMAKE_BUILD_TYPE=Release \
|
|
79
|
+
-DCMAKE_DISABLE_FIND_PACKAGE_ICU=TRUE \
|
|
80
|
+
../sword
|
|
79
81
|
fi
|
|
80
82
|
|
|
81
83
|
make -j4 sword_static
|
|
@@ -79,7 +79,13 @@ void NapiSwordHelper::swordModuleToNapiObject(const Napi::Env& env, SWModule* sw
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
if (swModule->getConfigEntry("InstallSize")) {
|
|
82
|
-
|
|
82
|
+
std::string configInstallSize = string(swModule->getConfigEntry("InstallSize"));
|
|
83
|
+
|
|
84
|
+
int moduleSize = -1;
|
|
85
|
+
if (configInstallSize.length() > 0) {
|
|
86
|
+
moduleSize = std::stoi(configInstallSize);
|
|
87
|
+
}
|
|
88
|
+
|
|
83
89
|
object["size"] = Napi::Number::New(env, moduleSize);
|
|
84
90
|
} else {
|
|
85
91
|
object["size"] = Napi::Number::New(env, -1);
|
|
@@ -45,9 +45,9 @@ public:
|
|
|
45
45
|
Napi::Array getNapiVerseObjectsFromRawList(const Napi::Env& env, std::string moduleCode, std::vector<Verse>& verses);
|
|
46
46
|
void swordModuleToNapiObject(const Napi::Env& env, sword::SWModule* swModule, Napi::Object& object);
|
|
47
47
|
void strongsEntryToNapiObject(const Napi::Env& env, StrongsEntry* strongsEntry, Napi::Object& object);
|
|
48
|
+
void verseTextToNapiObject(std::string moduleCode, Verse rawVerse, Napi::Object& object);
|
|
48
49
|
|
|
49
50
|
private:
|
|
50
|
-
void verseTextToNapiObject(std::string moduleCode, Verse rawVerse, Napi::Object& object);
|
|
51
51
|
Napi::String getConfigEntry(sword::SWModule* swModule, std::string key, const Napi::Env& env);
|
|
52
52
|
|
|
53
53
|
ModuleHelper& _moduleHelper;
|
|
@@ -90,6 +90,7 @@ Napi::Object NodeSwordInterface::Init(Napi::Env env, Napi::Object exports)
|
|
|
90
90
|
InstanceMethod("getLocalModule", &NodeSwordInterface::getLocalModule),
|
|
91
91
|
InstanceMethod("enableMarkup", &NodeSwordInterface::enableMarkup),
|
|
92
92
|
InstanceMethod("getRawModuleEntry", &NodeSwordInterface::getRawModuleEntry),
|
|
93
|
+
InstanceMethod("getReferenceText", &NodeSwordInterface::getReferenceText),
|
|
93
94
|
InstanceMethod("getChapterText", &NodeSwordInterface::getChapterText),
|
|
94
95
|
InstanceMethod("getBookText", &NodeSwordInterface::getBookText),
|
|
95
96
|
InstanceMethod("getBibleText", &NodeSwordInterface::getBibleText),
|
|
@@ -345,6 +346,8 @@ ModuleType NodeSwordInterface::getModuleTypeFromString(std::string moduleTypeStr
|
|
|
345
346
|
return ModuleType::bible;
|
|
346
347
|
} else if (moduleTypeString == "DICT") {
|
|
347
348
|
return ModuleType::dict;
|
|
349
|
+
} else if (moduleTypeString == "COMMENTARY") {
|
|
350
|
+
return ModuleType::commentary;
|
|
348
351
|
} else {
|
|
349
352
|
return ModuleType::any;
|
|
350
353
|
}
|
|
@@ -544,6 +547,23 @@ Napi::Value NodeSwordInterface::getRawModuleEntry(const Napi::CallbackInfo& info
|
|
|
544
547
|
}
|
|
545
548
|
}
|
|
546
549
|
|
|
550
|
+
Napi::Value NodeSwordInterface::getReferenceText(const Napi::CallbackInfo& info)
|
|
551
|
+
{
|
|
552
|
+
lockApi();
|
|
553
|
+
INIT_SCOPE_AND_VALIDATE(ParamType::string, ParamType::string);
|
|
554
|
+
Napi::Env env = info.Env();
|
|
555
|
+
Napi::String moduleName = info[0].As<Napi::String>();
|
|
556
|
+
Napi::String key = info[1].As<Napi::String>();
|
|
557
|
+
ASSERT_SW_MODULE_EXISTS(moduleName);
|
|
558
|
+
|
|
559
|
+
Verse rawVerse = this->_textProcessor->getReferenceText(moduleName, key);
|
|
560
|
+
Napi::Object verseObject = Napi::Object::New(env);
|
|
561
|
+
this->_napiSwordHelper->verseTextToNapiObject(moduleName, rawVerse, verseObject);
|
|
562
|
+
|
|
563
|
+
unlockApi();
|
|
564
|
+
return verseObject;
|
|
565
|
+
}
|
|
566
|
+
|
|
547
567
|
Napi::Value NodeSwordInterface::getChapterText(const Napi::CallbackInfo& info)
|
|
548
568
|
{
|
|
549
569
|
lockApi();
|
|
@@ -71,6 +71,7 @@ private:
|
|
|
71
71
|
Napi::Value enableMarkup(const Napi::CallbackInfo& info);
|
|
72
72
|
|
|
73
73
|
Napi::Value getRawModuleEntry(const Napi::CallbackInfo& info);
|
|
74
|
+
Napi::Value getReferenceText(const Napi::CallbackInfo& info);
|
|
74
75
|
Napi::Value getChapterText(const Napi::CallbackInfo& info);
|
|
75
76
|
Napi::Value getBookText(const Napi::CallbackInfo& info);
|
|
76
77
|
Napi::Value getBibleText(const Napi::CallbackInfo& info);
|
|
@@ -80,6 +80,11 @@ string TextProcessor::getFilteredText(const string& text, int chapter, int verse
|
|
|
80
80
|
static string divineNameStartElement = "<divineName>";
|
|
81
81
|
static string divineNameEndElement = "</divineName>";
|
|
82
82
|
static string strongsWElement = "<w lemma=";
|
|
83
|
+
static string listStartElement = "<list";
|
|
84
|
+
static string listEndElement = "</list>";
|
|
85
|
+
static string itemStartElement = "<item";
|
|
86
|
+
static string itemEndElement = "</item>";
|
|
87
|
+
static string hiBold = "<hi type=\"bold";
|
|
83
88
|
|
|
84
89
|
static regex milestoneFilter = regex("<milestone.*?/>");
|
|
85
90
|
static regex segStartElementFilter = regex("<seg.*?>");
|
|
@@ -159,6 +164,11 @@ string TextProcessor::getFilteredText(const string& text, int chapter, int verse
|
|
|
159
164
|
this->findAndReplaceAll(filteredText, divineNameStartElement, "");
|
|
160
165
|
this->findAndReplaceAll(filteredText, divineNameEndElement, "");
|
|
161
166
|
this->findAndReplaceAll(filteredText, strongsWElement, "<w class=");
|
|
167
|
+
this->findAndReplaceAll(filteredText, listStartElement, "<ul");
|
|
168
|
+
this->findAndReplaceAll(filteredText, listEndElement, "</ul>");
|
|
169
|
+
this->findAndReplaceAll(filteredText, itemStartElement, "<li");
|
|
170
|
+
this->findAndReplaceAll(filteredText, itemEndElement, "</li>");
|
|
171
|
+
this->findAndReplaceAll(filteredText, hiBold, "<hi class=\"bold");
|
|
162
172
|
|
|
163
173
|
filteredText = regex_replace(filteredText, selfClosingElement, "<$2 $3></$2>");
|
|
164
174
|
|
|
@@ -269,6 +279,25 @@ vector<Verse> TextProcessor::getBibleText(string moduleName)
|
|
|
269
279
|
return this->getText(moduleName, "Gen 1:1");
|
|
270
280
|
}
|
|
271
281
|
|
|
282
|
+
Verse TextProcessor::getReferenceText(std::string moduleName, std::string reference)
|
|
283
|
+
{
|
|
284
|
+
SWModule* module = this->_moduleStore.getLocalModule(moduleName);
|
|
285
|
+
module->setKey(reference.c_str());
|
|
286
|
+
bool entryExisting = module->hasEntry(module->getKey());
|
|
287
|
+
|
|
288
|
+
if (entryExisting) {
|
|
289
|
+
vector<Verse> verses = this->getText(moduleName, reference, QueryLimit::book, -1, 1);
|
|
290
|
+
verses[0].absoluteVerseNumber = -1;
|
|
291
|
+
return verses[0];
|
|
292
|
+
} else {
|
|
293
|
+
Verse verse;
|
|
294
|
+
verse.reference = reference;
|
|
295
|
+
verse.absoluteVerseNumber = -1;
|
|
296
|
+
verse.content = "";
|
|
297
|
+
return verse;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
272
301
|
vector<Verse> TextProcessor::getBookText(string moduleName, string bookCode, int startVerseNumber, int verseCount)
|
|
273
302
|
{
|
|
274
303
|
stringstream key;
|
|
@@ -39,6 +39,7 @@ public:
|
|
|
39
39
|
void disableMarkup() { this->_markupEnabled = false; }
|
|
40
40
|
|
|
41
41
|
std::vector<Verse> getBibleText(std::string moduleName);
|
|
42
|
+
Verse getReferenceText(std::string moduleName, std::string reference);
|
|
42
43
|
std::vector<Verse> getBookText(std::string moduleName, std::string bookCode, int startVerseNumber=-1, int verseCount=-1);
|
|
43
44
|
std::vector<Verse> getChapterText(std::string moduleName, std::string bookCode, int chapter);
|
|
44
45
|
std::vector<Verse> getVersesFromReferences(std::string moduleName, std::vector<std::string>& references);
|