Open aspiers opened 2 years ago
I am confused where these inconsistencies are coming from, because I thought the same slugify
function was supposed to handle anchor generation both for the TOC links and header anchors?
Ah, I see there is a markdown.toc
option, which says:
(Note: prefer
markdown.slugify
to customize header ids.)
but it looks the toc plugin is indeed using the same slugify
:
which is defined here:
so I'm not sure what's going wrong. Perhaps parseHeaders
is interfering somehow?
Bug report
Steps to reproduce
Generate a TOC with the
markdown.slugify
option set to use the defaultslugify
from@vuepress/shared-utils
. For example, see the.vuepress/config.js
for hardhat.org.What is expected?
Links from the TOC will correctly navigate to the corresponding auto-generated header anchors.
What is actually happening?
Some header links don't match the auto-generated header anchors.
Examples of inconsistencies:
-1
prefix in the TOC anchor link but a-2
prefix for the header anchor/
character in headers get removed in the TOC anchor link, but replaced with-
in the header anchor_
only in the header anchor, not in the TOC link. So for example a header1. node task
gets slugified to#1-node-task
in the TOC anchor link, but to#_1-node-task
in the header anchorOther relevant information
Please see https://hardhat.org/plugins/hardhat-deploy.html for a specific public example, and https://github.com/nomiclabs/hardhat/issues/1800 for the corresponding issue.