Skip to content
A tiny library to decode HTML numeric entities and basic XML named entities.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.babelrc
.gitignore Initial commit Aug 23, 2019
LICENSE.txt
README.md Fix wrong npm package name in usage example Aug 24, 2019
index.js
package.json Use Babel to build for ES5 Sep 4, 2019
rollup.config.js Use Babel to build for ES5 Sep 4, 2019

README.md

Simple Entity Decode

npm npm bundle size

A tiny library to decode HTML numeric entities and basic XML named entities.

Most entity libraries include complex handling for entities, and include the full list of named entities from the HTML specification. However, most applications and pages don't need this, and can instead normalise entities (e.g. on the server).

Specifically, this library decodes:

  • Basic named entities (&, ', ", <, >)
  • Numeric decimal entities (£)
  • Numeric hexadecimal entities (£)

It does not handle other named entities. Instead, normalise the entities on the server; for example in WordPress, you can use the ent2ncr function.

Usage

import decodeEntities from 'simple-entity-decode';

decodeEntities( 'Bill & Ted’s Excellent Adventure' );
// → "Bill & Ted’s Excellent Adventure"

Licence

Copyright 2019 Human Made. Licensed under the MIT license.

Uses code from he by Mathias Bynens. Used under the MIT license.

You can’t perform that action at this time.