You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,11 @@
1
1
# lean-he
2
2
3
-
_lean-he_ (for “HTML entities”) is a robust HTML entity encoder/decoder written in JavaScript. It supports [all standardized named character references as per HTML](https://html.spec.whatwg.org/multipage/syntax.html#named-character-references), handles [ambiguous ampersands](https://mathiasbynens.be/notes/ambiguous-ampersands) and other edge cases [just like a browser would](https://html.spec.whatwg.org/multipage/syntax.html#tokenizing-character-references), has an extensive test suite, and — contrary to many other JavaScript solutions — _lean-he_ handles astral Unicode symbols just fine. [An online demo is available.](https://mothereff.in/html-entities)
4
-
It is forked from [he](https://github.com/mathiasbynens/he).
3
+
_lean-he_ (for “HTML entities”) is a robust HTML entity encoder/decoder written in JavaScript. It supports [all standardized named character references as per HTML](https://html.spec.whatwg.org/multipage/syntax.html#named-character-references), handles [ambiguous ampersands](https://mathiasbynens.be/notes/ambiguous-ampersands) and other edge cases [just like a browser would](https://html.spec.whatwg.org/multipage/syntax.html#tokenizing-character-references), has an extensive test suite, and — contrary to many other JavaScript solutions — _lean-he_ handles astral Unicode symbols just fine.
4
+
You can get a hint of how it works from [an online demo is available.](https://mothereff.in/html-entities) created by the same creator of original [he](https://github.com/mathiasbynens/he) library.
5
+
This was created keeping bundling in mind. It will help in creating leaner bundle by using only the specific function developers needs, like if a use case requires only encoding then using `lean-he/encode`
6
+
will result in only encode file to be bundle leaving rest of the code hence creating leaner bundle.
7
+
8
+
**It is forked from [he](https://github.com/mathiasbynens/he) with minute changes to make it leaner and all thanks to it's author.**
5
9
6
10
## Installation
7
11
@@ -37,7 +41,7 @@ load('lean-he.js');
37
41
38
42
This function takes a string of text and encodes (by default) any symbols that aren’t printable ASCII symbols and `&`, `<`, `>`, `"`, `'`, and `` ` ``, replacing them with character references.
39
43
40
-
>Can also use `var encode = require('encode');` instead to reduce the imported file size if the only need is to encode.
44
+
>Can also use `var encode = require('lean-he/encode');` instead to reduce the imported file size if the only need is to encode.
This function takes a string of HTML and decodes any named and numerical character references in it using [the algorithm described in section 12.2.4.69 of the HTML spec](https://html.spec.whatwg.org/multipage/syntax.html#tokenizing-character-references).
187
191
188
-
>Can also use `var decode = require('decode');` instead to reduce the imported file size if the only need is to encode.
192
+
>Can also use `var decode = require('lean-he/decode');` instead to reduce the imported file size if the only need is to decode.
This function takes a string of text and escapes it for use in text contexts in XML or HTML documents. Only the following characters are escaped: `&`, `<`, `>`, `"`, `'`, and `` ` ``.
261
265
262
-
>Can also use `var escape = require('escape');` instead to reduce the imported file size if the only need is to encode.
266
+
>Can also use `var escape = require('lean-he/escape');` instead to reduce the imported file size if the only need is to escape.
0 commit comments