1.0.17 • Published 1 year ago

html-truncator v1.0.17

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

html-truncator

This function takes in an HTML string and a maximum length and returns a truncated version of the HTML string that is no longer than the maximum length. The resulting string is valid HTML and ends with an ellipsis.

Install

npm i html-truncator

Usage

const htmlString = "<p>This is some long HTML text</p>";
const truncatedHtml = truncate(htmlString, 10);

console.log(truncatedHtml);
// Output: <p>This is so</p>...

Notes

This package uses the htmlparser2 package to parse the input HTML string and generate a DOM tree, which is then traversed recursively to build the truncated HTML string. The resulting string is valid HTML and ends with an ellipsis.

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago