source: trip-planner-front/node_modules/html-entities/README.md@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[6a3a178]1html-entities
2=============
3
4[![Build Status](https://travis-ci.org/mdevils/node-html-entities.svg?branch=master)](https://travis-ci.org/mdevils/node-html-entities)
5[![Coverage Status](https://coveralls.io/repos/mdevils/node-html-entities/badge.svg?branch=master&service=github)](https://coveralls.io/github/mdevils/node-html-entities?branch=master)
6
7Fast html entities library.
8
9
10Installation
11------------
12
13```bash
14$ npm install html-entities
15```
16
17Usage
18-----
19
20**XML entities**
21
22HTML validity and XSS attack prevention you can achieve from XmlEntities class.
23
24```javascript
25const Entities = require('html-entities').XmlEntities;
26
27const entities = new Entities();
28
29console.log(entities.encode('<>"\'&©®')); // &lt;&gt;&quot;&apos;&amp;©®
30console.log(entities.encodeNonUTF('<>"\'&©®')); // &lt;&gt;&quot;&apos;&amp;&#169;&#174;
31console.log(entities.encodeNonASCII('<>"\'&©®')); // <>"\'&©®
32console.log(entities.decode('&lt;&gt;&quot;&apos;&amp;&copy;&reg;&#8710;')); // <>"'&&copy;&reg;∆
33```
34
35**All HTML entities encoding/decoding**
36
37
38```javascript
39const Entities = require('html-entities').AllHtmlEntities;
40
41const entities = new Entities();
42
43console.log(entities.encode('<>"&©®∆')); // &lt;&gt;&quot;&amp;&copy;&reg;∆
44console.log(entities.encodeNonUTF('<>"&©®∆')); // &lt;&gt;&quot;&amp;&copy;&reg;&#8710;
45console.log(entities.encodeNonASCII('<>"&©®∆')); // <>"&©®&#8710;
46console.log(entities.decode('&lt;&gt;&quot;&amp;&copy;&reg;')); // <>"&©®
47```
48
49**Available classes**
50
51```javascript
52const XmlEntities = require('html-entities').XmlEntities, // <>"'& + &#...; decoding
53 Html4Entities = require('html-entities').Html4Entities, // HTML4 entities.
54 Html5Entities = require('html-entities').Html5Entities, // HTML5 entities.
55 AllHtmlEntities = require('html-entities').AllHtmlEntities; // Synonym for HTML5 entities.
56```
57
58Supports four methods for every class:
59
60* encode — encodes, replacing characters to its entity representations. Ignores UTF characters with no entity representation.
61* encodeNonUTF — encodes, replacing characters to its entity representations. Inserts numeric entities for UTF characters.
62* encodeNonASCII — encodes, replacing only non-ASCII characters to its numeric entity representations.
63* decode — decodes, replacing entities to characters. Unknown entities are left as is.
Note: See TracBrowser for help on using the repository browser.