signalwerk / gatsby-remark-table-of-contents

gatsby remark plugin to generate table of contents
21 stars 10 forks source link

Dot and Ampersand rendered differently to how Gatsby renders them in anchors #11

Open bharatrajagopalan opened 3 years ago

bharatrajagopalan commented 3 years ago

Dots and ampersands are rendered differently in TOC compared to Gatsby

A.B help

Gatsby generated link #a.b-help TOC generated link: #ab-help

missing the .

A & B help

Gatsby converts & to and while TOC just ignores it

Gatsby link: #a-and-b-help TOC link: #a--b-help

signalwerk commented 3 years ago

@bharatrajagopalan thank you for the report! hmm... that's really not good. To generate the TOC itself I use mdast-util-toc this itself uses then github-slugger for the slug-generation. The gatsby-remark-autolink-headers uses also github-slugger. Did you do any research where the difference could come from?

bharatrajagopalan commented 3 years ago

@signalwerk

I managed to work out a few bits.I am using the Gatsby carbon theme https://gatsby-theme-carbon.now.sh

I am trying to work out what it uses internally, but it is highly likely that it doesn't use gatsby-remark-autolink-headers

I installed gatsby-remark-autolink-headers on top and it basically resulted in additional ids prefixed with object-

From your perspective given that the gatsby-remark-table-contents is designed to work with gatsby-remark-autolink-headers as a pre-requisite, arguably this is beyond your scope to fix. If you agree then I will close this issue accordingly.