Skip to content
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

Examples with Slugify option #150

Open
salmonjean opened this issue Sep 4, 2019 · 1 comment
Open

Examples with Slugify option #150

salmonjean opened this issue Sep 4, 2019 · 1 comment

Comments

@salmonjean
Copy link

Hi

I need a specific slugify function to avoid accentuated and some specials characters.
For the moment, I've directly have updated the utils.js source code. It works but it's "not clean".
For instance :
str = str.split(/[àèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇßØøÅåÆæœ]/).join('-');

I would rather use your option options.slugify
Do you have at least one example to show me how to use this option please?
Thanks for your help.

Regards,

Jean

@jonschlinkert
Copy link
Owner

jonschlinkert commented Sep 4, 2019

Sure, just pass a function to the slugify option:

const toc = require('markdown-toc');

const slugify = str => {
  // your custom logic here
};

console.log(toc(input, { slugify }));

Is this what you mean?

Also, I published markdown-slug a while ago, for this kind of situation. If you still need to add custom logic with that lib, and you want to do a PR that would be awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants