node-sword-interface 1.0.30 → 1.0.32

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 CHANGED
@@ -50,6 +50,7 @@ This is the main class of node-sword-interface and it provides a set of static f
50
50
  * [.isModuleReadable(moduleCode)](#NodeSwordInterface+isModuleReadable) ⇒ <code>Boolean</code>
51
51
  * [.getModuleDescription(moduleCode)](#NodeSwordInterface+getModuleDescription) ⇒ <code>String</code>
52
52
  * [.enableMarkup()](#NodeSwordInterface+enableMarkup)
53
+ * [.enableStrongsWithNbsp()](#NodeSwordInterface+enableStrongsWithNbsp)
53
54
  * [.getRawModuleEntry(moduleCode, key)](#NodeSwordInterface+getRawModuleEntry) ⇒ <code>String</code>
54
55
  * [.getReferenceText(moduleCode, key)](#NodeSwordInterface+getReferenceText) ⇒ [<code>VerseObject</code>](#VerseObject)
55
56
  * [.getChapterText(moduleCode, bookCode, chapter)](#NodeSwordInterface+getChapterText) ⇒ [<code>Array.&lt;VerseObject&gt;</code>](#VerseObject)
@@ -310,6 +311,12 @@ Returns the description of a module.
310
311
  Enables available markup (like Strongs, foot notes, etc.)
311
312
  This influences the output for getChapterText, getBookText and getBibleText.
312
313
 
314
+ **Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
315
+ <a name="NodeSwordInterface+enableStrongsWithNbsp"></a>
316
+
317
+ ### nodeSwordInterface.enableStrongsWithNbsp()
318
+ Enables rendering of Strongs elements with non-breaking spaces.
319
+
313
320
  **Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
314
321
  <a name="NodeSwordInterface+getRawModuleEntry"></a>
315
322
 
package/index.js CHANGED
@@ -331,6 +331,13 @@ class NodeSwordInterface {
331
331
  return this.nativeInterface.enableMarkup();
332
332
  }
333
333
 
334
+ /**
335
+ * Enables rendering of Strongs elements with non-breaking spaces.
336
+ */
337
+ enableStrongsWithNbsp() {
338
+ return this.nativeInterface.enableStrongsWithNbsp();
339
+ }
340
+
334
341
  /**
335
342
  * Returns the raw text of an entry for the given module and key.
336
343
  * If no entry exists for the given key the return value is undefined.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-sword-interface",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "Javascript (N-API) interface to SWORD library",
5
5
  "keywords": [
6
6
  "C++",
@@ -23,7 +23,7 @@
23
23
  "license": "GPL-2.0+",
24
24
  "dependencies": {
25
25
  "glob": "^8.0.3",
26
- "node-addon-api": "^7.1.0",
26
+ "node-addon-api": "^8.2.2",
27
27
  "node-html-parser": "^6.1.13"
28
28
  },
29
29
  "repository": {
@@ -90,6 +90,7 @@ Napi::Object NodeSwordInterface::Init(Napi::Env env, Napi::Object exports)
90
90
  InstanceMethod("getModuleDescription", &NodeSwordInterface::getModuleDescription),
91
91
  InstanceMethod("getLocalModule", &NodeSwordInterface::getLocalModule),
92
92
  InstanceMethod("enableMarkup", &NodeSwordInterface::enableMarkup),
93
+ InstanceMethod("enableStrongsWithNbsp", &NodeSwordInterface::enableStrongsWithNbsp),
93
94
  InstanceMethod("getRawModuleEntry", &NodeSwordInterface::getRawModuleEntry),
94
95
  InstanceMethod("getReferenceText", &NodeSwordInterface::getReferenceText),
95
96
  InstanceMethod("getChapterText", &NodeSwordInterface::getChapterText),
@@ -526,6 +527,16 @@ Napi::Value NodeSwordInterface::enableMarkup(const Napi::CallbackInfo& info)
526
527
  return info.Env().Undefined();
527
528
  }
528
529
 
530
+ Napi::Value NodeSwordInterface::enableStrongsWithNbsp(const Napi::CallbackInfo& info)
531
+ {
532
+ lockApi();
533
+ Napi::Env env = info.Env();
534
+ Napi::HandleScope scope(env);
535
+ this->_textProcessor->enableStrongsWithNbsp();
536
+ unlockApi();
537
+ return info.Env().Undefined();
538
+ }
539
+
529
540
  Napi::Value NodeSwordInterface::getRawModuleEntry(const Napi::CallbackInfo& info)
530
541
  {
531
542
  lockApi();
@@ -70,6 +70,7 @@ private:
70
70
  Napi::Value getLocalModule(const Napi::CallbackInfo& info);
71
71
 
72
72
  Napi::Value enableMarkup(const Napi::CallbackInfo& info);
73
+ Napi::Value enableStrongsWithNbsp(const Napi::CallbackInfo& info);
73
74
 
74
75
  Napi::Value getRawModuleEntry(const Napi::CallbackInfo& info);
75
76
  Napi::Value getReferenceText(const Napi::CallbackInfo& info);
@@ -43,14 +43,6 @@ bool ModuleHelper::moduleHasFeature(sword::SWModule* module, std::string feature
43
43
  return this->moduleHasKeyValuePair(module, "Feature", feature);
44
44
  }
45
45
 
46
- bool ModuleHelper::moduleHasStrongsKeys(sword::SWModule* module)
47
- {
48
- bool hasHebrewStrongsKeys = this->moduleHasFeature(module, "HebrewDef");
49
- bool hasGreekStrongsKeys = this->moduleHasFeature(module, "GreekDef");
50
-
51
- return hasHebrewStrongsKeys || hasGreekStrongsKeys;
52
- }
53
-
54
46
  bool ModuleHelper::moduleHasKeyValuePair(sword::SWModule* module, std::string key, std::string value)
55
47
  {
56
48
  bool hasKeyValuePair = false;
@@ -42,7 +42,6 @@ public:
42
42
 
43
43
  bool moduleHasGlobalOption(sword::SWModule* module, std::string globalOption);
44
44
  bool moduleHasFeature(sword::SWModule* module, std::string feature);
45
- bool moduleHasStrongsKeys(sword::SWModule* module);
46
45
  bool moduleHasBook(sword::SWModule* module, std::string bookCode);
47
46
 
48
47
  std::vector<std::string> getBookList(std::string moduleName);
@@ -230,10 +230,6 @@ vector<SWModule*> RepositoryInterface::getAllRepoModules(string repoName, Module
230
230
  SWModule* currentModule = it->second;
231
231
  string currentModuleType = currentModule->getType();
232
232
 
233
- /*if (moduleType == ModuleType::dict && !this->_moduleHelper.moduleHasStrongsKeys(currentModule)) {
234
- continue;
235
- }*/
236
-
237
233
  if (moduleTypeString == "ANY" || currentModuleType == moduleTypeString) {
238
234
  modules.push_back(currentModule);
239
235
  }
@@ -288,11 +284,6 @@ vector<SWModule*> RepositoryInterface::getRepoModulesByLang(string repoName,
288
284
  continue;
289
285
  }
290
286
 
291
- /*if (moduleType == ModuleType::dict && !hasHebrewStrongsKeys && !hasGreekStrongsKeys) {
292
- // In case of a dictionary module we ignore it if there are not Strong's keys
293
- continue;
294
- }*/
295
-
296
287
  if (hebrewStrongsKeys && !hasHebrewStrongsKeys) {
297
288
  continue;
298
289
  }
@@ -40,6 +40,7 @@ TextProcessor::TextProcessor(ModuleStore& moduleStore, ModuleHelper& moduleHelpe
40
40
  : _moduleStore(moduleStore), _moduleHelper(moduleHelper)
41
41
  {
42
42
  this->_markupEnabled = false;
43
+ this->_strongsWithNbspEnabled = false;
43
44
  this->_rawMarkupEnabled = false;
44
45
  }
45
46
 
@@ -210,7 +211,7 @@ string TextProcessor::getFilteredText(const string& text, int chapter, int verse
210
211
  }
211
212
  }
212
213
 
213
- if (hasStrongs) {
214
+ if (hasStrongs && this->_strongsWithNbspEnabled) {
214
215
  filteredText = this->replaceSpacesInStrongs(filteredText);
215
216
  }
216
217
 
@@ -533,6 +534,7 @@ string TextProcessor::replaceSpacesInStrongs(const string& text)
533
534
  filteredText += std::regex_replace(m[0].str(), space, "&nbsp;");
534
535
  input = m.suffix();
535
536
  }
537
+
536
538
  filteredText += input;
537
539
 
538
540
  return filteredText;
@@ -38,6 +38,8 @@ public:
38
38
  void enableMarkup() { this->_markupEnabled = true; }
39
39
  void disableMarkup() { this->_markupEnabled = false; }
40
40
 
41
+ void enableStrongsWithNbsp() { this->_strongsWithNbspEnabled = true; }
42
+
41
43
  std::vector<Verse> getBibleText(std::string moduleName);
42
44
  Verse getReferenceText(std::string moduleName, std::string reference);
43
45
  std::vector<Verse> getBookText(std::string moduleName, std::string bookCode, int startVerseNumber=-1, int verseCount=-1);
@@ -71,6 +73,7 @@ private:
71
73
  ModuleHelper& _moduleHelper;
72
74
  bool _markupEnabled;
73
75
  bool _rawMarkupEnabled;
76
+ bool _strongsWithNbspEnabled;
74
77
  };
75
78
 
76
79
  #endif // _TEXT_PROCESSOR