Skip to content

Commit

Permalink
add exception for wikimedia math images
Browse files Browse the repository at this point in the history
  • Loading branch information
PalmerAL authored and gijsk committed Feb 27, 2020
1 parent 56ecc4d commit 61ef00a
Show file tree
Hide file tree
Showing 5 changed files with 4,041 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Readability-readerable.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ var REGEXPS = {
};

function isNodeVisible(node) {
// Have to null-check node.style to deal with SVG and MathML nodes.
return (!node.style || node.style.display != "none") && !node.hasAttribute("hidden")
&& (!node.hasAttribute("aria-hidden") || node.getAttribute("aria-hidden") != "true");
// Have to null-check node.style and node.className.indexOf to deal with SVG and MathML nodes.
return (!node.style || node.style.display != "none")
&& !node.hasAttribute("hidden")
//check for "fallback-image" so that wikimedia math images are displayed
&& (!node.hasAttribute("aria-hidden") || node.getAttribute("aria-hidden") != "true" || (node.className && node.className.indexOf && node.className.indexOf("fallback-image") !== -1));
}

/**
Expand Down
4 changes: 3 additions & 1 deletion Readability.js
Original file line number Diff line number Diff line change
Expand Up @@ -1796,9 +1796,11 @@ Readability.prototype = {
},

_isProbablyVisible: function(node) {
// Have to null-check node.style and node.className.indexOf to deal with SVG and MathML nodes.
return (!node.style || node.style.display != "none")
&& !node.hasAttribute("hidden")
&& (!node.hasAttribute("aria-hidden") || node.getAttribute("aria-hidden") != "true");
//check for "fallback-image" so that wikimedia math images are displayed
&& (!node.hasAttribute("aria-hidden") || node.getAttribute("aria-hidden") != "true" || (node.className && node.className.indexOf && node.className.indexOf("fallback-image") !== -1));
},

/**
Expand Down
8 changes: 8 additions & 0 deletions test/test-pages/wikipedia-3/expected-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"title": "Hermitian matrix - Wikipedia",
"byline": null,
"dir": "ltr",
"excerpt": "In mathematics, a Hermitian matrix (or self-adjoint matrix) is a complex square matrix that is equal to its own conjugate transpose—that is, the element in the i-th row and j-th column is equal to the complex conjugate of the element in the j-th row and i-th column, for all indices i and j:",
"siteName": null,
"readerable": true
}
Loading

0 comments on commit 61ef00a

Please sign in to comment.