Based on unescape from jonschlinkert but updated for ES6
Install
Install with yarn:
$ yarn add unescape
Usage
const unescape = ;// or for TypeScript:// import { unescape } from 'unescape-es6'; console;//=> '<div>abc</div>' // use template tagsconsole; // => '<div>abc</div>' // or with variablesconst unescaped = '<div>unescaped</div>';console; //=> 'awesome text with some <div>unescaped</div> section'
Characters
For performance, this library only handles the following common entities
Only the following entities are converted by default.
Character | Description | Entity Name | Entity Decimal | Entity Hex |
---|---|---|---|---|
" |
double quotation mark | " |
" |
" |
' |
single quotation mark (apostrophe) | ' |
' |
' |
& |
ampersand | & |
& |
& |
> |
greater than | > |
> |
> |
< |
less than | < |
< |
< |
|
Single regular space | |
N.A |
  |
© |
copyright | © |
© |
© |
¢ |
cent | ¢ |
¢ |
¢ |
® |
registered trademark | ® |
® |
® |
€ |
euro | € |
€ |
N.A. |
£ |
pound | £ |
£ |
£ |
¥ |
yen | ¥ |
¥ |
¥ |
You can also print characters in runtime:
const charSets = ; console;
About
Alternatives
If you need a more robust implementation, try one of the following libraries:
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
License
Copyright © 2018-2019, Favna. Released under the MIT License.
Buy me a donut
This project is open source and always will be, even if I don't get donations. That said, I know there are people out there that may still want to donate just to show their appreciation so this is for you guys. Thanks in advance!
I accept donations through PayPal, BitCoin, Ethereum and LiteCoin. You can use the buttons below to donate through your method of choice
Donate With | QR | Address |
---|---|---|
Donate with PayPal | ||
1E643TNif2MTh75rugepmXuq35Tck4TnE5 | ||
0xF653F666903cd8739030D2721bF01095896F5D6E | ||
LZHvBkaJqKJRa8N7Dyu41Jd1PDBAofCik6 |