caoge c760052ff9 机车状态修改 | 8 mesiacov pred | |
---|---|---|
.. | ||
lib | 8 mesiacov pred | |
LICENSE | 8 mesiacov pred | |
README.md | 8 mesiacov pred | |
package.json | 8 mesiacov pred |
Fast html entities library.
$ npm install html-entities
XML entities
HTML validity and XSS attack prevention you can achieve from XmlEntities class.
const Entities = require('html-entities').XmlEntities;
const entities = new Entities();
console.log(entities.encode('<>"\'&©®')); // <>"'&©®
console.log(entities.encodeNonUTF('<>"\'&©®')); // <>"'&©®
console.log(entities.encodeNonASCII('<>"\'&©®')); // <>"\'&©®
console.log(entities.decode('<>"'&©®∆')); // <>"'&©®∆
All HTML entities encoding/decoding
const Entities = require('html-entities').AllHtmlEntities;
const entities = new Entities();
console.log(entities.encode('<>"&©®∆')); // <>"&©®∆
console.log(entities.encodeNonUTF('<>"&©®∆')); // <>"&©®∆
console.log(entities.encodeNonASCII('<>"&©®∆')); // <>"&©®∆
console.log(entities.decode('<>"&©®')); // <>"&©®
Available classes
const XmlEntities = require('html-entities').XmlEntities, // <>"'& + &#...; decoding
Html4Entities = require('html-entities').Html4Entities, // HTML4 entities.
Html5Entities = require('html-entities').Html5Entities, // HTML5 entities.
AllHtmlEntities = require('html-entities').AllHtmlEntities; // Synonym for HTML5 entities.
Supports four methods for every class: