Skip to content

Commit

Permalink
Use html-to-text instead of regex for transform description (MagicM…
Browse files Browse the repository at this point in the history
…irrorOrg#3264)

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

it's will solve issue MagicMirrorOrg#3235 

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

Thanks for feedbacks
  • Loading branch information
bugsounet authored Nov 11, 2023
1 parent 203e864 commit 70ddd80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit 70ddd80

Please sign in to comment.