Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a TOC with accents in Markdown?

I am writing a tutorial in Markdown and created a TOC with the extension Markdown TOC on Visual Studio Code.

It is working well except when using accents. The TOC is created the same way, but when the link is clicked, it doesn't go to the right section or move. This is annoying because I am doing this in French and have a hard time finding words without any accents as "é" or "è" are common characters.

What I don't understand is why does it work great on VSC's preview, but when I push it with Github Desktop and open it in the browser, it doesn't.

<!-- TOC -->

- [Affichage, ajout et modification de données](#affichage-ajout-et-modification-de-données)
    - [Présentation](#présentation)
    - [Affichage des tableaux de données](#affichage-des-tableaux-de-données)
    - [Rechercher un contenu](#rechercher-un-contenu)
    - [Ajout de données](#ajout-de-données)
    - [Édition, duplication et suppression de fiches](#édition-duplication-et-suppression-de-fiches)
        - [Édition d'une fiche](#édition-dune-fiche)
        - [Duplication d'une fiche](#duplication-dune-fiche)
        - [Suppression d'une fiche](#suppression-dune-fiche)
- [Exemple d'ajout de données dans un catalogue](#exemple-dajout-de-données-dans-un-catalogue)
    - [Concept](#concept)
        - [Types de fiches et liens](#types-de-fiches-et-liens)
        - [Ajout d'une fiche](#ajout-dune-fiche)

<!-- /TOC -->

This is what the TOC looks like in my document. [Duplication d'une fiche](#duplication-dune-fiche) is working like it is supposed to, but not [Édition d'une fiche](#édition-dune-fiche).

Also, when inspecting the page in Chrome, I can see that the "é" isn't correct in the link: screenshot of the weird link.

Is there a way to create a markdown TOC that supports special characters ?

like image 527
tukanium Avatar asked Oct 22 '25 02:10

tukanium


1 Answers

So I finally found out a way around this.

First, this works when titles don't have any accent:

<!-- TOC -->
- [Rechercher un contenu](#rechercher-un-contenu)
<!-- /TOC -->

# Rechercher un contenu

Now if the title has accents like é, è, à, ü, etc just place a link with an id attribute before the actual title and reference it in the TOC like so:

<!-- TOC -->
- [Ajout de données](#ajoutdonnees)
<!-- /TOC -->

<a id="ajoutdonnees"></a>
# Ajout de données
like image 167
tukanium Avatar answered Oct 24 '25 00:10

tukanium



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!