nodejs-html-truncate icon indicating copy to clipboard operation
nodejs-html-truncate copied to clipboard

Img attributes with single quotes result in invalid tags

Open vegetabill opened this issue 9 years ago • 0 comments

var trunc = require("html-truncate")
trunc("<p>osito<img src='http://example.com/img.jpg' width='100'/>oscuro</p>", 8)

Results in:

'<p>osito<im…</p>'

Note the truncated img tag. I tried it with and without keepImageTag and it didn't make a difference.

When you use double quotes for the src and width attributes, it behaves as expected. I tried the example with html-ellipsis and the above works as expected, preserving the img tag.

vegetabill avatar Oct 28 '15 20:10 vegetabill