Package Exports
- stringify-entities
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stringify-entities) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
stringify-entities

Encode HTML character references and character entities.
- Very fast;
- Just the encoding part;
- Reliable:
"`"
characters are escaped to ensure no scripts run in IE6-8. Additionally, only named entities recognized by HTML4 are encoded, meaning the infamous'
(which people think is a virus) won’t show up.
Installation
npm:
npm install stringify-entities
stringify-entities is also available as an AMD, CommonJS, and globals module, uncompressed and compressed.
Usage
var stringify = require('stringify-entities');
stringify.encode('alpha © bravo ≠ charlie 𝌆 delta');
Yields:
alpha © bravo ≠ charlie 𝌆 delta
…and with useNamedReferences: true
.
stringify.encode('alpha © bravo ≠ charlie 𝌆 delta', { useNamedReferences: true });
Yields:
alpha © bravo ≠ charlie 𝌆 delta
API
stringifyEntities(value[, options])
Encode special characters in value
.
options
options.escapeOnly
Whether to only escape possibly dangerous characters (boolean
,
default: false
). Those characters are "
, '
, <
, >
&
, and
`
.
options.subset
Whether to only escape the given subset of characters (Array.<string>
).
options.useNamedReferences
Whether to use entities where possible (boolean?
, default: false
).
options.omitOptionalSemicolons
Whether to use omit semi-colons when possible. This creates parse
errors: don’t do this unless when building a minifier (boolean?
,
default: false
).
Omitting semi-colons is possible for certain legacy named references, and numeric entities, in some cases.
options.attribute
Only needed when operating dangerously with omitOptionalSemicolons: true
.
Create entities which don’t fail in attributes (boolean?
, default:
false
).