mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-26 03:52:28 +00:00
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:
parent
203e8647d4
commit
70ddd80632
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user