replace tables whose role is not presentation with divs for newsletters

This commit is contained in:
Hongbo Wu
2022-09-14 15:56:49 +08:00
parent 9b92a64232
commit 1563ef9131
3 changed files with 1715 additions and 1714 deletions

View File

@ -918,8 +918,8 @@ Readability.prototype = {
}
});
// replace tables of article content with divs for newsletters
this._keepTables && this._replaceNodeTags(this._getAllNodesWithTag(articleContent, ["table"]), "div");
// replace tables whose role is not presentation with divs for newsletters
this._keepTables && this._replaceNodeTags(this._getAllNodesWithTag(articleContent, ["table"]).filter(t => t.getAttribute("role") !== "presentation"), "div");
// Final clean up of nodes that might pass readability conditions but still contain redundant text
// For example, this article (https://www.sciencedirect.com/science/article/abs/pii/S0047248498902196)