Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De-duplicating slugs #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

arantes555
Copy link

@arantes555 arantes555 commented Mar 9, 2021

Hello,

This is a PR that de-duplicates the slugs assigned as hashes of headers, if there are multiple headers with the same title in the same file, as is done by https://github.com/valeriangalliat/markdown-it-anchor and most markdown to HTML converters.

For example, if there are two ### Example headers in the file file.md, the first header gets assigned file.md#example, and the second one gets file.md#example-2 (for markdown-it-anchor < 6, which VuePress still uses) or file.md#example-1 (for markdown-it-anchor >= 6, as well as markdown-toc, github-slugger, and GitHub).

Currently, check-md wrongly considers these -n anchors as broken. This PR fixes it.

The behaviour is configurable with the introduced uniqueSlugStartIndex option.

I took the liberty of setting the default for uniqueSlugStartIndex at 2, like VuePress, but of course this could be changed to only be 2 with the VuePress preset, and 1 otherwise.

I also had to clear the content caches between runs of the .check function, because the cache content depends on the options passed to it, so the tests of the uniqueSlugStartIndex option would not work without clearing it.

Lastly, I updated README.md and index.d.ts files to reflect my changes, and the ignoreFootnotes change (they had not been updated for it).

@arantes555
Copy link
Author

@whxaxes any chance of seeing any more activity on this repo ?

@tex0l
Copy link

tex0l commented Sep 8, 2022

@whxaxes would it be possible to merge and release this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants