Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

Flet/github-slugger

Repository files navigation

npmBuild

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.

This project is not a markdown or HTML parser: passingalpha *bravo* charlieoralpha <em>bravo</em> charlie doesn’t work.Instead pass the plain text value of the heading:alpha bravo charlie.

Install

npm install github-slugger

Usage

importGithubSluggerfrom'github-slugger'constslugger=newGithubSlugger()slugger.slug('foo')// returns 'foo'slugger.slug('foo')// returns 'foo-1'slugger.slug('bar')// returns 'bar'slugger.slug('foo')// returns 'foo-2'slugger.slug('Привет non-latin 你好')// returns 'привет-non-latin-你好'slugger.slug('😄 emoji')// returns '-emoji'slugger.reset()slugger.slug('foo')// returns 'foo'

Checktest/fixtures.json for more examples.

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

importGithubSlugger,{slug}from'github-slugger'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 thecontributing guidelines first.

License

ISC

About

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

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors12


[8]ページ先頭

©2009-2025 Movatter.jp