- Truncate HTML String while preserving HTML tags and whole words.
- Split HTML String while preserving HTML tags and whole words.
If you're using node, you can run
npm install htmlsave.
htmlsave is also available via Bower (
bower install htmlsave)
Setting it up
htmlsave supports AMD (e.g. RequireJS), CommonJS (e.g. Node.js) and direct usage (e.g. loading globally with a <script> tag) loading methods. You should be able to do nearly anything, and then skip to the next section anyway and have it work. Just in case though, here's some specific examples that definitely do the right thing:
CommonsJS (e.g. Node)
var htmlsave = ;htmlsave;
AMD (e.g. RequireJS)
Directly in your web page:
Max characters allowed. Use
slice to split by word.
End truncated string with ellipsis. This option has no effect on
Copyright (c) 2016 Ben Zörb Licensed under the MIT license.