Socket
Socket
Sign inDemoInstall

remark-external-links

Package Overview
Dependencies
6
Maintainers
1
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
1
Install size
128 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

Automatically adds the target and rel attributes to external links.

Install

npm:

npm install remark-external-links --save

yarn:

yarn add remark-external-links

Example

remark-external-links is designed to work with remark-html. It add the target and rel attributes to external links.

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

// OR

import externalLinks from "remark-external-links"
import html from "remark-html"
import remark from "remark"

remark()
  .use(externalLinks, {
      target: null,
      rel: "nofollow",
  })
  .use(html)
  .process("[remark](https://github.com/gnab/remark)")

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

Note that this module must be included before remark-html.

API

options
target

Type: string Default: _blank

Specifies where to display the linked URL. The value should be on of : _self, _blank, _parent, _top

You can specify null to do not add the target attribute to your links

rel

Type: string Default: nofollow noopener noreferrer

Specifies the relationship of the target object to the link object. The value is a space-separated list of link types.

You can specify null to do not add the rel attribute to your links

When using target, consider adding rel="noopener noreferrer" to avoid exploitation of the window.opener API.

Changelog

See changelog

Contributing

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

Development

Clean lib folder

npm run clean

Build lib folder

npm run build

Lint src folder

npm run lint

Test src folder

npm run test

License

MIT

Keywords

FAQs

Last updated on 26 Jan 2017

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