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

Use html-to-text instead of regex for transform description #3264

Merged
merged 3 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ _This release is scheduled to be released on 2024-01-01._
### Updated

- Update electron to v27 and update other dependencies as well as github actions
- Update newsfeed: Use `html-to-text` instead of regex for transform description

### Fixed

Expand Down
11 changes: 8 additions & 3 deletions modules/default/newsfeed/newsfeedfetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
const url = item.url || item.link || "";

if (title && pubdate) {
const regex = /(<([^>]+)>)/gi;
description = description.toString().replace(regex, "");
// Convert HTML entities, codes and tag
description = htmlToText(description, { wordwrap: false });
description = htmlToText(description, {
wordwrap: false,
selectors: [
{ selector: "a", options: { ignoreHref: true, noAnchorUrl: true } },
{ selector: "br", format: "inlineSurround", options: { prefix: " " } },
{ selector: "img", format: "skip" }
]
});

items.push({
title: title,
Expand Down