Socket
Socket
Sign inDemoInstall

remark-external-links

Package Overview
Dependencies
6
Maintainers
5
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    remark-external-links

Automatically adds the target and rel attributes to external links


Version published
Maintainers
5
Install size
59.6 kB
Created

Package description

What is remark-external-links?

The remark-external-links package is a plugin for the Remark Markdown processor that automatically modifies links in Markdown files. It is primarily used to add attributes like target and rel to external links, enhancing security and usability without manual HTML tagging.

What are remark-external-links's main functionalities?

Adding attributes to external links

This feature allows users to automatically add specific attributes such as target='_blank' and rel='nofollow noopener noreferrer' to external links in Markdown content. This enhances security by preventing tabnapping and improves SEO through 'nofollow'. The code sample demonstrates how to set up the plugin with Remark to process a simple Markdown string.

const remark = require('remark');
const html = require('remark-html');
const externalLinks = require('remark-external-links');

remark()
  .use(externalLinks, {target: '_blank', rel: ['nofollow', 'noopener', 'noreferrer']})
  .use(html)
  .process('Check out [Google](https://google.com)!', function (err, file) {
    console.log(String(file));
  });

Other packages similar to remark-external-links

Readme

Source

Build Coverage Downloads Chat Sponsors Backers

Add target and rel attributes to external links with remark.

Installation

npm:

npm install remark-external-links

Usage

Say we have the following file, example.js:

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

remark()
  .use(externalLinks, {target: false, rel: ['nofollow']})
  .use(html)
  .process('[remark](https://github.com/remarkjs/remark)', function(err, file) {
    if (err) throw err
    console.log(String(file))
  })

Now, running node example yields:

<p><a href="https://github.com/remarkjs/remark" rel="nofollow">remark</a></p>

API

Add target and rel attributes to external links.

options.target

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

options.rel

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.

options.protocols

Allows additional protocols to be checked; such as mailto:, tel:, etc. (Array.<string>, default: ['http', 'https']).

Contribute

See contributing.md in remarkjs/remark for ways to get started.

This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Cédric Delpoux

Keywords

FAQs

Last updated on 04 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc