table of content slugification differs from anchors slugification #2341
Labels
bug
An error in the Docusaurus core causing instability or issues with its execution
difficulty: intermediate
Issues that are medium difficulty level, e.g. moderate refactoring with a clear test plan.
help wanted
Asking for outside help and/or contributions to this particular issue or PR.
v1
This issue is for Docusaurus 1
馃悰 Bug Report
If a header is called, for example,
Tips & Tricks
, the table of content section would slugify that asTips-amp-tricks
whereas the actual hash from the header istips-tricks
This is more problematic than a mismatching anchor. Docusaurus uses scrollSpy, which fails to find the anchor like so:
This exception then blocks lots of other functionalities on the page (e.g. code tab switching)
Have you read the [Contributing Guidelines on issues]
Yeah
To Reproduce
(Write your steps here:)
# Tips & Tricks
The problem comes from these lines:
docusaurus/packages/docusaurus-1.x/lib/core/toc.js
Line 40 in 6670c53
docusaurus/packages/docusaurus-1.x/lib/core/anchors.js
Line 25 in 6670c53
If you
console.log(rendered)
in the first snippet, the sanitization turnsTips & Tricks
intoTips & Tricks
. Whereas if youconsole.log(textToken.content)
in the latter snippet, it's stillTips & Tricks
.cc @JoelMarcey
The text was updated successfully, but these errors were encountered: