Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 23, 2024 via pnpm

github-slugger 2.0.0

Generate a slug just like GitHub does for markdown headings.
Package summary
Share
0
issues
1
license
1
ISC
Package created
22 Sep 2015
Version published
27 Oct 2022
Maintainers
5
Total deps
1
Direct deps
0
License
ISC

Issues

0
This package has no issues

Licenses

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
github-slugger@2.0.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
ⓘ This is a list of github-slugger 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does github-slugger do?

Github-slugger is an npm package designed to generate slugs similar to how GitHub does for markdown headings. Its function is not limited to slug generation but it also ensures the uniqueness of these slugs, paralleling the way GitHub does it. It's worth noting that github-slugger is not a markdown or HTML parser, therefore, it operates on the plain text value of the heading and not on encoded text. Its primary objective is to replicate the way GitHub manages the creation of markdown heading anchors as meticulously as possible.

How do you use github-slugger?

To use github-slugger, first install the package in your project by running npm install github-slugger. You can then import it into your JavaScript files using import GithubSlugger from 'github-slugger'. To generate a slug, instantiate GithubSlugger and use the slug() function of the instance.

Here's how:

import GithubSlugger from 'github-slugger'

const slugger = new GithubSlugger()

slugger.slug('foo') // returns 'foo'
slugger.slug('foo') // returns 'foo-1' (as it ensures uniqueness)
slugger.slug('bar') // returns 'bar'
slugger.slug('Привет non-latin 你好') // returns 'привет-non-latin-你好' (handles non-latin texts)
slugger.slug('😄 emoji') // returns '-emoji' (handles emojis)

This instance will remember the slugs it has generated. If you want to reset it, simply call the reset() function. Here's an example:

slugger.reset()
slugger.slug('foo') // now it returns 'foo' again

One can also use the underlying slug function, which does not keep track of previous entries. However, this is not recommended, and should be done as follows:

import GithubSlugger, {slug} from 'github-slugger'
slug('foo bar baz') // returns 'foo-bar-baz'

Where are the github-slugger docs?

The documentation for github-slugger is found in its readme file on GitHub. Visit GithubSlugger's GitHub repository for detailed usage instructions and examples. The test/fixtures.json file, within the same repository, contains more examples on usage. Please refer to this documentation for any further clarification or information.