-
-
Notifications
You must be signed in to change notification settings - Fork 79
Support multiple occurrences #37
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
Comments
That would be awesome 🥇
|
Wanted to talk a little about the strategy if it's going to be implemented.
I think it should start at 2 not at 1 cause it's effectively the second occurrence. IMHO that reads better and fits better in the humanize-url philosophy. I think it makes it more predictable, like Would love to know what you guys think. I can see it potentially conflict in cases where people want to replace github-slugger with slugify, maybe the counter could be configurable, defaulting to my suggestion 🤔 For now I'm using a little wrapper remark-plugin handling the counter anyways so it's actually not that urgent but would be a nice to have 💯 Update: slugify.reset()
t.is(slugify('foo', { counter: true }), 'foo');
t.is(slugify('foo', { counter: true }), 'foo-2');
t.is(slugify('foo', { counter: true }), 'foo-3');
t.is(slugify('foo 2', { counter: true }), 'What should this be?'); I cloned the repo and implemented a simple "counter" behind an option as you might've guessed, mainly to not break the other tests.. |
Okay I made a wrapper for internal consistency and to specify options once across projects and implemented a counter satisfying my current desires (I guess 🤔). Those are all currently passing tests related to duplicates slugify.reset();
t.is(slugify('foo'), 'foo');
t.is(slugify('foo'), 'foo-2');
t.is(slugify('foo 1'), 'foo-1');
t.is(slugify('foo-1'), 'foo-1-2');
t.is(slugify('foo-1'), 'foo-1-3');
t.is(slugify('foo'), 'foo-3');
t.is(slugify('foo'), 'foo-4');
t.is(slugify('foo-1'), 'foo-1-4');
t.is(slugify('foo-2'), 'foo-2-1'); // or foo-2-2 ??
t.is(slugify('foo-2'), 'foo-2-2');
t.is(slugify('foo-2-1'), 'foo-2-1-1');
t.is(slugify('foo-2-1'), 'foo-2-1-2');
t.is(slugify('foo-11'), 'foo-11-1');
t.is(slugify('foo-111'), 'foo-111-1');
t.is(slugify('foo-111-1'), 'foo-111-1-1');
t.is(slugify('fooCamelCase', { lowercase: false }), 'fooCamelCase');
t.is(slugify('fooCamelCase'), 'foocamelcase-2'); I'd like to know what you guys think about the numbering logic❓ By the way, I'm using this regex |
Agreed.
Nah. We can deal with that if anyone complains.
It cannot be the main PR welcome. |
Later than planned 😅 Got a little confused while working on a PR. From my former example slugify.reset();
t.is(slugify('foo'), 'foo');
t.is(slugify('foo'), 'foo-2');
t.is(slugify('foo 1'), 'foo-1');
t.is(slugify('foo-1'), 'foo-1-2');
t.is(slugify('foo-1'), 'foo-1-3');
t.is(slugify('foo'), 'foo-3');
t.is(slugify('foo'), 'foo-4');
t.is(slugify('foo-1'), 'foo-1-4');
t.is(slugify('foo-2'), 'foo-2-1'); // or foo-2-2 ??
t.is(slugify('foo-2'), 'foo-2-2');
t.is(slugify('foo-2-1'), 'foo-2-1-1');
t.is(slugify('foo-2-1'), 'foo-2-1-2');
t.is(slugify('foo-11'), 'foo-11-1');
t.is(slugify('foo-111'), 'foo-111-1');
t.is(slugify('foo-111-1'), 'foo-111-1-1');
t.is(slugify('fooCamelCase', { lowercase: false }), 'fooCamelCase');
t.is(slugify('fooCamelCase'), 'foocamelcase-2'); Does I now think it's confusing in this "contrived" testing yet I think I actually prefer it as is 👍 |
Yes |
It would be nice if this would support multiple occurrences of same headings, similar to what https://github.com/Flet/github-slugger can do. So multiple occurrences are appended with an incremental number or perhaps hash.
Thoughts @sindresorhus?
The text was updated successfully, but these errors were encountered: