Truncates a HTML string to a maximum length and optionally adds an ellipsis while preserving the HTML structure.
Usage
String truncatedHtml = htmlEllsipsis('<div>Some <strong>cool</strong> example HTML</div>', 9);
// <div>Some <strong>cool</strong></div>
You can also optionally add the ellipsis character.
String truncatedHtml = htmlEllsipsis('<div>Some cool example HTML</div>', 9, addEllipsis: true);
// <div>Some cool…</div>
Additional information
This package is a Dart port of the awesome TypeScript library made by alexghr.