exclude additional elements based on their role (#619)

master
PalmerAL 4 years ago committed by GitHub
parent 3fe82816af
commit d5eea06a00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -141,6 +141,8 @@ Readability.prototype = {
jsonLdArticleTypes: /^Article|AdvertiserContentArticle|NewsArticle|AnalysisNewsArticle|AskPublicNewsArticle|BackgroundNewsArticle|OpinionNewsArticle|ReportageNewsArticle|ReviewNewsArticle|Report|SatiricalArticle|ScholarlyArticle|MedicalScholarlyArticle|SocialMediaPosting|BlogPosting|LiveBlogPosting|DiscussionForumPosting|TechArticle|APIReference$/
},
UNLIKELY_ROLES: [ "menu", "menubar", "complementary", "navigation", "alert", "alertdialog", "dialog" ],
DIV_TO_P_ELEMS: [ "A", "BLOCKQUOTE", "DL", "DIV", "IMG", "OL", "P", "PRE", "TABLE", "UL", "SELECT" ],
ALTER_TO_DIV_EXCEPTIONS: ["DIV", "ARTICLE", "SECTION", "P"],
@ -917,8 +919,8 @@ Readability.prototype = {
continue;
}
if (node.getAttribute("role") == "complementary") {
this.log("Removing complementary content - " + matchString);
if (this.UNLIKELY_ROLES.includes(node.getAttribute("role"))) {
this.log("Removing content with role " + node.getAttribute("role") + " - " + matchString);
node = this._removeAndGetNext(node);
continue;
}

@ -41,9 +41,5 @@
</div>
</article>
</main>
<section id="site-index">
<nav id="site-index-navigation" role="navigation">
</nav>
</section>
</div>
</div>

@ -44,9 +44,5 @@
</div>
</article>
</main>
<section id="site-index">
<nav id="site-index-navigation" role="navigation">
</nav>
</section>
</div>
</div>
Loading…
Cancel
Save