Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-inline-links

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-inline-links - npm Package Compare versions

Comparing version 3.1.3 to 4.0.0

55

index.js
'use strict'
var visit = require('unist-util-visit')
var remove = require('unist-util-remove')
var getDefinitions = require('mdast-util-definitions')

@@ -13,40 +12,40 @@

function transformer(tree) {
var reference = referenceFactory(tree, options)
var definitions = getDefinitions(tree, options)
visit(tree, ['imageReference', 'linkReference'], reference)
visit(tree, onvisit)
remove(tree, 'definition')
}
}
function onvisit(node, index, parent) {
var definition
var replacement
var image
// Factory to transform a reference based on `definitions`.
function referenceFactory(tree, options) {
var definitions = getDefinitions(tree, options)
if (node.type === 'definition') {
parent.children.splice(index, 1)
return [visit.SKIP, index]
}
return reference
if (node.type === 'imageReference' || node.type === 'linkReference') {
definition = definitions(node.identifier)
// Transform a reference based on bound `definitions`.
function reference(node, index, parent) {
var definition = definitions(node.identifier)
var replacement
var image
if (definition) {
image = node.type === 'imageReference'
if (definition) {
image = node.type === 'imageReference'
replacement = {
type: image ? 'image' : 'link',
url: definition.url,
title: definition.title
}
replacement = {
type: image ? 'image' : 'link',
url: definition.url,
title: definition.title
}
if (image) {
replacement.alt = node.alt
} else {
replacement.children = node.children
}
if (image) {
replacement.alt = node.alt
} else {
replacement.children = node.children
parent.children[index] = replacement
return [visit.SKIP, index]
}
}
parent.children[index] = replacement
}
}
}
{
"name": "remark-inline-links",
"version": "3.1.3",
"version": "4.0.0",
"description": "remark plugin to transform references and definitions into normal links and images",

@@ -9,2 +9,3 @@ "license": "MIT",

"remark",
"remark-plugin",
"plugin",

@@ -21,2 +22,6 @@ "mdast",

"bugs": "https://github.com/remarkjs/remark-inline-links/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",

@@ -27,5 +32,4 @@ "contributors": [

"dependencies": {
"mdast-util-definitions": "^1.1.1",
"unist-util-remove": "^1.0.0",
"unist-util-visit": "^1.1.0"
"mdast-util-definitions": "^2.0.0",
"unist-util-visit": "^2.0.0"
},

@@ -37,10 +41,10 @@ "files": [

"browserify": "^16.0.0",
"nyc": "^14.0.0",
"prettier": "^1.0.0",
"remark": "^10.0.0",
"remark-cli": "^6.0.0",
"remark-preset-wooorm": "^5.0.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"remark": "^11.0.0",
"remark-cli": "^7.0.0",
"remark-preset-wooorm": "^6.0.0",
"tape": "^4.0.0",
"tinyify": "^2.0.0",
"xo": "^0.24.0"
"xo": "^0.28.0"
},

@@ -47,0 +51,0 @@ "scripts": {

@@ -67,7 +67,13 @@ # remark-inline-links

Handle definitions as commonmark (`boolean`, default: `false`).
The default behaviour is to prefer the last found duplicate definition.
Handle definitions as CommonMark (`boolean`, default: `false`).
The default behavior is to prefer the last found duplicate definition.
Turn on to use CommonMark handling of duplicate definitions: use the first
definition, ignore duplicate definitions.
## Security
Use of `remark-inline-links` does not involve [**rehype**][rehype]
([**hast**][hast]) or user content so there are no openings for
[cross-site scripting (XSS)][xss] attacks.
## Related

@@ -92,4 +98,4 @@

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

@@ -125,3 +131,3 @@

[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg

@@ -145,1 +151,7 @@ [chat]: https://spectrum.chat/unified/remark

[remark]: https://github.com/remarkjs/remark
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[rehype]: https://github.com/rehypejs/rehype
[hast]: https://github.com/syntax-tree/hast
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc