Skip to content

Commit

Permalink
Convert HTML entities, codes and tag (#3191)
Browse files Browse the repository at this point in the history
related to PR [#3092](#3092)

maybe best way is using `html-to-text` library

sample: `&quotHello World&quot` will be transformed to `"Hello World"`
  • Loading branch information
bugsounet authored Sep 13, 2023
1 parent 7a1591b commit 91fd931
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 48 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ _This release is scheduled to be released on 2023-10-01._
- Fix electron width/heigth when using xrandr under bullseye
- Fix time issue with certain recurring events in calendar module
- Fix ipWhiteList test (#3179)
- Fix newsfeed: Convert HTML entities, codes and tag in description (#3191)

## [2.24.0] - 2023-07-01

Expand Down
3 changes: 3 additions & 0 deletions modules/default/newsfeed/newsfeedfetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
const stream = require("stream");
const FeedMe = require("feedme");
const iconv = require("iconv-lite");
const { htmlToText } = require("html-to-text");
const Log = require("logger");
const NodeHelper = require("node_helper");

Expand Down Expand Up @@ -53,6 +54,8 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
if (title && pubdate) {
const regex = /(<([^>]+)>)/gi;
description = description.toString().replace(regex, "");
// Convert HTML entities, codes and tag
description = htmlToText(description, { wordwrap: false });

items.push({
title: title,
Expand Down
184 changes: 136 additions & 48 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"express-ipfilter": "^1.3.1",
"feedme": "^2.0.2",
"helmet": "^7.0.0",
"html-to-text": "^9.0.5",
"iconv-lite": "^0.6.3",
"luxon": "^1.28.1",
"module-alias": "^2.2.3",
Expand Down

0 comments on commit 91fd931

Please sign in to comment.