node-sword-interface 1.0.100 → 1.0.101
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
|
@@ -294,6 +294,48 @@ 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
|
+
|
|
297
339
|
string TextProcessor::getCurrentVerseText(sword::SWModule* module, bool hasStrongs, bool hasInconsistentClosingEndDivs, bool forceNoMarkup)
|
|
298
340
|
{
|
|
299
341
|
string moduleFileUrl = this->getFileUrl(this->_moduleStore.getModuleDataPath(module));
|
|
@@ -408,7 +450,13 @@ vector<Verse> TextProcessor::getVersesFromReferences(string moduleName, vector<s
|
|
|
408
450
|
bool entryExisting = module->hasEntry(module->getKey());
|
|
409
451
|
|
|
410
452
|
if (entryExisting) {
|
|
411
|
-
|
|
453
|
+
// Add preverse heading before verse text
|
|
454
|
+
if (!moduleMarkupIsBroken) {
|
|
455
|
+
string preverseHeading = this->getCurrentPreverseHeading(module, moduleFileUrl);
|
|
456
|
+
currentVerseText += preverseHeading;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
currentVerseText += this->getCurrentVerseText(module, false, hasInconsistentClosingEndDivs, moduleMarkupIsBroken, moduleFileUrl);
|
|
412
460
|
}
|
|
413
461
|
|
|
414
462
|
Verse currentVerse;
|
|
@@ -499,6 +547,13 @@ vector<Verse> TextProcessor::getText(string moduleName, string key, QueryLimit q
|
|
|
499
547
|
verseText += chapterHeading;
|
|
500
548
|
}
|
|
501
549
|
|
|
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
|
+
|
|
502
557
|
// Current verse text
|
|
503
558
|
verseText += this->getCurrentVerseText(module,
|
|
504
559
|
hasStrongs,
|
|
@@ -64,6 +64,7 @@ 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);
|
|
67
68
|
std::string getCurrentVerseText(sword::SWModule* module, bool hasStrongs, bool hasInconsistentClosingEndDivs, bool forceNoMarkup, const std::string& moduleFileUrl);
|
|
68
69
|
std::string getFilteredText(const std::string& text, int chapter, int verseNr, bool hasStrongs, bool hasInconsistentClosingEndDivs, const std::string& moduleFileUrl);
|
|
69
70
|
std::string getFileUrl(const std::string& nativePath);
|