image

text-clipper is a library for truncating text, both plain text and HTML. With the new 2.2 release, it gained a powerful new ability: stripping tags from HTML input.

Example:

const clipped = clip(
    “<p>Hello <img alt=‘Beautiful’ src=‘#’> World, everyone!</p>”,
    15,
    { html: true, stripTags: [“img”] }
);
// clipped == “<p>Hello  World, …</p>”