This page is outdated

You are reading documentation for Linkify v2. Browse the latest v3+ documentation.

Jump To

Linkify HTML String Interface

linkify-html is an interface for replacing links with anchor tags within JavaScript strings containing HTML.

Installation

Node.js/Browserify

npm install linkifyjs
var linkifyHtml = require('linkifyjs/html');

or with ES6 modules

import linkifyHtml from 'linkifyjs/html';

AMD

<script src="linkify.amd.js"></script>
<script src="linkify-html.amd.js"></script>
<script>
  require(['linkify-html'], function (linkifyHtml) {
    // …
  });
</script>

Browser globals

<script src="linkify.js"></script>
<script src="linkify-html.js"></script>

Usage

var options = {/* … */};
var str = '<p>For help with GitHub.com, please email support@github.com</p>';
linkifyHtml(str, options);

Returns

'<p>For help with <a href="http://github.com" target="_blank">GitHub.com</a>, please email <a href="mailto:support@github.com">support@github.com</a></p>'

Params

  • String str String to linkify
  • Object [options] Options object

Returns String Linkified htmlString