No bug, update Readability to github tip, rs=me

This commit is contained in:
Margaret Leibovic 2015-04-03 11:08:25 -04:00
Родитель 37f3daf0c7
Коммит 709ab91d5d
1 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -1567,6 +1567,39 @@ Readability.prototype = {
this._flags = this._flags & ~flag;
},
/**
* Decides whether or not the document is reader-able without parsing the whole thing.
*
* @return boolean Whether or not we suspect parse() will suceeed at returning an article object.
*/
isProbablyReaderable: function() {
var nodes = this._doc.getElementsByTagName("p");
if (nodes.length < 5) {
return false;
}
var possibleParagraphs = 0;
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
var matchString = node.className + " " + node.id;
if (this.REGEXPS.unlikelyCandidates.test(matchString) &&
!this.REGEXPS.okMaybeItsACandidate.test(matchString)) {
continue;
}
if (node.textContent.trim().length < 100) {
continue;
}
possibleParagraphs++;
if (possibleParagraphs >= 5) {
return true;
}
}
return false;
},
/**
* Runs readability.
*