he
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
'he' is a robust HTML entity encoder/decoder written in JavaScript, known for its comprehensive support for HTML named character references and Unicode symbols, including astral ones. When it comes to handling ambiguous ampersands and other edge cases, 'he' operates just like a browser would, promising true-to-spec behavior and reliable performance. It is powered by an extensive test suite and stands out from many other JavaScript solutions owing to its adept handling of astral Unicode symbols.
Using 'he' is quite straightforward, and it can be used in different JavaScript environments, be it Node.js, a web browser, or even Rhino. First, you need to install the package using npm:
npm install he
Then, in a typical Node.js environment, you require 'he' as follows:
var he = require('he');
The main functionality of 'he' comes through its encode
and decode
methods. You can use encode
to encode text into HTML entities:
he.encode('foo Β© bar β baz π qux');
// The output will be: 'foo © bar ≠ baz 𝌆 qux'
Similarly, you can decode HTML entities back into text using decode
:
he.decode('foo © bar ≠ baz 𝌆 qux');
// The output will be: 'foo Β© bar β baz π qux'
Additional customization can be achieved by using the options object available for both the encode
and decode
methods.
The documentation for 'he' can be found in the README file of the package on its GitHub repository, which is located at https://github.com/mathiasbynens/he. It includes a thorough walk-through of how to install and use 'he', a detailed explanation of the API and its options, as well as examples for various use cases.