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

remark-inline-links

Package Overview
Dependencies
Maintainers
1
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.0 to 3.1.1

54

index.js

@@ -1,19 +0,18 @@

'use strict';
'use strict'
var visit = require('unist-util-visit');
var remove = require('unist-util-remove');
var getDefinitions = require('mdast-util-definitions');
var visit = require('unist-util-visit')
var remove = require('unist-util-remove')
var getDefinitions = require('mdast-util-definitions')
module.exports = inlineLinks;
module.exports = inlineLinks
function inlineLinks(options) {
return transformer;
return transformer
function transformer(tree) {
var reference = referenceFactory(tree, options);
var reference = referenceFactory(tree, options)
remove(tree, 'definition');
visit(tree, ['imageReference', 'linkReference'], reference)
visit(tree, 'imageReference', reference);
visit(tree, 'linkReference', reference);
remove(tree, 'definition')
}

@@ -24,31 +23,30 @@ }

function referenceFactory(tree, options) {
var definitions = getDefinitions(tree, options);
var definitions = getDefinitions(tree, options)
return reference;
return reference
/* Transform a reference based on bound `definitions`. */
function reference(node, index, parent) {
var definition = definitions(node.identifier);
var replacement;
var definition = definitions(node.identifier)
var replacement
var image
if (definition) {
if (node.type === 'imageReference') {
replacement = {
type: 'image',
url: definition.url,
title: definition.title,
alt: node.alt
};
image = node.type === 'imageReference'
replacement = {
type: image ? 'image' : 'link',
url: definition.url,
title: definition.title
}
if (image) {
replacement.alt = node.alt
} else {
replacement = {
type: 'link',
url: definition.url,
title: definition.title,
children: node.children
};
replacement.children = node.children
}
parent.children[index] = replacement;
parent.children[index] = replacement
}
}
}
{
"name": "remark-inline-links",
"version": "3.1.0",
"version": "3.1.1",
"description": "Transform references and definitions into normal links and images",

@@ -30,20 +30,20 @@ "license": "MIT",

"devDependencies": {
"browserify": "^14.0.0",
"esmangle": "^1.0.0",
"nyc": "^11.0.0",
"remark": "^8.0.0",
"remark-cli": "^4.0.0",
"remark-preset-wooorm": "^3.0.0",
"browserify": "^16.0.0",
"nyc": "^12.0.0",
"prettier": "^1.14.2",
"remark": "^9.0.0",
"remark-cli": "^5.0.0",
"remark-preset-wooorm": "^4.0.0",
"tape": "^4.4.0",
"xo": "^0.18.0"
"tinyify": "^2.4.3",
"xo": "^0.22.0"
},
"scripts": {
"build-md": "remark . -qfo",
"build-bundle": "browserify index.js -s remarkInlineLinks > remark-inline-links.js",
"build-mangle": "esmangle remark-inline-links.js > remark-inline-links.min.js",
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint": "xo",
"format": "remark . -qfo && prettier --write \"**/*.js\" && 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 build && npm run lint && npm run test-coverage"
"test": "npm run format && npm run build && npm run test-coverage"
},

@@ -56,4 +56,12 @@ "nyc": {

},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"space": true,
"prettier": true,
"esnext": false,

@@ -60,0 +68,0 @@ "ignores": [

@@ -29,12 +29,12 @@ # remark-inline-links [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat]

```javascript
var fs = require('fs');
var remark = require('remark');
var links = require('remark-inline-links');
var fs = require('fs')
var remark = require('remark')
var links = require('remark-inline-links')
remark()
.use(links)
.process(fs.readFileSync('example.md'), function (err, file) {
if (err) throw err;
console.log(String(file));
});
.process(fs.readFileSync('example.md'), function(err, file) {
if (err) throw err
console.log(String(file))
})
```

@@ -79,3 +79,3 @@

See [`contribute.md` in `remarkjs/remarkjs`][contribute] for ways to get
See [`contributing.md` in `remarkjs/remark`][contributing] for ways to get
started.

@@ -112,4 +112,4 @@

[contribute]: https://github.com/remarkjs/remark/blob/master/contributing.md
[contributing]: https://github.com/remarkjs/remark/blob/master/contributing.md
[coc]: https://github.com/remarkjs/remark/blob/master/code-of-conduct.md
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