node-sword-interface 1.0.101 → 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
|
|
|
@@ -294,48 +294,6 @@ string TextProcessor::getCurrentChapterHeading(sword::SWModule* module, const st
|
|
|
294
294
|
return chapterHeading;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
string TextProcessor::getCurrentPreverseHeading(sword::SWModule* module, const string& moduleFileUrl)
|
|
298
|
-
{
|
|
299
|
-
string preverse = "";
|
|
300
|
-
VerseKey currentVerseKey = module->getKey();
|
|
301
|
-
int currentChapter = currentVerseKey.getChapter();
|
|
302
|
-
int currentVerseNr = currentVerseKey.getVerse();
|
|
303
|
-
|
|
304
|
-
// First, we need to access the rendered text to populate entry attributes
|
|
305
|
-
// The entry attributes are only available after rendering/stripping
|
|
306
|
-
module->renderText();
|
|
307
|
-
|
|
308
|
-
// Get the entry attributes map
|
|
309
|
-
sword::AttributeTypeList& attributes = module->getEntryAttributes();
|
|
310
|
-
|
|
311
|
-
// Look for Heading/Preverse entries (indexed 0, 1, 2, ...)
|
|
312
|
-
auto headingIt = attributes.find("Heading");
|
|
313
|
-
if (headingIt != attributes.end()) {
|
|
314
|
-
auto preverseIt = headingIt->second.find("Preverse");
|
|
315
|
-
if (preverseIt != headingIt->second.end()) {
|
|
316
|
-
// Iterate through all preverse entries (0, 1, 2, ...)
|
|
317
|
-
for (auto& entry : preverseIt->second) {
|
|
318
|
-
string preverseContent = string(entry.second.c_str());
|
|
319
|
-
StringHelper::trim(preverseContent);
|
|
320
|
-
|
|
321
|
-
if (!preverseContent.empty()) {
|
|
322
|
-
// Render the preverse content through the module
|
|
323
|
-
sword::SWBuf renderedBuf = module->renderText(preverseContent.c_str());
|
|
324
|
-
string rendered = string(renderedBuf.c_str());
|
|
325
|
-
|
|
326
|
-
if (this->_markupEnabled && !this->_rawMarkupEnabled) {
|
|
327
|
-
rendered = this->getFilteredText(rendered, currentChapter, currentVerseNr, false, false, moduleFileUrl);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
preverse += rendered;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return preverse;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
297
|
string TextProcessor::getCurrentVerseText(sword::SWModule* module, bool hasStrongs, bool hasInconsistentClosingEndDivs, bool forceNoMarkup)
|
|
340
298
|
{
|
|
341
299
|
string moduleFileUrl = this->getFileUrl(this->_moduleStore.getModuleDataPath(module));
|
|
@@ -450,13 +408,7 @@ vector<Verse> TextProcessor::getVersesFromReferences(string moduleName, vector<s
|
|
|
450
408
|
bool entryExisting = module->hasEntry(module->getKey());
|
|
451
409
|
|
|
452
410
|
if (entryExisting) {
|
|
453
|
-
|
|
454
|
-
if (!moduleMarkupIsBroken) {
|
|
455
|
-
string preverseHeading = this->getCurrentPreverseHeading(module, moduleFileUrl);
|
|
456
|
-
currentVerseText += preverseHeading;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
currentVerseText += this->getCurrentVerseText(module, false, hasInconsistentClosingEndDivs, moduleMarkupIsBroken, moduleFileUrl);
|
|
411
|
+
currentVerseText = this->getCurrentVerseText(module, false, hasInconsistentClosingEndDivs, moduleMarkupIsBroken, moduleFileUrl);
|
|
460
412
|
}
|
|
461
413
|
|
|
462
414
|
Verse currentVerse;
|
|
@@ -547,13 +499,6 @@ vector<Verse> TextProcessor::getText(string moduleName, string key, QueryLimit q
|
|
|
547
499
|
verseText += chapterHeading;
|
|
548
500
|
}
|
|
549
501
|
|
|
550
|
-
// Preverse heading (introductory material attached to this verse via entry attributes)
|
|
551
|
-
// This includes intro images and other material that should appear before the verse text
|
|
552
|
-
if (!moduleMarkupIsBroken) {
|
|
553
|
-
string preverseHeading = this->getCurrentPreverseHeading(module, moduleFileUrl);
|
|
554
|
-
verseText += preverseHeading;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
502
|
// Current verse text
|
|
558
503
|
verseText += this->getCurrentVerseText(module,
|
|
559
504
|
hasStrongs,
|
|
@@ -595,18 +540,37 @@ string TextProcessor::getBookIntroduction(string moduleName, string bookCode)
|
|
|
595
540
|
if (module == 0) {
|
|
596
541
|
cerr << "getLocalModule returned zero pointer for " << moduleName << endl;
|
|
597
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
|
+
|
|
598
547
|
module->setKeyText(bookCode.c_str());
|
|
599
|
-
|
|
548
|
+
|
|
549
|
+
// Create a local VerseKey copy to avoid pointer invalidation issues
|
|
550
|
+
VerseKey verseKey = module->getKey();
|
|
600
551
|
|
|
601
552
|
// Include chapter/book/testament/module intros
|
|
602
|
-
verseKey
|
|
603
|
-
|
|
604
|
-
|
|
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);
|
|
605
558
|
module->setKey(verseKey);
|
|
606
559
|
|
|
607
560
|
bookIntroText = string(module->getRawEntry());
|
|
608
561
|
StringHelper::trim(bookIntroText);
|
|
609
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
|
+
|
|
610
574
|
static regex titleStartElementFilter = regex("<title");
|
|
611
575
|
static regex titleEndElementFilter = regex("</title>");
|
|
612
576
|
static regex noteStartElementFilter = regex("<note");
|
|
@@ -625,7 +589,6 @@ string TextProcessor::getBookIntroduction(string moduleName, string bookCode)
|
|
|
625
589
|
filteredText = regex_replace(filteredText, chapterDivFilter, "");
|
|
626
590
|
|
|
627
591
|
// Prefix img src attributes starting with "/" with the module file URL
|
|
628
|
-
string moduleFileUrl = this->getFileUrl(this->_moduleStore.getModuleDataPath(module));
|
|
629
592
|
if (!moduleFileUrl.empty()) {
|
|
630
593
|
static string imgSrcSlash = "src=\"/";
|
|
631
594
|
string imgSrcReplacement = "src=\"" + moduleFileUrl + "/";
|
|
@@ -64,7 +64,6 @@ private:
|
|
|
64
64
|
int verseCount=-1);
|
|
65
65
|
|
|
66
66
|
std::string getCurrentChapterHeading(sword::SWModule* module, const std::string& moduleFileUrl);
|
|
67
|
-
std::string getCurrentPreverseHeading(sword::SWModule* module, const std::string& moduleFileUrl);
|
|
68
67
|
std::string getCurrentVerseText(sword::SWModule* module, bool hasStrongs, bool hasInconsistentClosingEndDivs, bool forceNoMarkup, const std::string& moduleFileUrl);
|
|
69
68
|
std::string getFilteredText(const std::string& text, int chapter, int verseNr, bool hasStrongs, bool hasInconsistentClosingEndDivs, const std::string& moduleFileUrl);
|
|
70
69
|
std::string getFileUrl(const std::string& nativePath);
|