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

links to sections on github with emoji in the heading are broken

Open chriseppstein opened this issue 7 years ago • 2 comments

# ⭐️ My Fancy 💅 Heading is assigned an anchor id of -my-fancy--heading but markdown-toc generates an id containing character escapes instead.

chriseppstein avatar Apr 23 '18 23:04 chriseppstein

@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).

doowb avatar Apr 25 '18 18:04 doowb

This also affect READMEs as displayed on npmjs.com - they follow the GitHub convention of stripping emoji from IDs.

PixievoltNo1 avatar Jun 02 '19 23:06 PixievoltNo1