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

I try to use only `html-to-text` library

it's will solve issue #3235 

@rejas, @sdetweil, @khassel: Can you do tests with your own feeds?

Thanks for feedbacks
This commit is contained in:
Bugsounet - Cédric 2023-11-11 09:13:16 +01:00 committed by GitHub
parent 203e8647d4
commit 70ddd80632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -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,