-
-
Notifications
You must be signed in to change notification settings - Fork 714
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
markdown-toc support for accented characters broken #145
Comments
This is an inconsistency between how the implementation of the markdown For the time being, this little accent fix would be a great improvement since it would add compatibility with two very common markdown implementations:
For reference, this is the sluggin function in marked:
I think implementing this function would be a great start. Feature request: Maybe if in the future some inconsistencies between sluggify implementations arrive, we could delegate the responsibility to create the headings to this library instead of depending on another library, maybe as an optional function. Edit: It looks that @mootari wrote a script to support that very same feature already in an issue of this same repo, although I'm not sure how to integrate it with the current code (I'm very newby at node) |
@AeonFr The snippet you linked to was part of an assemble pipeline. You can find the full context here: https://github.com/mootari/Documentation/blob/aae6df5755fffa4b4f48caed53dfa7b8acf24270/generator/lib/plugins/render-markdown/index.js#L76 Be aware that markdown-toc already has an option to specify a custom slugify callback. |
Thanks very much, actually it makes perfect sense to be able to use your own slugify function. I leave my code for further reference: function slugify(value) {
return value
.toLowerCase()
.trim()
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
.replace(/\s/g, '-');
}
toc('# Some markdown', { slugify }); You may notice the accented characters are rendered "URL encoded", but Chrome is not making any problem with that and it works nevertheless Generated by markdown-toc:
li><a href="#c%C3%B3mo-hacer-un-back-up-del-sitio-y-recuperar-una-versi%C3%B3n-antigua-del-sitio">Cómo hacer un back-up del sitio y recuperar una versión antigua del sitio?</a></li>
Generated by marked:
<h3 id="cómo-hacer-un-back-up-del-sitio-y-recuperar-una-versión-antigua-del-sitio">Cómo hacer un back-up del sitio y recuperar una versión antigua del sitio?</h3> Again, this just works and it's a clean solution since it doesn't depend on the markdown implementation. I still believe it would be best if the library supported accents by default but I'm still glad I got this working. Thanks |
In my experience it is rather unusual for slugs to contain anything but unreserved characters. Let me also point you to https://en.wikipedia.org/wiki/Clean_URL#Slug. |
markdown-toc is generating :
instead of
for this markdown:
The text was updated successfully, but these errors were encountered: