remark-autolink-headings
Advanced tools
Comparing version 5.1.0 to 5.2.0
@@ -18,3 +18,3 @@ "use strict"; | ||
const behaviours = { | ||
const behaviors = { | ||
prepend: 'unshift', | ||
@@ -31,5 +31,6 @@ append: 'push' | ||
const defaults = { | ||
behaviour: 'prepend', | ||
behavior: 'prepend', | ||
content: contentDefaults | ||
}; | ||
let deprecationWarningIssued = false; | ||
@@ -39,3 +40,3 @@ function attacher(opts = {}) { | ||
linkProperties, | ||
behaviour, | ||
behavior, | ||
content | ||
@@ -45,5 +46,14 @@ } = _objectSpread({}, defaults, opts); | ||
let method; | ||
let hChildren; | ||
let hChildren; // NOTE: Remove in next major version | ||
if (behaviour === 'wrap') { | ||
if (opts.behaviour !== undefined) { | ||
if (!deprecationWarningIssued) { | ||
deprecationWarningIssued = true; | ||
console.warn('Deprecation Warning: `behaviour` is a nonstandard option. Use `behavior` instead.'); | ||
} | ||
behavior = opts.behaviour; | ||
} | ||
if (behavior === 'wrap') { | ||
method = wrap; | ||
@@ -75,3 +85,3 @@ } else { | ||
function inject(node, url) { | ||
node.children[behaviours[behaviour]]({ | ||
node.children[behaviors[behavior]]({ | ||
type: 'link', | ||
@@ -78,0 +88,0 @@ url, |
{ | ||
"name": "remark-autolink-headings", | ||
"version": "5.1.0", | ||
"version": "5.2.0", | ||
"description": "Automatically add links to headings in Markdown.", | ||
@@ -37,3 +37,3 @@ "license": "MIT", | ||
"babel-plugin-add-module-exports": "^1.0.0", | ||
"nyc": "^13.1.0", | ||
"nyc": "^14.0.0", | ||
"prettier": "^1.14.3", | ||
@@ -45,3 +45,3 @@ "remark": "^10.0.0", | ||
"remark-preset-wooorm": "^4.0.0", | ||
"xo": "^0.23.0" | ||
"xo": "^0.24.0" | ||
}, | ||
@@ -48,0 +48,0 @@ "scripts": { |
@@ -74,3 +74,3 @@ # remark-autolink-headings | ||
#### `options.behaviour` | ||
#### `options.behavior` | ||
@@ -94,3 +94,2 @@ How to create links (`string`, default: `'prepend'`). | ||
properties: {className: ['icon', 'icon-link']} | ||
children: [] | ||
} | ||
@@ -97,0 +96,0 @@ ``` |
@@ -10,7 +10,21 @@ import {readFileSync as read} from 'fs' | ||
const base = file => read(join(__dirname, 'fixtures', file), 'utf-8') | ||
const behaviors = ['append', 'prepend', 'wrap'] | ||
test('should autolink headings', t => { | ||
const behaviours = ['append', 'prepend', 'wrap'] | ||
behaviors.forEach(b => { | ||
t.is( | ||
remark() | ||
.use(slug) | ||
.use(html) | ||
.use(headings, {behavior: b}) | ||
.processSync(base('input.md')) | ||
.toString(), | ||
base(`output.${b}.html`), | ||
`should ${b} headings` | ||
) | ||
}) | ||
}) | ||
behaviours.forEach(b => { | ||
test('should autolink headings with deprecated option', t => { | ||
behaviors.forEach(b => { | ||
t.is( | ||
@@ -17,0 +31,0 @@ remark() |
import visit from 'unist-util-visit' | ||
import extend from 'extend' | ||
const behaviours = {prepend: 'unshift', append: 'push'} | ||
const behaviors = {prepend: 'unshift', append: 'push'} | ||
@@ -12,10 +12,24 @@ const contentDefaults = { | ||
const defaults = {behaviour: 'prepend', content: contentDefaults} | ||
const defaults = {behavior: 'prepend', content: contentDefaults} | ||
let deprecationWarningIssued = false | ||
export default function attacher(opts = {}) { | ||
let {linkProperties, behaviour, content} = {...defaults, ...opts} | ||
let {linkProperties, behavior, content} = {...defaults, ...opts} | ||
let method | ||
let hChildren | ||
if (behaviour === 'wrap') { | ||
// NOTE: Remove in next major version | ||
if (opts.behaviour !== undefined) { | ||
if (!deprecationWarningIssued) { | ||
deprecationWarningIssued = true | ||
console.warn( | ||
'Deprecation Warning: `behaviour` is a nonstandard option. Use `behavior` instead.' | ||
) | ||
} | ||
behavior = opts.behaviour | ||
} | ||
if (behavior === 'wrap') { | ||
method = wrap | ||
@@ -43,3 +57,3 @@ } else { | ||
function inject(node, url) { | ||
node.children[behaviours[behaviour]]({ | ||
node.children[behaviors[behavior]]({ | ||
type: 'link', | ||
@@ -46,0 +60,0 @@ url, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
14706
234
0
156