question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

table of content slugification differs from anchors slugification

See original GitHub issue

🐛 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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yangshuncommented, Mar 6, 2020

Hmm @chenglou are you using the latest Docusaurus v1?

1reaction
theosherrycommented, Mar 6, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Content tabs - Material for MkDocs - GitHub Pages
Python Markdown Extensions 9.6 adds support for slugification of content tabs, which produces nicer looking and more readable anchor links.
Read more >
markdown-it-anchor - npm
If a slugify function is given, you can decide how to transform a heading text to a URL slug. See user-friendly URLs. The...
Read more >
Configuration - Zola
🔗Slugification strategies​​ By default, Zola will turn every path, taxonomies and anchors to a slug, an ASCII representation with no special characters. You...
Read more >
11ty Slugs and Anchors - 11ty Rocks!
The default slug filter uses slugify under the hood, but sometimes the default behavior isn't quite enough if you are using special ...
Read more >
Config | VuePress
This can be specified in different locales. ... This will be the content attribute of <meta name="description" /> tag ... markdown.slugify.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found