New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 5.0.0 to 6.0.0

index.d.ts

73

index.js

@@ -1,51 +0,50 @@

'use strict'
/**
* @typedef {import('mdast').Root} Root
* @typedef {import('mdast').Image} Image
* @typedef {import('mdast').Link} Link
*/
var visit = require('unist-util-visit')
var getDefinitions = require('mdast-util-definitions')
import {visit, SKIP} from 'unist-util-visit'
import {definitions} from 'mdast-util-definitions'
module.exports = inlineLinks
/**
* Plugin to transform references and definitions into normal links and images.
*
* @type {import('unified').Plugin<void[], Root>}
*/
export default function remarkInlineLinks() {
return (tree) => {
const definition = definitions(tree)
function inlineLinks() {
return transformer
function transformer(tree) {
var definitions = getDefinitions(tree)
visit(tree, onvisit)
function onvisit(node, index, parent) {
var definition
var replacement
var image
if (node.type === 'definition') {
visit(tree, (node, index, parent) => {
if (
node.type === 'definition' &&
parent !== null &&
typeof index === 'number'
) {
parent.children.splice(index, 1)
return [visit.SKIP, index]
return [SKIP, index]
}
if (node.type === 'imageReference' || node.type === 'linkReference') {
definition = definitions(node.identifier)
const def = definition(node.identifier)
/* istanbul ignore else - plugins could inject undefined references. */
if (definition) {
image = node.type === 'imageReference'
if (def && parent !== null && typeof index === 'number') {
/** @type {Image|Link} */
const replacement =
node.type === 'imageReference'
? {type: 'image', url: def.url, title: def.title, alt: node.alt}
: {
type: 'link',
url: def.url,
title: def.title,
children: node.children
}
replacement = {
type: image ? 'image' : 'link',
url: definition.url,
title: definition.title
}
if (image) {
replacement.alt = node.alt
} else {
replacement.children = node.children
}
parent.children[index] = replacement
return [visit.SKIP, index]
return [SKIP, index]
}
}
}
})
}
}
{
"name": "remark-inline-links",
"version": "5.0.0",
"version": "6.0.0",
"description": "remark plugin to transform references and definitions into normal links and images",

@@ -29,35 +29,36 @@ "license": "MIT",

],
"dependencies": {
"mdast-util-definitions": "^4.0.0",
"unist-util-visit": "^2.0.0"
},
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.d.ts",
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"mdast-util-definitions": "^5.0.0",
"unified": "^10.0.0",
"unist-util-visit": "^4.0.0"
},
"devDependencies": {
"browserify": "^16.0.0",
"nyc": "^15.0.0",
"@types/tape": "^4.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark": "^13.0.0-alpha.0",
"remark-cli": "^8.0.0",
"remark-preset-wooorm": "^7.0.0",
"remark": "^14.0.0",
"remark-cli": "^10.0.0",
"remark-preset-wooorm": "^8.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"tinyify": "^3.0.0",
"xo": "^0.33.0"
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"xo": "^0.43.0"
},
"scripts": {
"format": "remark . -qfo && prettier . --write && xo --fix",
"build-bundle": "browserify . -s remarkInlineLinks > remark-inline-links.js",
"build-mangle": "browserify . -s remarkInlineLinks -p tinyify > remark-inline-links.min.js",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run format && npm run build && npm run test-coverage"
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {

@@ -72,7 +73,3 @@ "tabWidth": 2,

"xo": {
"prettier": true,
"esnext": false,
"ignores": [
"remark-inline-links.js"
]
"prettier": true
},

@@ -83,3 +80,9 @@ "remarkConfig": {

]
},
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true,
"ignoreCatch": true
}
}

@@ -23,2 +23,5 @@ # remark-inline-links

This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
[npm][]:

@@ -42,13 +45,15 @@

And our script, `example.js`, looks as follows:
And our module, `example.js`, looks as follows:
```js
var fs = require('fs')
var remark = require('remark')
var links = require('remark-inline-links')
import fs from 'node:fs'
import remark from 'remark'
import remarkInlineLinks from 'remark-inline-links'
const buf = fs.readFileSync('example.md')
remark()
.use(links)
.process(fs.readFileSync('example.md'), function(err, file) {
if (err) throw err
.use(remarkInlineLinks)
.process(buf)
.then((file) => {
console.log(String(file))

@@ -68,4 +73,7 @@ })

### `remark().use(inlineLinks)`
This package exports no identifiers.
The default export is `remarkInlineLinks`.
### `unified().use(remarkInlineLinks)`
Plugin to transform references and definitions into normal links and images.

@@ -81,4 +89,2 @@

* [`remark-bookmarks`](https://github.com/ben-eb/remark-bookmarks)
— Link manager
* [`remark-reference-links`](https://github.com/remarkjs/remark-reference-links)

@@ -109,5 +115,5 @@ — Reverse of `remark-inline-links`, thus rewriting normal links and images

[build-badge]: https://img.shields.io/travis/remarkjs/remark-inline-links/main.svg
[build-badge]: https://github.com/remarkjs/remark-inline-links/workflows/main/badge.svg
[build]: https://travis-ci.org/remarkjs/remark-inline-links
[build]: https://github.com/remarkjs/remark-inline-links/actions

@@ -114,0 +120,0 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-inline-links.svg

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