-
Notifications
You must be signed in to change notification settings - Fork 633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed Lists of Images Not Showing #738
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have a few things to address. Thanks for working on this!
Readability.js
Outdated
@@ -2109,6 +2109,7 @@ Readability.prototype = { | |||
var embedCount = 0; | |||
var embeds = this._getAllNodesWithTag(node, ["object", "embed", "iframe"]); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We can remove this empty line
Readability.js
Outdated
} | ||
} | ||
// Allow lists of images to remain, so long as img count doesn't exceed li count | ||
if (img > 1 && img <= (li+100)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we add 100 to li
here?
Readability.js
Outdated
} | ||
} | ||
// Allow lists of images to remain, so long as img count doesn't exceed li count | ||
if (img > 1 && img <= (li+100)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we add 100 to li
here?
Readability.js
Outdated
@@ -2136,6 +2137,29 @@ Readability.prototype = { | |||
(!isList && weight < 25 && linkDensity > 0.2) || | |||
(weight >= 25 && linkDensity > 0.5) || | |||
((embedCount === 1 && contentLength < 75) || embedCount > 1); | |||
|
|||
if (haveToRemove) { | |||
// Check for lists of images |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having comments on each line, could we have one comment at the beginning explaining why we are doing this check?
Readability.js
Outdated
@@ -2136,6 +2137,29 @@ Readability.prototype = { | |||
(!isList && weight < 25 && linkDensity > 0.2) || | |||
(weight >= 25 && linkDensity > 0.5) || | |||
((embedCount === 1 && contentLength < 75) || embedCount > 1); | |||
|
|||
if (haveToRemove) { | |||
// Check for lists of images |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having comments on each line, could we have one comment at the beginning explaining why we are doing this check?
Readability.js
Outdated
@@ -2109,6 +2109,7 @@ Readability.prototype = { | |||
var embedCount = 0; | |||
var embeds = this._getAllNodesWithTag(node, ["object", "embed", "iframe"]); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this extra newline
Readability.js
Outdated
if (node.children[x].localName == "li") { | ||
if (node.children[x].children.length > 1) { | ||
return true; | ||
} | ||
} else { | ||
return true; | ||
} | ||
} | ||
li_count = node.getElementsByTagName("li").length; | ||
if (img > 1 && img <= (li_count)) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (node.children[x].localName == "li") { | |
if (node.children[x].children.length > 1) { | |
return true; | |
} | |
} else { | |
return true; | |
} | |
} | |
li_count = node.getElementsByTagName("li").length; | |
if (img > 1 && img <= (li_count)) { | |
return false; | |
} | |
let child = node.children[x]; | |
if (child.localName == "li" && child.children.length) { | |
return true; | |
} | |
li_count = node.getElementsByTagName("li").length; | |
if (img > 1 && img <= (li_count)) { | |
return false; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a good idea to document here why we remove some images for this specific case. It's not immediately clear to me here.
Readability.js
Outdated
if (node.children[x].localName == "li") { | ||
if (node.children[x].children.length > 1) { | ||
return true; | ||
} | ||
} else { | ||
return true; | ||
} | ||
} | ||
li_count = node.getElementsByTagName("li").length; | ||
if (img > 1 && img <= (li_count)) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a good idea to document here why we remove some images for this specific case. It's not immediately clear to me here.
It looks like we have one failing test here. Could you investigate it? |
Nice! Thanks @Tuxy222 . Do you think we can create a test case for this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have a nit to fix. Otherwise, I think this is good
Co-authored-by: niklasbaumgardner <63427453+niklasbaumgardner@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Will this be merged? Or why not? |
I think this just got lost. I just merged it. |
(Thanks for the ping!) |
This change allows for lists of images within the content of the page to be present in reader mode.
Related to: #697