Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Library does not truncate text of links #21

Open
damianwojakowski opened this issue Jul 1, 2016 · 5 comments
Open

Library does not truncate text of links #21

damianwojakowski opened this issue Jul 1, 2016 · 5 comments

Comments

@damianwojakowski
Copy link

damianwojakowski commented Jul 1, 2016

Hi there!

I started using this library some time ago and I've noticed that it is not truncating links.

If I have a link, e.g.

<a href="someUrl">SomeLongTextOfALinkEvenLongerThanThis</a>

then this library is always going to display the whole text (I mean the "SomeLongTextOfALinkEvenLongerThanThis"), it does not truncate it.

Another thing - If you have a clickable block of text from a source that you don't control (e.g. RSS channel), then there's no way to simply truncate it with this library - you need to do additional work.

Please, have a look at this problem.

Regards,

  • Damian Wojakowski.
@sshaw
Copy link

sshaw commented Jul 22, 2016

Do you have an example? I just tried this, and it worked:

~/code/js/html-trunc >node
> var truncate = require('html-truncate');
undefined
> truncate('<a href="someUrl">SomeLongTextOfALinkEvenLongerThanThis</a>', 4)
'<a href="someUrl">Some...</a>'
> truncate('<p><div><a href="someUrl">SomeLongTextOfALinkEvenLongerThanThis</a>hello world</div></p>', 4)
'<p><div><a href="someUrl">Some...</a></div></p>'

@damianwojakowski
Copy link
Author

Hi,

I gave you just a simple example (not real) to describe what's the problem.

This library has problems with links. I used it at work (for a project similar to facebook), we had ton's of links there and some business rules for truncating links on many "components" (e.g. profiles, chatbox), this library had problems with truncating quite a lot of links.

Finally we replaced it with another lib that handled the problems.

I don't remember what kind of liks were they and I don't have time to test it now. Just try a few possibilities.

Maybe when there's a link in tag (instead of text), or maybe when the words in tag are separated. It definatelly did not work for long links (like I described it above, e.g. when you got a lot of text from RSS source and you wanted to make it clickable.

Regards,
Damian Wojakowski.

@sshaw
Copy link

sshaw commented Jul 25, 2016

Have you seen/tried this?

@damianwojakowski
Copy link
Author

No, I haven't. I tried other libarary.

@Noushad-web
Copy link

I encountered a similar issue where the library fails to function properly with hyperlinks. In my experience, this resulted in unexpected behavior, including triggering an infinite loop that caused browser hang-ups.

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

No branches or pull requests

3 participants