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

remark-slug

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-slug - npm Package Compare versions

Comparing version 4.2.3 to 5.0.0

33

index.js

@@ -7,5 +7,5 @@ 'use strict';

module.exports = attacher;
module.exports = slug;
function attacher() {
function slug() {
return transformer;

@@ -18,23 +18,18 @@ }

visit(ast, 'heading', function (node) {
visit(ast, 'heading', visitor);
function visitor(node) {
var id = slugs.slug(toString(node));
var data = patch(node, 'data', {});
/* Non-html */
patch(data, 'id', id);
/* Legacy remark-html */
patch(data, 'htmlAttributes', {});
/* Current remark-html */
patch(data, 'hProperties', {});
patch(data.htmlAttributes, 'id', id);
patch(data.hProperties, 'id', id);
});
}
if (!node.data) {
node.data = {};
}
function patch(context, key, value) {
if (!context[key]) {
context[key] = value;
if (!node.data.hProperties) {
node.data.hProperties = {};
}
node.data.id = id;
node.data.hProperties.id = id;
}
return context[key];
}
{
"name": "remark-slug",
"version": "4.2.3",
"version": "5.0.0",
"description": "Add anchors to remark heading nodes",

@@ -15,4 +15,4 @@ "license": "MIT",

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

@@ -34,4 +34,4 @@ "contributors": [

"nyc": "^11.0.0",
"remark": "^7.0.0",
"remark-cli": "^3.0.0",
"remark": "^8.0.0",
"remark-cli": "^4.0.0",
"remark-preset-wooorm": "^3.0.0",

@@ -38,0 +38,0 @@ "tape": "^4.0.0",

@@ -72,8 +72,8 @@ # remark-slug [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat]

Uses [**github-slugger**][ghslug] (thus creating GitHub style `id`s).
Uses [`github-slugger`][ghslug], which creates GitHub-style slugs.
Sets `data.id`, `data.hProperties.id` on heading nodes. The first can be
used by any plugin as a unique identifier, the second tells **remark-html**
to use its value as an `id` attribute. **remark-slug** does not overwrite
these values when they already exist.
Sets `data.id` and `data.hProperties.id` on heading nodes.
The first can be used by any plugin as a unique identifier, the second tells
[`mdast-util-to-hast`][to-hast] (used in [`remark-html`][remark-html] and
[`remark-rehype`][remark-rehype]) to use its value as an `id` attribute.

@@ -84,2 +84,10 @@ ## Related

## Contribute
See [`contribute.md` in `remarkjs/remarkjs`][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

@@ -91,13 +99,13 @@

[build-badge]: https://img.shields.io/travis/wooorm/remark-slug.svg
[build-badge]: https://img.shields.io/travis/remarkjs/remark-slug.svg
[build-status]: https://travis-ci.org/wooorm/remark-slug
[build-status]: https://travis-ci.org/remarkjs/remark-slug
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/remark-slug.svg
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-slug.svg
[coverage-status]: https://codecov.io/github/wooorm/remark-slug
[coverage-status]: https://codecov.io/github/remarkjs/remark-slug
[chat-badge]: https://img.shields.io/gitter/room/wooorm/remark.svg
[chat-badge]: https://img.shields.io/gitter/room/remarkjs/Lobby.svg
[chat]: https://gitter.im/wooorm/remark
[chat]: https://gitter.im/remarkjs/Lobby

@@ -110,10 +118,18 @@ [license]: LICENSE

[remark]: https://github.com/wooorm/remark
[remark]: https://github.com/remarkjs/remark
[ghslug]: https://github.com/Flet/github-slugger
[rehype-slug]: https://github.com/wooorm/rehype-slug
[to-hast]: https://github.com/syntax-tree/mdast-util-to-hast
[remark-rehype]: https://github.com/wooorm/remark-rehype
[rehype-slug]: https://github.com/rehypejs/rehype-slug
[rehype]: https://github.com/wooorm/rehype
[remark-html]: https://github.com/remarkjs/remark-html
[remark-rehype]: https://github.com/remarkjs/remark-rehype
[rehype]: https://github.com/rehypejs/rehype
[contribute]: 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