Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit c20a835410977c1e078653219a79cb10c84e7b3c 0 parents
@tj tj authored
Showing with 54 additions and 0 deletions.
  1. +2 −0  .gitignore
  2. +11 −0 Makefile
  3. +15 −0 Readme.md
  4. +10 −0 component.json
  5. +16 −0 index.js
2  .gitignore
@@ -0,0 +1,2 @@
+components
+build
11 Makefile
@@ -0,0 +1,11 @@
+
+build: components index.js
+ @component build
+
+components:
+ @Component install
+
+clean:
+ rm -fr build components template.js
+
+.PHONY: clean
15 Readme.md
@@ -0,0 +1,15 @@
+
+# escape-html
+
+ Escape HTML entities
+
+## Example
+
+```js
+var escape = require('html-escape');
+escape(str);
+```
+
+## License
+
+ MIT
10 component.json
@@ -0,0 +1,10 @@
+{
+ "name": "escape-html",
+ "description": "Escape HTML entities",
+ "version": "0.0.1",
+ "keywords": ["escape", "html", "utility"],
+ "dependencies": {},
+ "scripts": [
+ "index.js"
+ ]
+}
16 index.js
@@ -0,0 +1,16 @@
+
+/**
+ * Escape special characters in the given string of html.
+ *
+ * @param {String} html
+ * @return {String}
+ * @api private
+ */
+
+module.exports = function(html) {
+ return String(html)
+ .replace(/&/g, '&')
+ .replace(/"/g, '"')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;');
+}
Please sign in to comment.
Something went wrong with that request. Please try again.