Skip to content

Commit

Permalink
Fix tabular data got removed
Browse files Browse the repository at this point in the history
  • Loading branch information
RadhiFadlillah authored and gijsk committed Mar 1, 2019
1 parent f70d368 commit 6a5066a
Show file tree
Hide file tree
Showing 4 changed files with 1,543 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Readability.js
Original file line number Diff line number Diff line change
Expand Up @@ -1628,11 +1628,16 @@ Readability.prototype = {
//
// TODO: Consider taking into account original contentScore here.
this._removeNodes(e.getElementsByTagName(tag), function(node) {
// First check if we're in a data table, in which case don't remove us.
// First check if this node IS data table, in which case don't remove it.
var isDataTable = function(t) {
return t._readabilityDataTable;
};

if (tag === "table" && isDataTable(node)) {
return false;
}

// Next check if we're inside a data table, in which case don't remove it as well.
if (this._hasAncestorTag(node, "table", -1, isDataTable)) {
return false;
}
Expand Down
7 changes: 7 additions & 0 deletions test/test-pages/keep-tabular-data/expected-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"title": "Friday Facts #282 - 0.17 in sight | Factorio",
"byline": null,
"excerpt": "Posted by kovarex, TOGos, Ernestas, Albert on 2019-02-15, all posts",
"readerable": true,
"siteName": "Factorio.com"
}
Loading

0 comments on commit 6a5066a

Please sign in to comment.