huang47 / nodejs-html-truncate

truncate html text and keep tag safe
77 stars 30 forks source link

Problem handling entities #28

Open numscrl opened 6 years ago

numscrl commented 6 years ago

I'm seeing problems with properly entities, particularly with shorter strings. For example:

var truncate = require("html-truncate"); truncate( "<p>David &amp; Jenny</p>", 13, { ellipsis: "" } );

returns "David & J"

truncate( "<p>D&amp;C</p>", 4, { ellipsis: "" } );

returns "D&am"