Docusaurus: table of content slugification differs from anchors slugification

Created on 28 Feb 2020  路  4Comments  路  Source: facebook/docusaurus

馃悰 Bug Report

If a header is called, for example, Tips & Tricks, the table of content section would slugify that as Tips-amp-tricks whereas the actual hash from the header is tips-tricks

This is more problematic than a mismatching anchor. Docusaurus uses scrollSpy, which fails to find the anchor like so:
Screen Shot 2020-02-27 at 16 34 17
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:)

  1. Write any markdown doc, add a header # Tips & Tricks
  2. Check console

The problem comes from these lines:
https://github.com/facebook/docusaurus/blob/6670c53d1838750de66ea2e6876da90d906428cb/packages/docusaurus-1.x/lib/core/toc.js#L40
https://github.com/facebook/docusaurus/blob/6670c53d1838750de66ea2e6876da90d906428cb/packages/docusaurus-1.x/lib/core/anchors.js#L25

If you console.log(rendered) in the first snippet, the sanitization turns Tips & Tricks into Tips & Tricks. Whereas if you console.log(textToken.content) in the latter snippet, it's still Tips & Tricks.

cc @JoelMarcey

bug intermediate help wanted v1

All 4 comments

@chenglou Your website is still on v1 of Docusaurus, right?

cc @yangshun

Yes this is v1.

@chenglou @yangshun This issue was fixed with https://github.com/facebook/docusaurus/pull/2019

Hmm @chenglou are you using the latest Docusaurus v1?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

slorber picture slorber  路  23Comments

cameronelliott picture cameronelliott  路  28Comments

nebrelbug picture nebrelbug  路  26Comments

slorber picture slorber  路  24Comments

wez picture wez  路  26Comments