Skip to content

:octocat: Generate a slug just like GitHub does for markdown headings.

License

Notifications You must be signed in to change notification settings

jedwards1211/github-slugger

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-slugger

npm travis

Generate a slug just like GitHub does for markdown headings. It also ensures slugs are unique in the same way GitHub does it. The overall goal of this package is to emulate the way GitHub handles generating markdown heading anchors as close as possible.

Install

npm install github-slugger

Usage

var GithubSlugger = require('github-slugger')
var slugger = new GithubSlugger()

slugger.slug('foo')
// returns 'foo'

slugger.slug('foo')
// returns 'foo-1'

slugger.slug('bar')
// returns 'bar'

slugger.slug('foo')
// returns 'foo-2'

slugger.reset()

slugger.slug('foo')
// returns 'foo'

Check test/index.js for more examples.

Contributing

Contributions welcome! Please read the contributing guidelines first.

License

ISC

About

:octocat: Generate a slug just like GitHub does for markdown headings.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%