[Pkg-javascript-commits] [node-htmlescape] 02/12: Clarify README

Bastien Roucariès rouca at moszumanska.debian.org
Sun Aug 20 13:48:42 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-htmlescape.

commit dd849114fb09d5fa33e2a4efce4608e7bdfeb72a
Author: Andres Suarez <zertosh at gmail.com>
Date:   Sun Sep 28 18:37:15 2014 -0400

    Clarify README
---
 README.md     | 21 ++++++++++++++++++++-
 htmlescape.js |  9 +++------
 package.json  |  2 +-
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 5622a45..870ba16 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,17 @@
 # htmlescape
 
-Proper escaping of JSON for usage as an object literal inside of a `<script>` tag. Use `htmlescape` in place of `JSON.stringify`. For more info see [JSON: The JavaScript subset that isn't](http://timelessrepo.com/json-isnt-a-javascript-subset).
+Properly escape JSON for usage as an object literal inside of a `<script>` tag. Use `htmlescape` in place of `JSON.stringify`. For more info see [JSON: The JavaScript subset that isn't](http://timelessrepo.com/json-isnt-a-javascript-subset).
+
+## Transformations
+
+| from     | to        |
+| -------- |:---------:|
+| `&`      | `\\u0026` |
+| `>`      | `\\u003e` |
+| `<`      | `\\u003c` |
+| `\u2028` | `\\u2028` |
+| `\u2029` | `\\u2029` |
+
 
 ## Usage
 
@@ -9,3 +20,11 @@ var htmlescape = require('htmlescape');
 htmlescape({prop:'value'});
 //=> '{"prop":"value"}'
 ```
+
+Or in your templates:
+
+```html
+<script>
+var payload = <%= htmlescape(payload) %>;
+</script>
+```
diff --git a/htmlescape.js b/htmlescape.js
index dec4c88..62119b4 100644
--- a/htmlescape.js
+++ b/htmlescape.js
@@ -1,10 +1,7 @@
 /**
- * Proper escaping of JSON for usage as an object literal inside
- * of a `<script>` tag.
- *
- * js implementation of http://golang.org/pkg/encoding/json/#HTMLEscape
- *
- * more info: http://timelessrepo.com/json-isnt-a-javascript-subset
+ * Properly escape JSON for usage as an object literal inside of a `<script>` tag.
+ * JS implementation of http://golang.org/pkg/encoding/json/#HTMLEscape
+ * More info: http://timelessrepo.com/json-isnt-a-javascript-subset
  */
 
 'use strict';
diff --git a/package.json b/package.json
index f0546f4..a443eef 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "htmlescape",
   "version": "0.0.1",
-  "description": "htmlescape",
+  "description": "Properly escape JSON for usage as an object literal inside of a `<script>` tag",
   "keywords": [
     "escape",
     "encoding",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-htmlescape.git



More information about the Pkg-javascript-commits mailing list