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

[newsfeed] Line break tags <br> should be replaced with spaces #3235

Closed
d42ohpaz opened this issue Oct 16, 2023 · 8 comments
Closed

[newsfeed] Line break tags <br> should be replaced with spaces #3235

d42ohpaz opened this issue Oct 16, 2023 · 8 comments

Comments

@d42ohpaz
Copy link

d42ohpaz commented Oct 16, 2023

As an example, if you look at the RSS feed for lemmy.world, you'll notice that it uses line breaks. Because the newsfeed module seems to strip out HTML (rightfully so), it causes some of the text to be butted up against each other:

Screenshot 2023-10-16 at 7 41 38 AM

Instead of stripping out <br> tags, it should replace them with a space (or non-breaking space (&nbsp;)).

@bugsounet
Copy link
Contributor

bugsounet commented Oct 16, 2023

Hi, I don’t know if that’s really intended but according to the code it removes the <...> tag and replaces it with nothing.

see original code in ~/MagicMirror/modules/default/newsfeed/newsfeedfetcher.js line 56

Try to replace this line by description = description.toString().replace(regex, " ");

maybe it will be better in your case

Result will be as you want:

image

@d42ohpaz
Copy link
Author

@bugsounet Yes, that's exactly the solution needed.

@rejas
Copy link
Collaborator

rejas commented Oct 17, 2023

That line is from waaaay back, maybe @MichMich can weigh in and tell if it can be replaced by the html-to-text library used directly below?

@MichMich
Copy link
Collaborator

I've got absolutely no idea anymore. 🙈

@rejas
Copy link
Collaborator

rejas commented Oct 17, 2023

I've got absolutely no idea anymore. 🙈

well, 7 years is a long time... but maybe its really just trying to get rid of any html tags. which looks weird with
in the text.

would just replacing those with an empty space " " look always okay I wonder?

@d42ohpaz do you want to code something (remove the regex and try to make a good looking description with some more options passed to the html-to-text library)?

@bugsounet
Copy link
Contributor

bugsounet commented Oct 17, 2023

I will inspect html-to-text library options because actually, without regex, It display web links. I don't think it's raeally neded to display this

For remember I add html-to-text library for delete &.... Html tag

@khassel khassel added the bug label Oct 18, 2023
rejas pushed a commit that referenced this issue Nov 11, 2023
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
@rejas
Copy link
Collaborator

rejas commented Nov 11, 2023

@d42ohpaz can you check if the latest develop branch fixes your problem?

@d42ohpaz
Copy link
Author

@d42ohpaz can you check if the latest develop branch fixes your problem?

Yup, looks fixed in latest develop branch. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants