markdown-it-external-link
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

markdown-it-external-link

NPM version Downloads AppVeyor Build Status

markdown-it plugin that adds target and rel attributes on external links.

Install

Via npm

npm install markdown-it-external-link

Via Yarn

yarn add markdown-it-external-link

Usage

const markdownit = require('markdown-it');
const markdownitExternalLink = require('../index').default;
const md = markdownit();

const testString = 'This is an [Example](http://example.com) link, [Google](https://google.com) link, [Facebook](https://facebook.com) link, [Test Example](http://test.example.com/) link, [Test2 Example](http://test2.example.com/) link and [Relative](/docs/concept/) link.';

// Mark http://example.com and http://test.example.com as internal domain.
md.use(markdownitExternalLink, {
  'hosts': [
    'http://example.com',
    'http://test.example.com'
  ]
});

console.log(md.render(testString));

Parameters

Attributes Type Required Default Description
hosts Array Yes [] Site hostname(s) to detect external links.
target String No _blank Specifies where to open the linked document.
rel String No noopener Specifies the relationship between the current document and the linked document.

Package Sidebar

Install

npm i markdown-it-external-link

Weekly Downloads

130

Version

1.1.0

License

MIT

Unpacked Size

11.9 kB

Total Files

12

Last publish

Collaborators

  • samiahmedsiddiqui