node-sword-interface 1.0.99 → 1.0.100
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
|
@@ -71,7 +71,7 @@ string TextProcessor::getFileUrl(const string& nativePath)
|
|
|
71
71
|
#endif
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
string TextProcessor::getFilteredText(const string& text, int chapter, int verseNr, bool hasStrongs, bool hasInconsistentClosingEndDivs, const string&
|
|
74
|
+
string TextProcessor::getFilteredText(const string& text, int chapter, int verseNr, bool hasStrongs, bool hasInconsistentClosingEndDivs, const string& moduleFileUrl)
|
|
75
75
|
{
|
|
76
76
|
static string chapterFilter = "<chapter";
|
|
77
77
|
static regex pbElement = regex("<pb .*?/> ");
|
|
@@ -244,18 +244,17 @@ string TextProcessor::getFilteredText(const string& text, int chapter, int verse
|
|
|
244
244
|
filteredText = this->replaceSpacesInStrongs(filteredText);
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
// Prefix img src attributes starting with "/" with the module
|
|
248
|
-
if (!
|
|
249
|
-
string fileUrl = this->getFileUrl(moduleDataPath);
|
|
247
|
+
// Prefix img src attributes starting with "/" with the module file URL
|
|
248
|
+
if (!moduleFileUrl.empty()) {
|
|
250
249
|
static string imgSrcSlash = "src=\"/";
|
|
251
|
-
string imgSrcReplacement = "src=\"" +
|
|
250
|
+
string imgSrcReplacement = "src=\"" + moduleFileUrl + "/";
|
|
252
251
|
this->findAndReplaceAll(filteredText, imgSrcSlash, imgSrcReplacement);
|
|
253
252
|
}
|
|
254
253
|
|
|
255
254
|
return filteredText;
|
|
256
255
|
}
|
|
257
256
|
|
|
258
|
-
string TextProcessor::getCurrentChapterHeading(sword::SWModule* module)
|
|
257
|
+
string TextProcessor::getCurrentChapterHeading(sword::SWModule* module, const string& moduleFileUrl)
|
|
259
258
|
{
|
|
260
259
|
string currentModuleName = string(module->getName());
|
|
261
260
|
string chapterHeading = "";
|
|
@@ -288,8 +287,7 @@ string TextProcessor::getCurrentChapterHeading(sword::SWModule* module)
|
|
|
288
287
|
// Therefore we do not render chapter headings for the first verse of the chapter in this case.
|
|
289
288
|
chapterHeading = "";
|
|
290
289
|
} else {
|
|
291
|
-
|
|
292
|
-
chapterHeading = this->getFilteredText(chapterHeading, currentChapter, currentVerseNr, false, false, moduleDataPath);
|
|
290
|
+
chapterHeading = this->getFilteredText(chapterHeading, currentChapter, currentVerseNr, false, false, moduleFileUrl);
|
|
293
291
|
}
|
|
294
292
|
}
|
|
295
293
|
|
|
@@ -297,6 +295,12 @@ string TextProcessor::getCurrentChapterHeading(sword::SWModule* module)
|
|
|
297
295
|
}
|
|
298
296
|
|
|
299
297
|
string TextProcessor::getCurrentVerseText(sword::SWModule* module, bool hasStrongs, bool hasInconsistentClosingEndDivs, bool forceNoMarkup)
|
|
298
|
+
{
|
|
299
|
+
string moduleFileUrl = this->getFileUrl(this->_moduleStore.getModuleDataPath(module));
|
|
300
|
+
return this->getCurrentVerseText(module, hasStrongs, hasInconsistentClosingEndDivs, forceNoMarkup, moduleFileUrl);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
string TextProcessor::getCurrentVerseText(sword::SWModule* module, bool hasStrongs, bool hasInconsistentClosingEndDivs, bool forceNoMarkup, const string& moduleFileUrl)
|
|
300
304
|
{
|
|
301
305
|
string verseText;
|
|
302
306
|
string filteredText;
|
|
@@ -310,8 +314,7 @@ string TextProcessor::getCurrentVerseText(sword::SWModule* module, bool hasStron
|
|
|
310
314
|
filteredText = verseText;
|
|
311
315
|
|
|
312
316
|
if (!this->_rawMarkupEnabled) {
|
|
313
|
-
|
|
314
|
-
filteredText = this->getFilteredText(verseText, currentChapter, currentVerseNr, hasStrongs, hasInconsistentClosingEndDivs, moduleDataPath);
|
|
317
|
+
filteredText = this->getFilteredText(verseText, currentChapter, currentVerseNr, hasStrongs, hasInconsistentClosingEndDivs, moduleFileUrl);
|
|
315
318
|
}
|
|
316
319
|
} else {
|
|
317
320
|
verseText = string(module->stripText());
|
|
@@ -394,6 +397,9 @@ vector<Verse> TextProcessor::getVersesFromReferences(string moduleName, vector<s
|
|
|
394
397
|
bool moduleMarkupIsBroken = this->_moduleHelper.isBrokenMarkupModule(moduleName);
|
|
395
398
|
bool hasInconsistentClosingEndDivs = this->_moduleHelper.isInconsistentClosingEndDivModule(moduleName);
|
|
396
399
|
|
|
400
|
+
// Compute file URL once for the entire module
|
|
401
|
+
string moduleFileUrl = this->getFileUrl(this->_moduleStore.getModuleDataPath(module));
|
|
402
|
+
|
|
397
403
|
for (unsigned int i = 0; i < references.size(); i++) {
|
|
398
404
|
string currentReference = references[i];
|
|
399
405
|
string currentVerseText = "";
|
|
@@ -402,7 +408,7 @@ vector<Verse> TextProcessor::getVersesFromReferences(string moduleName, vector<s
|
|
|
402
408
|
bool entryExisting = module->hasEntry(module->getKey());
|
|
403
409
|
|
|
404
410
|
if (entryExisting) {
|
|
405
|
-
currentVerseText = this->getCurrentVerseText(module, false, hasInconsistentClosingEndDivs, moduleMarkupIsBroken);
|
|
411
|
+
currentVerseText = this->getCurrentVerseText(module, false, hasInconsistentClosingEndDivs, moduleMarkupIsBroken, moduleFileUrl);
|
|
406
412
|
}
|
|
407
413
|
|
|
408
414
|
Verse currentVerse;
|
|
@@ -450,6 +456,9 @@ vector<Verse> TextProcessor::getText(string moduleName, string key, QueryLimit q
|
|
|
450
456
|
} else {
|
|
451
457
|
bool hasStrongs = this->_moduleHelper.moduleHasGlobalOption(module, "Strongs");
|
|
452
458
|
|
|
459
|
+
// Compute file URL once for the entire module
|
|
460
|
+
string moduleFileUrl = this->getFileUrl(this->_moduleStore.getModuleDataPath(module));
|
|
461
|
+
|
|
453
462
|
module->setKey(key.c_str());
|
|
454
463
|
|
|
455
464
|
if (startVerseNumber >= 1) {
|
|
@@ -486,7 +495,7 @@ vector<Verse> TextProcessor::getText(string moduleName, string key, QueryLimit q
|
|
|
486
495
|
// and if the module markup is not broken
|
|
487
496
|
// and if the requested verse count is more than one or the default (-1 / all verses).
|
|
488
497
|
if (firstVerseInChapter && !moduleMarkupIsBroken && (verseCount > 1 || verseCount == -1)) {
|
|
489
|
-
string chapterHeading = this->getCurrentChapterHeading(module);
|
|
498
|
+
string chapterHeading = this->getCurrentChapterHeading(module, moduleFileUrl);
|
|
490
499
|
verseText += chapterHeading;
|
|
491
500
|
}
|
|
492
501
|
|
|
@@ -496,7 +505,8 @@ vector<Verse> TextProcessor::getText(string moduleName, string key, QueryLimit q
|
|
|
496
505
|
hasInconsistentClosingEndDivs,
|
|
497
506
|
// Note that if markup is broken this will enforce
|
|
498
507
|
// the usage of the "stripped" / non-markup variant of the text
|
|
499
|
-
moduleMarkupIsBroken
|
|
508
|
+
moduleMarkupIsBroken,
|
|
509
|
+
moduleFileUrl);
|
|
500
510
|
|
|
501
511
|
// If the current verse does not have any content and if it is the first verse in this book
|
|
502
512
|
// we assume that the book is not existing.
|
|
@@ -559,12 +569,11 @@ string TextProcessor::getBookIntroduction(string moduleName, string bookCode)
|
|
|
559
569
|
filteredText = regex_replace(filteredText, headEndElementFilter, "</div>");
|
|
560
570
|
filteredText = regex_replace(filteredText, chapterDivFilter, "");
|
|
561
571
|
|
|
562
|
-
// Prefix img src attributes starting with "/" with the module
|
|
563
|
-
string
|
|
564
|
-
if (!
|
|
565
|
-
string fileUrl = this->getFileUrl(moduleDataPath);
|
|
572
|
+
// Prefix img src attributes starting with "/" with the module file URL
|
|
573
|
+
string moduleFileUrl = this->getFileUrl(this->_moduleStore.getModuleDataPath(module));
|
|
574
|
+
if (!moduleFileUrl.empty()) {
|
|
566
575
|
static string imgSrcSlash = "src=\"/";
|
|
567
|
-
string imgSrcReplacement = "src=\"" +
|
|
576
|
+
string imgSrcReplacement = "src=\"" + moduleFileUrl + "/";
|
|
568
577
|
this->findAndReplaceAll(filteredText, imgSrcSlash, imgSrcReplacement);
|
|
569
578
|
}
|
|
570
579
|
}
|
|
@@ -63,8 +63,9 @@ private:
|
|
|
63
63
|
int startVerseNr=-1,
|
|
64
64
|
int verseCount=-1);
|
|
65
65
|
|
|
66
|
-
std::string getCurrentChapterHeading(sword::SWModule* module);
|
|
67
|
-
std::string
|
|
66
|
+
std::string getCurrentChapterHeading(sword::SWModule* module, const std::string& moduleFileUrl);
|
|
67
|
+
std::string getCurrentVerseText(sword::SWModule* module, bool hasStrongs, bool hasInconsistentClosingEndDivs, bool forceNoMarkup, const std::string& moduleFileUrl);
|
|
68
|
+
std::string getFilteredText(const std::string& text, int chapter, int verseNr, bool hasStrongs, bool hasInconsistentClosingEndDivs, const std::string& moduleFileUrl);
|
|
68
69
|
std::string getFileUrl(const std::string& nativePath);
|
|
69
70
|
std::string replaceSpacesInStrongs(const std::string& text);
|
|
70
71
|
unsigned int findAndReplaceAll(std::string & data, std::string toSearch, std::string replaceStr);
|