diff --git a/plugins/links/article/article.js b/plugins/links/article/article.js index 21b8770a2..505547520 100644 --- a/plugins/links/article/article.js +++ b/plugins/links/article/article.js @@ -8,10 +8,11 @@ export default { const articleHtml = utils.encodeText(meta.charset, readability.getHTML()); const $p = cheerio.load(articleHtml)('p'); + const articleText = $p.text(); - if ($p.text()) { + if (articleText) { return { - articlebody: articleHtml + articlebody: __readabilityEnabled === 'html' ? articleHtml : articleText.replace(/\.([^\.\d\s\n\r\'\"\”\)\]])/g, '. $1') } } }, diff --git a/plugins/links/article/check-article.js b/plugins/links/article/check-article.js index d4bfce1f4..f7a0cdb87 100644 --- a/plugins/links/article/check-article.js +++ b/plugins/links/article/check-article.js @@ -14,15 +14,18 @@ export default { || meta.twitter?.card === 'summary_large_image' || meta.article)) - && (options.getRequestOptions('readability.articlebody', false) || CONFIG.providerOptions?.app?.allow_readability === true)) { + && (options.getRequestOptions('readability.articlebody') || CONFIG.providerOptions?.app?.allow_readability === true)) { - if (ld?.articlebody && /\/>/.test(ld.articlebody)) { + const article_format = (options.getRequestOptions('readability.articlebody') === 'html' + || CONFIG.providerOptions?.app?.allow_readability === true) ? 'html' : 'txt'; + + if (ld?.articlebody && (article_format !== 'html' || /\/>/.test(ld.articlebody))) { return { articlebody: ld.articlebody } } else if (options.getProviderOptions('app.allow_readability')) { return { - __readabilityEnabled: true + __readabilityEnabled: article_format } } } diff --git a/plugins/links/article/reader.js b/plugins/links/article/reader.js index 78c94a4f9..3d496baa7 100644 --- a/plugins/links/article/reader.js +++ b/plugins/links/article/reader.js @@ -1,7 +1,7 @@ export default { - getData: function(articlebody) { - if (CONFIG.providerOptions?.app?.allow_readability === true && !CONFIG.SKIP_IFRAMELY_RENDERS) { + getData: function(__readabilityEnabled, articlebody) { + if (__readabilityEnabled === 'html' && CONFIG.providerOptions?.app?.allow_readability === true && !CONFIG.SKIP_IFRAMELY_RENDERS) { return { safe_html: articlebody }