Escape HTML entities like ♦
or ♦
to 💎
Use in either nodejs or the browser. It's really simple and works pretty fast.
Installation
Browser 🌎 : https://cdn.jsdelivr.net/npm/entity-escape@latest/index.min.js
Node.js 🛠 : npm install --save entity-escape
Usage
Browser:
var text1 = Entities.unescape('The big & and sparkly diamond ( almost ) glittered in the dark.');
var text2 = Entities.escape('This is a diamond ♦, watch it ◊');
console.log(text1,text2);
Node.js:
const Entities = require('entity-escape');
var text1 = Entities.unescape('The big & and sparkly diamond ( almost ) glittered in the dark.');
var text2 = Entities.escape('This is a diamond ♦, watch it ◊');
console.log(text1,text2);
Methods and Options
Entities.unescape(text,options);
Entities.escape(text,options);
In case {silent:true}
no output is rendered to the console. In case replaceNumbers:false
only those characters which are explicitly named HTML entities will be replaced.