diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7f4..b2bdec2d7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/lib/Readability.js b/lib/Readability.js index aa9167836..359fd947e 100644 --- a/lib/Readability.js +++ b/lib/Readability.js @@ -1316,6 +1316,101 @@ Readability.prototype = { return metadata; }, + /** + * Check if node is image, or if node contains exactly only one image + * whether as a direct child or as its descendants. + * + * @param Element + **/ + _isSingleImage: function(node) { + if (node.tagName === "IMG") { + return true; + } + + if (node.children.length !== 1 || node.textContent.trim() !== "") { + return false; + } + + return this._isSingleImage(node.children[0]); + }, + + /** + * Find all