Socket
Socket
Sign inDemoInstall

remark-external-links

Package Overview
Dependencies
5
Maintainers
14
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.1 to 3.1.0

30

index.js
var visit = require('unist-util-visit')
var definitions = require('mdast-util-definitions')
var spaceSeparated = require('space-separated-tokens').parse

@@ -22,19 +23,22 @@

function transform(tree) {
visit(tree, 'link', visitor)
}
var definition = definitions(tree)
function visitor(node) {
var data
var props
visit(tree, ['link', 'linkReference'], visitor)
if (node.url.charAt(0) !== '#' && !relative.test(node.url)) {
data = node.data || (node.data = {})
props = data.hProperties || (data.hProperties = {})
function visitor(node) {
var ctx = node.type === 'link' ? node : definition(node.identifier)
var data
var props
if (target !== false) {
props.target = target || defaultTarget
}
if (ctx && ctx.url.charAt(0) !== '#' && !relative.test(ctx.url)) {
data = node.data || (node.data = {})
props = data.hProperties || (data.hProperties = {})
if (rel !== false) {
props.rel = (rel || defaultRel).concat()
if (target !== false) {
props.target = target || defaultTarget
}
if (rel !== false) {
props.rel = (rel || defaultRel).concat()
}
}

@@ -41,0 +45,0 @@ }

{
"name": "remark-external-links",
"version": "3.0.1",
"version": "3.1.0",
"description": "Automatically adds the target and rel attributes to external links",

@@ -18,3 +18,3 @@ "license": "MIT",

"Cédric Delpoux <xuopled@gmail.com>",
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"Merlijn Vos <merlijn@soverin.net>"

@@ -26,2 +26,3 @@ ],

"dependencies": {
"mdast-util-definitions": "^1.2.3",
"space-separated-tokens": "^1.1.2",

@@ -35,3 +36,3 @@ "unist-util-visit": "^1.4.0"

"remark-cli": "^6.0.0",
"remark-html": "^8.0.0",
"remark-html": "^9.0.0",
"remark-preset-wooorm": "^4.0.0",

@@ -38,0 +39,0 @@ "xo": "^0.23.0"

@@ -1,3 +0,10 @@

# remark-external-links [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat]
# remark-external-links
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Chat][chat-badge]][chat]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
Add target and rel attributes to external links with [**remark**][remark].

@@ -72,15 +79,25 @@

[build-status]: https://travis-ci.org/remarkjs/remark-external-links
[build]: https://travis-ci.org/remarkjs/remark-external-links
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-external-links.svg
[coverage-status]: https://codecov.io/github/remarkjs/remark-external-links
[coverage]: https://codecov.io/github/remarkjs/remark-external-links
[chat-badge]: https://img.shields.io/gitter/room/remarkjs/Lobby.svg
[downloads-badge]: https://img.shields.io/npm/dm/remark-external-links.svg
[chat]: https://gitter.im/remarkjs/Lobby
[downloads]: https://www.npmjs.com/package/remark-external-links
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
[chat]: https://spectrum.chat/unified/remark
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[license]: license
[author]: http://xuopled.netlify.com
[author]: https://xuopled.netlify.com

@@ -87,0 +104,0 @@ [npm]: https://docs.npmjs.com/cli/install

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