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

remark-autolink-headings

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-autolink-headings - npm Package Compare versions

Comparing version 5.1.0 to 5.2.0

22

dist/index.js

@@ -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,

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