You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change the logic of generating the id of h tags #432
Now the logic of generating the id of h tags is raw.toLowerCase().replace(/[^\w]+/g, '-').
By using this method, if the header includes other none-English words, the id just is '-'.
Then if we need the id to be used as anchors, this won't work.
Now I am using marked-toc to generate index of the headers, it uses uslug to generate the anchors, the logic is slugify(raw.toLowerCase(), {allowedChars: '-'}).
I think that is a good solution. if you support this modification, I can do it and create a pull request. Thanks
There's no perfect way to slugify any text. I think the best course of action is to define our own slugify function (hopefully based on uslag, since it looks pretty good) and use it to generate ids both in marked and in marked-toc.
In marked, this is very easy since you can override the renderer function for headings.
marked-toc lacks this capability. In fact, I think I'm going to post a pull request to allow this.
Activity
Feder1co5oave commentedon Jul 16, 2014
There's no perfect way to slugify any text. I think the best course of action is to define our own slugify function (hopefully based on
uslag, since it looks pretty good) and use it to generate ids both in marked and in marked-toc.In marked, this is very easy since you can override the renderer function for headings.
marked-toc lacks this capability. In fact, I think I'm going to post a pull request to allow this.
joshbruce commentedon Dec 25, 2017
#981