-
Notifications
You must be signed in to change notification settings - Fork 34
Add more conformant unicode handling #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,16 @@ | |
"description": "Generate a slug just like GitHub does for markdown headings.", | ||
"version": "1.1.0", | ||
"author": "Dan Flettre <[email protected]>", | ||
"contributors": [ | ||
"Dan Flettre <[email protected]>", | ||
"Titus Wormer <[email protected]> (http://wooorm.com)" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/Flet/github-slugger/issues" | ||
}, | ||
"dependencies": { | ||
"emoji-regex": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"standard": "*", | ||
"tap-spec": "^4.0.2", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ test('github test cases', function (t) { | |
var slugger = new GithubSlugger() | ||
|
||
testCases.forEach(function (test) { | ||
t.equals(test.slug, slugger.slug(test.text), test.mesg) | ||
t.equals(slugger.slug(test.text), test.slug, test.mesg) | ||
}) | ||
t.end() | ||
}) | ||
|
@@ -71,22 +71,114 @@ var testCases = [ | |
}, | ||
{ | ||
mesg: 'deals with duplicates correctly', | ||
text: 'duplicate', | ||
slug: 'duplicate' | ||
text: 'duplicates', | ||
slug: 'duplicates' | ||
}, | ||
{ | ||
mesg: 'deals with duplicates correctly-1', | ||
text: 'duplicate', | ||
slug: 'duplicate-1' | ||
text: 'duplicates', | ||
slug: 'duplicates-1' | ||
}, | ||
{ | ||
mesg: 'deals with duplicates correctly-2', | ||
text: 'duplicate', | ||
slug: 'duplicate-2' | ||
text: 'duplicates', | ||
slug: 'duplicates-2' | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests cases later also contained |
||
{ | ||
mesg: 'deals with non-latin chars', | ||
text: 'Привет', | ||
slug: 'привет' | ||
slug: 'Привет' | ||
}, | ||
// https://github.com/wooorm/gh-and-npm-slug-generation | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-1', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hope this naming convention of using numbers here is OK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally fine with this! |
||
text: 'I ♥ unicode', | ||
slug: 'i--unicode' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-2', | ||
text: 'Dash-dash', | ||
slug: 'dash-dash' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-3', | ||
text: 'en–dash!', | ||
slug: 'endash' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-4', | ||
text: 'em–dash', | ||
slug: 'emdash' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-5', | ||
text: '😄 unicode emoji', | ||
slug: '-unicode-emoji' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-6', | ||
text: '😄-😄 unicode emoji', | ||
slug: '--unicode-emoji' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-7', | ||
text: '😄_😄 unicode emoji', | ||
slug: '_-unicode-emoji' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-8', | ||
text: '😄 - an emoji', | ||
slug: '---an-emoji' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-9', | ||
text: ':smile: - a gemoji', | ||
slug: 'smile---a-gemoji' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-10', | ||
text: ' Initial spaces', | ||
slug: 'initial-spaces' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-11', | ||
text: 'Final spaces ', | ||
slug: 'final-spaces' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-12', | ||
text: 'duplicate', | ||
slug: 'duplicate' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-13', | ||
text: 'duplicate', | ||
slug: 'duplicate-1' | ||
}, | ||
{ | ||
mesg: 'gh-and-npm-slug-generation-14', | ||
text: 'Привет non-latin 你好', | ||
slug: 'Привет-non-latin-你好' | ||
}, | ||
// https://github.com/chrisdickinson/emoji-slug-example | ||
{ | ||
mesg: 'emoji-slug-example-1', | ||
text: ':ok: No underscore', | ||
slug: 'ok-no-underscore' | ||
}, | ||
{ | ||
mesg: 'emoji-slug-example-2', | ||
text: ':ok_hand: Single', | ||
slug: 'ok_hand-single' | ||
}, | ||
{ | ||
mesg: 'emoji-slug-example-3', | ||
text: ':ok_hand::hatched_chick: Two in a row with no spaces', | ||
slug: 'ok_handhatched_chick-two-in-a-row-with-no-spaces' | ||
}, | ||
{ | ||
mesg: 'emoji-slug-example-4', | ||
text: ':ok_hand: :hatched_chick: Two in a row', | ||
slug: 'ok_hand-hatched_chick-two-in-a-row' | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First argument should be the
actual
, secondexpected
, this threw me off 😉There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I get this confused a lot :)