remark plugin to automatically add target and rel attributes to external links
Last updated 5 hours ago by wooorm .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install remark-external-links 
SYNC missed versions from official npm registry.


Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to automatically add target and rel attributes to external links.



npm install remark-external-links


Say we have the following file, example.js:

var remark = require('remark')
var html = require('remark-html')
var externalLinks = require('remark-external-links')

  .use(externalLinks, {target: false, rel: ['nofollow']})
  .process('[remark](', function(err, file) {
    if (err) throw err

Now, running node example yields:

<p><a href="" rel="nofollow">remark</a></p>


remark().use(externalLinks[, options])

Automatically add target and rel attributes to external links.


How to display referenced documents (string?: _self, _blank, _parent, or _top, default: _blank). Pass false to not set targets on links.


Link types to hint about the referenced documents (Array.<string> or string, default: ['nofollow', 'noopener', 'noreferrer']). Pass false to not set rels on links.

When using a target, add noopener and noreferrer to avoid exploitation of the window.opener API.


Protocols to check, such as mailto or tel (Array.<string>, default: ['http', 'https']).


hast content to insert at the end of external links (Node or Children). Will be inserted in a <span> element.

Useful for improving accessibility by giving users advanced warning when opening a new window.


Properties to add to the span wrapping content, when given.


options.content is used and injected into the tree when it’s given. This could open you up to a cross-site scripting (XSS) attack if you pass user provided content in.

This may become a problem if the Markdown later transformed to rehype (hast) or opened in an unsafe Markdown viewer.

Most likely though, this plugin will instead protect you from exploitation of the window.opener API.


See in remarkjs/.github for ways to get started. See for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.


MIT © Cédric Delpoux

Current Tags

  • 7.0.1                                ...           latest (5 hours ago)

13 Versions

  • 7.0.1                                ...           5 hours ago
  • 7.0.0                                ...           a month ago
  • 6.1.0                                ...           4 months ago
  • 6.0.0                                ...           6 months ago
  • 5.0.0                                ...           a year ago
  • 4.0.0                                ...           2 years ago
  • 3.1.1                                ...           2 years ago
  • 3.1.0                                ...           2 years ago
  • 3.0.1                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago

Copyright 2014 - 2017 © |