node-readability
Advanced tools
Comparing version 2.1.5 to 2.2.0
@@ -1,24 +0,4 @@ | ||
<a name="2.1.5"></a> | ||
## [2.1.5](https://github.com/luin/node-readability/compare/v2.1.4...v2.1.5) (2016-01-31) | ||
<a name="2.2.0"></a> | ||
## [2.2.0](https://github.com/luin/node-readability/compare/v2.1.5...v2.2.0) (2016-03-11) | ||
<a name="2.1.4"></a> | ||
## [2.1.4](https://github.com/luin/node-readability/compare/v2.1.3...v2.1.4) (2016-01-31) | ||
<a name="2.1.3"></a> | ||
## [2.1.3](https://github.com/luin/node-readability/compare/v2.1.2...v2.1.3) (2016-01-31) | ||
<a name="2.1.2"></a> | ||
## [2.1.2](https://github.com/luin/node-readability/compare/v2.1.1...v2.1.2) (2016-01-31) | ||
* Add `textBody` property. |
{ | ||
"name": "node-readability", | ||
"version": "2.1.5", | ||
"version": "2.2.0", | ||
"author": "Zihua Li", | ||
@@ -5,0 +5,0 @@ "description": "Turning any web page into a clean view.", |
@@ -110,2 +110,6 @@ # Readability | ||
### textBody | ||
A string containing all the text found on the page | ||
### html | ||
@@ -112,0 +116,0 @@ |
@@ -138,3 +138,3 @@ var url = require("url"); | ||
// If this paragraph is less than 25 characters, don't even count it. | ||
// If this paragraph is less than 25 characters, don't even count it. | ||
if (innerText.length < 25) continue; | ||
@@ -649,3 +649,3 @@ | ||
} | ||
if (node.attributes.itemscope) { | ||
@@ -652,0 +652,0 @@ node.readability.contentScore += 5; |
@@ -35,2 +35,5 @@ var jsdom = require('jsdom'); | ||
}); | ||
this.__defineGetter__('textBody', function() { | ||
return this.getTextBody(true); | ||
}); | ||
this.__defineGetter__('html', function() { | ||
@@ -100,2 +103,27 @@ return this.getHTML(true); | ||
Readability.prototype.getTextBody = function(notDeprecated) { | ||
if (!notDeprecated) { | ||
console.warn('The method `getTextBody()` is deprecated, using `textBody` property instead.'); | ||
} | ||
if (typeof this.cache['article-text-body'] !== 'undefined') { | ||
return this.cache['article-text-body']; | ||
} | ||
var articleContent = helpers.grabArticle(this._document); | ||
var rootElement = articleContent.childNodes[0]; | ||
var textBody = ''; | ||
if (rootElement) { | ||
var textElements = rootElement.childNodes; | ||
for (var i = 0; i < textElements.length; i++) { | ||
var el = textElements[i]; | ||
var text = helpers.getInnerText(el); | ||
if (!text) continue; | ||
textBody += text; | ||
if ((i + 1) < textElements.length) textBody += '\n'; | ||
} | ||
} | ||
return this.cache['article-text-body'] = textBody; | ||
} | ||
Readability.prototype.getDocument = function(notDeprecated) { | ||
@@ -102,0 +130,0 @@ if (!notDeprecated) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3537340
1380
140