improve code (comment from PR #17)

This commit is contained in:
GotPPay
2018-04-11 11:00:33 +02:00
parent d69972da07
commit b5d66c950a

View File

@@ -28,15 +28,16 @@ getDataFromWPJSON = function (sourceUrl, page = 1, maxPosts = 10) {
}; };
summarizeText = function (text, length, clearText = true) { summarizeText = function (text, length, clearText = true) {
let preparedText = text;
if (clearText) { if (clearText) {
text = htmlToText.fromString (text, { preparedText = htmlToText.fromString (text, {
wordwrap: false, wordwrap: false,
ignoreHref: true, ignoreHref: true,
ignoreImage: true, ignoreImage: true,
}); });
} }
return summarizer (text, {n: length}); return summarizer (preparedText, {n: length});
}; };
getTitlesFromWP = function (sourceUrl) { getTitlesFromWP = function (sourceUrl) {