parshap / html-linkify

Turn plain text links into safe HTML anchor elements
11 stars 5 forks source link

html-linkify

Replace any links and emails found in your text with HTML anchor elements and return properly escaped and safe HTML.

Example

var linkify = require("html-linkify");
var text = linkify(
    "Visit http://foo.com!\n" +
    "Email me@me.com\n" +
    "<script>alert('xss!')</script>");
console.log(text);
// -> Visit <a href="http://foo.com">http://foo.com</a>!
//    Email <a href="https://github.com/parshap/html-linkify/blob/master/mailto:me@me.com">me@me.com</a>
//    &lt;script&gt;alert(&#39;xss!&#39;)&lt;/script&gt;

API

linkify(text, [options])

Replace any links found in the input text with anchor elements.

Options:

Todo

Installation

npm install html-linkify