1.3.0 • Published 3 months ago

github-slugger v1.3.0

Weekly downloads
786,761
License
ISC
Repository
github
Last release
3 months ago

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.

If you need, you can also use the underlying implementation which does not keep track of the previously slugged strings (not recommended):

var slugger = require('github-slugger').slug;

slug('foo bar baz')
// returns 'foo-bar-baz'

slug('foo bar baz')
// returns the same slug 'foo-bar-baz' because it does not keep track

Contributing

Contributions welcome! Please read the contributing guidelines first.

License

ISC

sfdx-mohanc-di@bitionaire/react-styleguidist@celo/dev-cli@1nd/documentation@alicloud/console-components-lib-publisherstandard-readme-preset@cc-dev-kit-test/console-components-lib-publisher@catalog/coresmooth-doc@confluenza/gatsby-theme-confluenza@commercetools-docs/gatsby-theme-docsspore-documentation-theme@digidem/jsonschema2md@double-great/alt-textngindoxmarkdown-it-toc-x3mdxx-parsermdx-component-autolink-headermdast-util-tocminimark-plugin-table-of-contentsmos-plugin-tocmarky-markdown@alchemy-se/catalogpapersaurusparcel-transformer-mdx-with-toc@activeviam/documentationreact-website-themes@axelhzf/react-styleguidist-ts@availity/gatsby-theme@availity/gatsby-theme-docs@awesome-fe/translatesecondwheelreact-static-plugin-md-pagesreact-ui-docreact-styleguidistreact-styleguidist-extendedts-info-extractturpan@enjoylife/catalog@eshlox/gatsby-theme-axii@fox-tech/doctextlint-rule-no-dead-relative-linkpicidae-transformer-tocpolicygenius-react-styleguidistpipe-documentationsparcel-plugin-mdx-with-tocreact-display-windowhs-markdownliverecordlectjimmaaay-vue-styleguidist-test@docusaurus-azuread/mdx-loader@docusaurus/mdx-loader@freepress/corevue-styleguidistvue-styleguidist-jimmyvue-styleguidist2vue-component-docsremark-preset-lint-origami-componentremark-validate-linksremark-slugrehype-slugremark-lint-appropriate-headingremark-manoclif-dev-cli-npmhafas-rest-apijsonschema_transformed_into_markdown_pagesjsdoc-mdjsdoc-md-standardglossarify-mdmarkdown-it-githubmarkdown-it-github-headingswikic@hashicorp/remark-plugins@hackclub/markdown@helpdotcom/help-gen@hpprc/gatsby-theme-blog@hugomrdias/documentationantd-site-commonantdsite@matthieulemoine/react-styleguidist@adobe/jsonschema2md@mavenlink/react-styleguidistamdx@tiagonapoli/oclif-dev-cliacyort-util-md@okmarvin/markdown-it-toc@troglotit/vue-styleguidist@limedocs/transformer-markdown@rollup-umd/react-styleguidist@rizzlesauce/oclif-dev-cli@yorhodes/dev-cli@mapbox/jsxtreme-markdown@windkomo/gatsby-remark-autolink-headers@stencila/encoda@kamikazept/jsdoc-mddocboxdfuzr-docusaurusdocusaurusdocumentation42
1.3.0

3 months ago

1.2.1

1 year ago

1.2.0

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

5 years ago