node-sword-interface 1.0.109 → 1.0.111
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/API.md
CHANGED
|
@@ -53,7 +53,7 @@ This is the main class of node-sword-interface and it provides a set of static f
|
|
|
53
53
|
* [.enableMarkup()](#NodeSwordInterface+enableMarkup)
|
|
54
54
|
* [.disableMarkup()](#NodeSwordInterface+disableMarkup)
|
|
55
55
|
* [.enableStrongsWithNbsp()](#NodeSwordInterface+enableStrongsWithNbsp)
|
|
56
|
-
* [.getRawModuleEntry(moduleCode, key)](#NodeSwordInterface+getRawModuleEntry) ⇒ <code>String</code>
|
|
56
|
+
* [.getRawModuleEntry(moduleCode, key, processImageUrls)](#NodeSwordInterface+getRawModuleEntry) ⇒ <code>String</code>
|
|
57
57
|
* [.getReferenceText(moduleCode, key)](#NodeSwordInterface+getReferenceText) ⇒ [<code>VerseObject</code>](#VerseObject)
|
|
58
58
|
* [.getChapterText(moduleCode, bookCode, chapter)](#NodeSwordInterface+getChapterText) ⇒ [<code>Array.<VerseObject></code>](#VerseObject)
|
|
59
59
|
* [.getBookText(moduleCode, bookCode, startVerseNr, verseCount)](#NodeSwordInterface+getBookText) ⇒ [<code>Array.<VerseObject></code>](#VerseObject)
|
|
@@ -346,7 +346,7 @@ Enables rendering of Strongs elements with non-breaking spaces.
|
|
|
346
346
|
**Kind**: instance method of [<code>NodeSwordInterface</code>](#NodeSwordInterface)
|
|
347
347
|
<a name="NodeSwordInterface+getRawModuleEntry"></a>
|
|
348
348
|
|
|
349
|
-
### nodeSwordInterface.getRawModuleEntry(moduleCode, key) ⇒ <code>String</code>
|
|
349
|
+
### nodeSwordInterface.getRawModuleEntry(moduleCode, key, processImageUrls) ⇒ <code>String</code>
|
|
350
350
|
Returns the raw text of an entry for the given module and key.
|
|
351
351
|
If no entry exists for the given key the return value is undefined.
|
|
352
352
|
|
|
@@ -356,6 +356,7 @@ If no entry exists for the given key the return value is undefined.
|
|
|
356
356
|
| --- | --- | --- |
|
|
357
357
|
| moduleCode | <code>String</code> | The module code of the SWORD module. |
|
|
358
358
|
| key | <code>String</code> | The key of the entry. |
|
|
359
|
+
| processImageUrls | <code>Boolean</code> | Whether to pre-process image URLs with platform-specific file paths (Optional, default: false). |
|
|
359
360
|
|
|
360
361
|
<a name="NodeSwordInterface+getReferenceText"></a>
|
|
361
362
|
|
package/deploy_local.sh
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
PROJECT_DIR='ezra-
|
|
3
|
+
PROJECT_DIR='ezra-project-git'
|
|
4
4
|
WORK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
5
5
|
rm -rf $WORK_DIR/../$PROJECT_DIR/node_modules/node-sword-interface
|
|
6
6
|
cp -a $WORK_DIR $WORK_DIR/../$PROJECT_DIR/node_modules/node-sword-interface
|
package/index.js
CHANGED
|
@@ -382,10 +382,11 @@ class NodeSwordInterface {
|
|
|
382
382
|
*
|
|
383
383
|
* @param {String} moduleCode - The module code of the SWORD module.
|
|
384
384
|
* @param {String} key - The key of the entry.
|
|
385
|
+
* @param {Boolean} processImageUrls - Whether to pre-process image URLs with platform-specific file paths (Optional, default: false).
|
|
385
386
|
* @return {String}
|
|
386
387
|
*/
|
|
387
|
-
getRawModuleEntry(moduleCode, key) {
|
|
388
|
-
return this.nativeInterface.getRawModuleEntry(moduleCode, key);
|
|
388
|
+
getRawModuleEntry(moduleCode, key, processImageUrls = false) {
|
|
389
|
+
return this.nativeInterface.getRawModuleEntry(moduleCode, key, processImageUrls);
|
|
389
390
|
}
|
|
390
391
|
|
|
391
392
|
/**
|
package/package.json
CHANGED
|
@@ -599,10 +599,12 @@ Napi::Value NodeSwordInterface::enableStrongsWithNbsp(const Napi::CallbackInfo&
|
|
|
599
599
|
Napi::Value NodeSwordInterface::getRawModuleEntry(const Napi::CallbackInfo& info)
|
|
600
600
|
{
|
|
601
601
|
lockApi();
|
|
602
|
-
INIT_SCOPE_AND_VALIDATE(ParamType::string, ParamType::string);
|
|
602
|
+
INIT_SCOPE_AND_VALIDATE(ParamType::string, ParamType::string, ParamType::boolean);
|
|
603
603
|
Napi::Env env = info.Env();
|
|
604
604
|
Napi::String moduleName = info[0].As<Napi::String>();
|
|
605
605
|
Napi::String key = info[1].As<Napi::String>();
|
|
606
|
+
Napi::Boolean processImageUrls = info[2].As<Napi::Boolean>();
|
|
607
|
+
|
|
606
608
|
ASSERT_SW_MODULE_EXISTS(moduleName);
|
|
607
609
|
|
|
608
610
|
SWModule* swordModule = this->_moduleStore->getLocalModule(moduleName);
|
|
@@ -610,7 +612,13 @@ Napi::Value NodeSwordInterface::getRawModuleEntry(const Napi::CallbackInfo& info
|
|
|
610
612
|
bool entryExisting = swordModule->hasEntry(swordModule->getKey());
|
|
611
613
|
|
|
612
614
|
if (entryExisting) {
|
|
613
|
-
|
|
615
|
+
string rawEntry = swordModule->getRawEntry();
|
|
616
|
+
|
|
617
|
+
if (processImageUrls) {
|
|
618
|
+
this->_textProcessor->processImageUrls(rawEntry, swordModule);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
Napi::String entryText = Napi::String::New(env, rawEntry);
|
|
614
622
|
unlockApi();
|
|
615
623
|
return entryText;
|
|
616
624
|
} else {
|
|
@@ -247,11 +247,7 @@ string TextProcessor::getFilteredText(const string& text, int chapter, int verse
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
// Prefix img src attributes starting with "/" with the module file URL
|
|
250
|
-
|
|
251
|
-
static string imgSrcSlash = "src=\"/";
|
|
252
|
-
string imgSrcReplacement = "src=\"" + moduleFileUrl + "/";
|
|
253
|
-
this->findAndReplaceAll(filteredText, imgSrcSlash, imgSrcReplacement);
|
|
254
|
-
}
|
|
250
|
+
this->processImageUrls(filteredText, moduleFileUrl);
|
|
255
251
|
|
|
256
252
|
return filteredText;
|
|
257
253
|
}
|
|
@@ -610,16 +606,27 @@ string TextProcessor::getBookIntroduction(string moduleName, string bookCode)
|
|
|
610
606
|
filteredText = regex_replace(filteredText, chapterDivFilter, "");
|
|
611
607
|
|
|
612
608
|
// Prefix img src attributes starting with "/" with the module file URL
|
|
613
|
-
|
|
614
|
-
static string imgSrcSlash = "src=\"/";
|
|
615
|
-
string imgSrcReplacement = "src=\"" + moduleFileUrl + "/";
|
|
616
|
-
this->findAndReplaceAll(filteredText, imgSrcSlash, imgSrcReplacement);
|
|
617
|
-
}
|
|
609
|
+
this->processImageUrls(filteredText, moduleFileUrl);
|
|
618
610
|
}
|
|
619
611
|
|
|
620
612
|
return filteredText;
|
|
621
613
|
}
|
|
622
614
|
|
|
615
|
+
void TextProcessor::processImageUrls(string& text, const string& moduleFileUrl)
|
|
616
|
+
{
|
|
617
|
+
if (!moduleFileUrl.empty()) {
|
|
618
|
+
static string imgSrcSlash = "src=\"/";
|
|
619
|
+
string imgSrcReplacement = "src=\"" + moduleFileUrl + "/";
|
|
620
|
+
this->findAndReplaceAll(text, imgSrcSlash, imgSrcReplacement);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
void TextProcessor::processImageUrls(string& text, sword::SWModule* module)
|
|
625
|
+
{
|
|
626
|
+
string moduleFileUrl = this->getFileUrl(this->_moduleStore.getModuleDataPath(module));
|
|
627
|
+
this->processImageUrls(text, moduleFileUrl);
|
|
628
|
+
}
|
|
629
|
+
|
|
623
630
|
string TextProcessor::replaceSpacesInStrongs(const string& text)
|
|
624
631
|
{
|
|
625
632
|
string input = text;
|
|
@@ -51,6 +51,9 @@ public:
|
|
|
51
51
|
|
|
52
52
|
StrongsEntry* getStrongsEntry(std::string key);
|
|
53
53
|
|
|
54
|
+
void processImageUrls(std::string& text, const std::string& moduleFileUrl);
|
|
55
|
+
void processImageUrls(std::string& text, sword::SWModule* module);
|
|
56
|
+
|
|
54
57
|
bool moduleHasStrongsZeroPrefixes(sword::SWModule* module);
|
|
55
58
|
bool moduleHasStrongsPaddedZeroPrefixes(sword::SWModule* module);
|
|
56
59
|
std::string padStrongsNumber(const std::string strongsNumber);
|