1.1.0 • Published 7 months ago

markdown-it-external-link v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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

AttributesTypeRequiredDefaultDescription
hostsArrayYes[]Site hostname(s) to detect external links.
targetStringNo_blankSpecifies where to open the linked document.
relStringNonoopenerSpecifies the relationship between the current document and the linked document.
1.1.0

7 months ago

1.0.1

9 months ago

1.0.0

9 months ago