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

Doesn't work with <img /> tags, somehow #5

Open
rlipscombe opened this issue Nov 2, 2013 · 2 comments
Open

Doesn't work with <img /> tags, somehow #5

rlipscombe opened this issue Nov 2, 2013 · 2 comments

Comments

@rlipscombe
Copy link

var t = require('html-truncate');
t('<ul><li><img src="image-1" /><img src="image-2" /></li></ul>', 40);

...returns

<ul><li><img src="image-2" /><img src="image-2" />

...rather than anything sensible.

Moreover, increasing the requested length doesn't fix it (passing 1000 instead of 40) gives the same result.

@rlipscombe
Copy link
Author

So, thinking it might be a problem with the <img />, rather than <img>, I tried the following:

t('<ul><li><img src="image-1"><img src="image-2"></li></ul>', 1000);

...which returns:

<ul><li><img src="image-2"></li></ul></li></ul>

...which is still wrong. Where did the first image go?

@orourkedd
Copy link

I had the same problem, but with <br> tags. The issue seems to be that its trying to close the tags. For example, this:

<br>test

becomes:

<br>tes</br>

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

2 participants