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

rehype-slug

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rehype-slug - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

license

26

index.js

@@ -1,25 +0,25 @@

'use strict';
'use strict'
var slugs = require('github-slugger')();
var visit = require('unist-util-visit');
var toString = require('hast-util-to-string');
var is = require('hast-util-is-element');
var has = require('hast-util-has-property');
var slugs = require('github-slugger')()
var visit = require('unist-util-visit')
var toString = require('hast-util-to-string')
var is = require('hast-util-is-element')
var has = require('hast-util-has-property')
module.exports = slug;
module.exports = slug
var headings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
var headings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
function slug() {
return transformer;
return transformer
}
function transformer(tree) {
slugs.reset();
slugs.reset()
visit(tree, 'element', function (node) {
visit(tree, 'element', function(node) {
if (is(node, headings) && !has(node, 'id')) {
node.properties.id = slugs.slug(toString(node));
node.properties.id = slugs.slug(toString(node))
}
});
})
}
{
"name": "rehype-slug",
"version": "2.0.1",
"version": "2.0.2",
"description": "Add id attributes to headings",

@@ -12,7 +12,7 @@ "license": "MIT",

],
"repository": "https://github.com/wooorm/rehype-slug",
"bugs": "https://github.com/wooorm/rehype-slug/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
"repository": "rehypejs/rehype-slug",
"bugs": "https://github.com/rehypejs/rehype-slug/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],

@@ -30,20 +30,20 @@ "files": [

"devDependencies": {
"browserify": "^14.1.0",
"esmangle": "^1.0.0",
"nyc": "^11.0.0",
"rehype": "^5.0.0",
"remark-cli": "^3.0.0",
"remark-preset-wooorm": "^3.0.0",
"browserify": "^16.0.0",
"nyc": "^13.0.0",
"prettier": "^1.13.7",
"rehype": "^6.0.0",
"remark-cli": "^6.0.0",
"remark-preset-wooorm": "^4.0.0",
"tape": "^4.0.0",
"xo": "^0.18.0"
"tinyify": "^2.4.3",
"xo": "^0.23.0"
},
"scripts": {
"build-md": "remark . -qfo",
"build-bundle": "browserify index.js --bare -s rehypeSlug > rehype-slug.js",
"build-mangle": "esmangle rehype-slug.js > rehype-slug.min.js",
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint": "xo",
"test-api": "node test.js",
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
"build-bundle": "browserify index.js -s rehypeSlug > rehype-slug.js",
"build-mangle": "browserify index.js -s rehypeSlug -p tinyify > rehype-slug.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": [

@@ -1,3 +0,8 @@

# rehype-slug [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
# rehype-slug
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Chat][chat-badge]][chat]
Add `id`s to headings with [**rehype**][rehype].

@@ -28,5 +33,5 @@

```javascript
var fs = require('fs');
var rehype = require('rehype');
var slug = require('rehype-slug');
var fs = require('fs')
var rehype = require('rehype')
var slug = require('rehype-slug')

@@ -36,6 +41,6 @@ rehype()

.use(slug)
.process(fs.readFileSync('fragment.html'), function (err, file) {
if (err) throw err;
console.log(String(file));
});
.process(fs.readFileSync('fragment.html'), function(err, file) {
if (err) throw err
console.log(String(file))
})
```

@@ -66,2 +71,10 @@

## Contribute
See [`contributing.md` in `rehypejs/rehype`][contribute] for ways to get
started.
This organisation has a [Code of Conduct][coc]. By interacting with this
repository, organisation, or community you agree to abide by its terms.
## License

@@ -73,18 +86,30 @@

[travis-badge]: https://img.shields.io/travis/wooorm/rehype-slug.svg
[build-badge]: https://img.shields.io/travis/rehypejs/rehype-slug.svg
[travis]: https://travis-ci.org/wooorm/rehype-slug
[build]: https://travis-ci.org/rehypejs/rehype-slug
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/rehype-slug.svg
[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-slug.svg
[codecov]: https://codecov.io/github/wooorm/rehype-slug
[coverage]: https://codecov.io/github/rehypejs/rehype-slug
[downloads-badge]: https://img.shields.io/npm/dm/rehype-slug.svg
[downloads]: https://www.npmjs.com/package/rehype-slug
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
[chat]: https://spectrum.chat/unified/rehype
[npm]: https://docs.npmjs.com/cli/install
[license]: LICENSE
[license]: license
[author]: http://wooorm.com
[author]: https://wooorm.com
[rehype]: https://github.com/wooorm/rehype
[rehype]: https://github.com/rehypejs/rehype
[ghslug]: https://github.com/Flet/github-slugger
[contribute]: https://github.com/rehypejs/rehype/blob/master/contributing.md
[coc]: https://github.com/rehypejs/rehype/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