node-sword-interface 0.249.0 → 0.252.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-sword-interface",
3
- "version": "0.249.0",
3
+ "version": "0.252.0",
4
4
  "description": "Javascript (N-API) interface to SWORD library",
5
5
  "keywords": [
6
6
  "C++",
@@ -214,13 +214,13 @@ int main(int argc, char** argv)
214
214
  //string translation = sword_facade.getSwordTranslation(string("/usr/share/sword/locales.d"), string("de"), string("locales"));
215
215
  //cout << translation << endl;
216
216
 
217
- /*vector<Verse> searchResults = moduleSearch.getModuleSearchResults("NASB", "faith", SearchType::multiWord, SearchScope::NT, true);
217
+ vector<Verse> searchResults = moduleSearch.getModuleSearchResults("GerNeUe", "Glaube", SearchType::multiWord, SearchScope::NT, true);
218
218
  cout << "Got " << searchResults.size() << " results!" << endl;
219
219
  for (unsigned int i=0; i < searchResults.size(); i++) {
220
220
  cout << searchResults[i].reference << endl;
221
- }*/
221
+ }
222
222
 
223
- get_book_headers(textProcessor);
223
+ /*get_book_headers(textProcessor);*/
224
224
 
225
225
  return 0;
226
226
  }
@@ -70,14 +70,25 @@ bool ModuleHelper::moduleHasKeyValuePair(sword::SWModule* module, std::string ke
70
70
 
71
71
  bool ModuleHelper::moduleHasBook(sword::SWModule* module, std::string bookCode)
72
72
  {
73
- bool hasBook;
73
+ bool hasBook = true;
74
74
  stringstream key;
75
75
  key << bookCode;
76
76
  key << " 1:1";
77
77
 
78
78
  module->setKey(key.str().c_str());
79
- hasBook = module->hasEntry(module->getKey());
80
-
79
+ string moduleKeyText = string(module->getKey()->getShortText());
80
+
81
+ /* In case of apocryphal books the hasEntry method below is not enough.
82
+ Once we have set the key we need to compare the actual module key with the key we wanted to set.
83
+ For apocryphal books we may get "Rev 1:1" as actual module key and this will mismatch with the set key
84
+ and then indicate that the book is not existing. */
85
+
86
+ if (moduleKeyText != key.str()) {
87
+ hasBook = false;
88
+ } else {
89
+ hasBook = module->hasEntry(module->getKey());
90
+ }
91
+
81
92
  return hasBook;
82
93
  }
83
94
 
@@ -50,10 +50,17 @@
50
50
  using namespace std;
51
51
  using namespace sword;
52
52
 
53
- ListKey ModuleSearch::getScopeKey(SearchScope scope)
53
+ ListKey ModuleSearch::getScopeKey(SWModule* module, SearchScope scope)
54
54
  {
55
55
  ListKey key;
56
56
 
57
+ if (module == 0) {
58
+ cerr << "ModuleSearch::getScopeKey / received 0 pointer for module!!!";
59
+ return key;
60
+ }
61
+
62
+ VerseKey verseKey = module->getKey();
63
+
57
64
  switch (scope) {
58
65
  case SearchScope::OT:
59
66
  {
@@ -63,7 +70,7 @@ ListKey ModuleSearch::getScopeKey(SearchScope scope)
63
70
  "Isaiah;Jeremiah;Lamentations;Ezekiel;Daniel;Hosea;Joel;Amos;Obadiah;"
64
71
  "Jonah;Micah;Nahum;Habakkuk;Zephaniah;Haggai;Zechariah;Malachi;";
65
72
 
66
- key = VerseKey().parseVerseList(otBooks, "", true);
73
+ key = verseKey.parseVerseList(otBooks, "", true);
67
74
  break;
68
75
  }
69
76
 
@@ -74,7 +81,7 @@ ListKey ModuleSearch::getScopeKey(SearchScope scope)
74
81
  "I Timothy;II Timothy;Titus;Philemon;Hebrews;James;I Peter;II Peter;"
75
82
  "I John;II John;III John;Jude;Revelation of John;";
76
83
 
77
- key = VerseKey().parseVerseList(ntBooks, "", true);
84
+ key = verseKey.parseVerseList(ntBooks, "", true);
78
85
  break;
79
86
  }
80
87
 
@@ -119,7 +126,7 @@ vector<Verse> ModuleSearch::getModuleSearchResults(string moduleName,
119
126
  ListKey scopeKey;
120
127
 
121
128
  if (searchScope != SearchScope::BIBLE) {
122
- scopeKey = this->getScopeKey(searchScope);
129
+ scopeKey = this->getScopeKey(module, searchScope);
123
130
  scope = &scopeKey;
124
131
  }
125
132
 
@@ -65,7 +65,7 @@ public:
65
65
  void terminate();
66
66
 
67
67
  private:
68
- sword::ListKey getScopeKey(SearchScope scope);
68
+ sword::ListKey getScopeKey(sword::SWModule* module, SearchScope scope);
69
69
 
70
70
  ModuleStore& _moduleStore;
71
71
  ModuleHelper& _moduleHelper;
@@ -138,6 +138,14 @@ string TextProcessor::getFilteredText(const string& text, int chapter, int verse
138
138
  secHead << "chapter=\"" << chapter << "\"";
139
139
  this->findAndReplaceAll(filteredText, secHeadClassFilter, secHead.str());
140
140
 
141
+ if (filteredText.find("subType=\"x-Chapter") != string::npos ||
142
+ filteredText.find("type=\"chapter") != string::npos) {
143
+
144
+ static string swordSectionTitle = "sword-section-title";
145
+ static string swordSectionTitleChapter = "sword-section-title sword-chapter-title";
146
+ this->findAndReplaceAll(filteredText, swordSectionTitle, swordSectionTitleChapter);
147
+ }
148
+
141
149
  this->findAndReplaceAll(filteredText, titleEndElementFilter, "</div>");
142
150
  this->findAndReplaceAll(filteredText, segStartElementFilter, "");
143
151
  this->findAndReplaceAll(filteredText, segEndElementFilter, "");