Skip to content
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

Preserve videos in paragraphs #957

Open
yeefun opened this issue Feb 28, 2025 · 1 comment
Open

Preserve videos in paragraphs #957

yeefun opened this issue Feb 28, 2025 · 1 comment

Comments

@yeefun
Copy link

yeefun commented Feb 28, 2025

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @mozilla/[email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@mozilla/readability/Readability.js b/node_modules/@mozilla/readability/Readability.js
index b745aa0..970538b 100644
--- a/node_modules/@mozilla/readability/Readability.js
+++ b/node_modules/@mozilla/readability/Readability.js
@@ -715,11 +715,12 @@ Readability.prototype = {
     // Remove extra paragraphs
     this._removeNodes(this._getAllNodesWithTag(articleContent, ["p"]), function (paragraph) {
       var imgCount = paragraph.getElementsByTagName("img").length;
+      var videoCount = paragraph.getElementsByTagName("video").length;
       var embedCount = paragraph.getElementsByTagName("embed").length;
       var objectCount = paragraph.getElementsByTagName("object").length;
       // At this point, nasty iframes have been removed, only remain embedded video ones.
       var iframeCount = paragraph.getElementsByTagName("iframe").length;
-      var totalCount = imgCount + embedCount + objectCount + iframeCount;
+      var totalCount = imgCount + videoCount + embedCount + objectCount + iframeCount;
 
       return totalCount === 0 && !this._getInnerText(paragraph, false);
     });

If I don't apply this change, the video on this website will be removed.

Image

Do you think we can open a PR to fix it?

This issue body was partially generated by patch-package.

@yeefun yeefun changed the title Remove videos in paragraphs Preserve videos in paragraphs Feb 28, 2025
@gijsk
Copy link
Contributor

gijsk commented Feb 28, 2025

Sure, happy to look at a PR for this. See also e.g. #675 and some of the other issues tagged with the video tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants