node-sword-interface 1.0.100 → 1.0.102
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
package/src/node_sword_cli.cpp
CHANGED
|
@@ -130,7 +130,7 @@ void get_book_intro(TextProcessor& text_processor)
|
|
|
130
130
|
{
|
|
131
131
|
cout << "Text:" << endl;
|
|
132
132
|
text_processor.enableMarkup();
|
|
133
|
-
string bookIntro = text_processor.getBookIntroduction("
|
|
133
|
+
string bookIntro = text_processor.getBookIntroduction("NET", "Luke");
|
|
134
134
|
cout << bookIntro << endl;
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -226,11 +226,11 @@ int main(int argc, char** argv)
|
|
|
226
226
|
cout << "Error installing module (write permissions?)\n";
|
|
227
227
|
}*/
|
|
228
228
|
|
|
229
|
-
int error = moduleInstaller.uninstallModule("YLT");
|
|
229
|
+
/*int error = moduleInstaller.uninstallModule("YLT");
|
|
230
230
|
|
|
231
231
|
if (error) {
|
|
232
232
|
cout << "Error uninstalling module (write permissions?)\n";
|
|
233
|
-
}
|
|
233
|
+
}*/
|
|
234
234
|
|
|
235
235
|
/*get_local_module(moduleStore);
|
|
236
236
|
|
|
@@ -241,11 +241,11 @@ int main(int argc, char** argv)
|
|
|
241
241
|
|
|
242
242
|
//get_strongs_entry(textProcessor);
|
|
243
243
|
|
|
244
|
-
get_module_text(textProcessor);
|
|
244
|
+
//get_module_text(textProcessor);
|
|
245
245
|
|
|
246
246
|
//get_reference_text(moduleStore, textProcessor);
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
get_book_intro(textProcessor);
|
|
249
249
|
|
|
250
250
|
//get_book_list(moduleHelper);
|
|
251
251
|
|
|
@@ -540,18 +540,37 @@ string TextProcessor::getBookIntroduction(string moduleName, string bookCode)
|
|
|
540
540
|
if (module == 0) {
|
|
541
541
|
cerr << "getLocalModule returned zero pointer for " << moduleName << endl;
|
|
542
542
|
} else {
|
|
543
|
+
// Get module data path BEFORE manipulating the module key
|
|
544
|
+
string moduleDataPath = this->_moduleStore.getModuleDataPath(module);
|
|
545
|
+
string moduleFileUrl = this->getFileUrl(moduleDataPath);
|
|
546
|
+
|
|
543
547
|
module->setKeyText(bookCode.c_str());
|
|
544
|
-
|
|
548
|
+
|
|
549
|
+
// Create a local VerseKey copy to avoid pointer invalidation issues
|
|
550
|
+
VerseKey verseKey = module->getKey();
|
|
545
551
|
|
|
546
552
|
// Include chapter/book/testament/module intros
|
|
547
|
-
verseKey
|
|
548
|
-
|
|
549
|
-
|
|
553
|
+
verseKey.setIntros(true);
|
|
554
|
+
|
|
555
|
+
// First try to get book intro from chapter 0, verse 0
|
|
556
|
+
verseKey.setChapter(0);
|
|
557
|
+
verseKey.setVerse(0);
|
|
550
558
|
module->setKey(verseKey);
|
|
551
559
|
|
|
552
560
|
bookIntroText = string(module->getRawEntry());
|
|
553
561
|
StringHelper::trim(bookIntroText);
|
|
554
562
|
|
|
563
|
+
// If book intro (0:0) is empty, also fetch chapter 1:0
|
|
564
|
+
// Some modules (like NET) store book-level intro content in chapter 1:0
|
|
565
|
+
if (bookIntroText.empty()) {
|
|
566
|
+
verseKey.setChapter(1);
|
|
567
|
+
verseKey.setVerse(0);
|
|
568
|
+
module->setKey(verseKey);
|
|
569
|
+
|
|
570
|
+
bookIntroText = string(module->getRawEntry());
|
|
571
|
+
StringHelper::trim(bookIntroText);
|
|
572
|
+
}
|
|
573
|
+
|
|
555
574
|
static regex titleStartElementFilter = regex("<title");
|
|
556
575
|
static regex titleEndElementFilter = regex("</title>");
|
|
557
576
|
static regex noteStartElementFilter = regex("<note");
|
|
@@ -570,7 +589,6 @@ string TextProcessor::getBookIntroduction(string moduleName, string bookCode)
|
|
|
570
589
|
filteredText = regex_replace(filteredText, chapterDivFilter, "");
|
|
571
590
|
|
|
572
591
|
// Prefix img src attributes starting with "/" with the module file URL
|
|
573
|
-
string moduleFileUrl = this->getFileUrl(this->_moduleStore.getModuleDataPath(module));
|
|
574
592
|
if (!moduleFileUrl.empty()) {
|
|
575
593
|
static string imgSrcSlash = "src=\"/";
|
|
576
594
|
string imgSrcReplacement = "src=\"" + moduleFileUrl + "/";
|