nodejs-html-truncate
nodejs-html-truncate copied to clipboard
Img attributes with single quotes result in invalid tags
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.