markdown-toc icon indicating copy to clipboard operation
markdown-toc copied to clipboard

Examples with Slugify option

Open salmonjean opened this issue 6 years ago • 1 comments

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

salmonjean avatar Sep 04 '19 12:09 salmonjean

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.

jonschlinkert avatar Sep 04 '19 12:09 jonschlinkert