Socket
Socket
Sign inDemoInstall

remark-slug

Package Overview
Dependencies
5
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    remark-slug

Add anchors to remark heading nodes


Version published
Weekly downloads
3.3M
decreased by-1.83%
Maintainers
1
Install size
67.2 kB
Created
Weekly downloads
 

Package description

What is remark-slug?

The remark-slug npm package is a plugin for the remark Markdown processor that automatically adds slugs to headings in a Markdown document. This is useful for generating links to specific sections of the document, enhancing navigation and accessibility.

What are remark-slug's main functionalities?

Automatic Slug Generation

This feature automatically generates slugs for each heading in a Markdown document. The code sample shows how to use remark-slug with remark and remark-html to convert a Markdown heading into HTML with a slug.

const remark = require('remark');
const remarkHtml = require('remark-html');
const remarkSlug = require('remark-slug');

remark()
  .use(remarkSlug)
  .use(remarkHtml)
  .process('# Hello world', function (err, file) {
    console.log(String(file));
  });

Other packages similar to remark-slug

Readme

Source

remark-slug Build Status Coverage Status

Add anchors to remark heading nodes using GitHub’s algorithm.

Works great with remark-html, used by remark-toc and remark-man.

Installation

npm:

npm install remark-slug

remark-slug is also available for duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.

Usage

Dependencies:

var slug = require('remark-slug');
var remark = require('remark');
var html = require('remark-html');

Process:

var doc = remark().use(slug).use(html).process('# Foo bar');

Yields:

<h1 id="foo-bar">Foo bar</h1>

CLI

remark readme.md -u slug

API

remark.use(slug)

Adds slugs to markdown headings.

Sets data.id and data.htmlAttributes.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.

Parameters:

  • slug — This plugin.

License

MIT © Titus Wormer

Keywords

FAQs

Last updated on 23 Jan 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc