0.0.3 • Published 5 years ago

simple-entity-decode v0.0.3

Weekly downloads
1,748
License
MIT
Repository
-
Last release
5 years ago

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.