keep the market-info class in morning brew newsletters

This commit is contained in:
Hongbo Wu
2022-09-15 16:22:12 +08:00
parent fa5370c3e2
commit 8ff356d3bc

View File

@ -226,7 +226,7 @@ Readability.prototype = {
// These are the classes that readability sets itself.
CLASSES_TO_PRESERVE: [
"page", "twitter-tweet", "tweet-placeholder", "instagram-placeholder",
"page", "twitter-tweet", "tweet-placeholder", "instagram-placeholder", "morning-brew-markets"
],
// Classes of placeholder elements that can be empty but shouldn't be removed
@ -831,9 +831,10 @@ Readability.prototype = {
* @return void
**/
_prepArticle: async function (articleContent) {
// 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");
if (this._keepTables) {
// replace tables which is not a preserve class with divs for newsletters
this._replaceNodeTags(this._getAllNodesWithTag(articleContent, ["table"]).filter(t => !this._classesToPreserve.includes(t.className)), "div");
}
await this._createPlaceholders(articleContent);
this._cleanStyles(articleContent);
// Check for data tables before we continue, to avoid removing items in
@ -877,7 +878,7 @@ Readability.prototype = {
// Do these last as the previous stuff may have removed junk
// that will affect these
!this._keepTables && this._cleanConditionally(articleContent, "table");
this._cleanConditionally(articleContent, "table");
this._cleanConditionally(articleContent, "ul");
this._cleanConditionally(articleContent, "div");