Open chriseppstein opened 6 years ago
@chriseppstein if you're using markdown-toc
through the api, you can pass an optional slugify
function on options. This one works for this case, but I'm not sure if it'll work for other cases:
const slugify = (title) => {
return [...toc.slugify(title)]
.reduce((acc, ch) => {
if (ch.charCodeAt(0) > 255) {
return acc;
}
return acc + ch;
}, '');
};
Since we're already doing replaceDiacritics, I wonder if we could do replaceUnicode
(I think that's what would it would be called).
This also affect READMEs as displayed on npmjs.com - they follow the GitHub convention of stripping emoji from IDs.
# ⭐️ My Fancy 💅 Heading
is assigned an anchor id of-my-fancy--heading
butmarkdown-toc
generates an id containing character escapes instead.