html-linkify
Turn plain text links into HTML anchor elements
Last updated 5 years ago by parshap .
Public Domain · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install html-linkify 
SYNC missed versions from official npm registry.

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="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:

  • options.attributes: A mapping of attributes to be added to the generated anchor elements (in addition to href).
  • options.escape: Whether surrounding HTML tags should be escaped or not (default: true).

Todo

  • Allow arbitrary user-definable replacing

Installation

npm install html-linkify

Current Tags

  • 1.2.2                                ...           latest (5 years ago)

6 Versions

  • 1.2.2                                ...           5 years ago
  • 1.2.1                                ...           6 years ago
  • 1.2.0                                ...           6 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 9
Last Day 0
Last Week 3
Last Month 10
Dependencies (1)
Dev Dependencies (1)

Copyright 2014 - 2017 © taobao.org |