-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Sidebar level link does not work if header starts with numbers #1088
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
Comments
can you share a reproducible sandbox for this . we have a demo sandbox in the readme. |
You may try the test link below: https://data42.cn/docsify/docs/#/?id=introduction Regards, |
hey, it seems the bug about the element @anikethsaha How about add a common id prefix by default to avoid those issues?
|
@Koooooo-7 this is a good solution but then we need to change the ids of the source as well like the markdown rendering as content. I am pretty sure it was working before but don't know the exact version |
I mean I just add the prefix on the // it will only work on the titles.
const slug = "docsify-"+slugify(config.id || str);
const url = router.toURL(router.getCurrentPath(), { id: slug });
nextToc.slug = url;
_self.toc.push(nextToc);
return `<h${level} id="${slug}"><a href="${url}" data-id="${slug}" class="anchor"><span>${str}</span></a></h${level}>`;
I get it, in the old version( ~v4.10.2), it will replace the front digit to let slug = str
.trim()
.replace(/[A-Z]+/g, lower)
.replace(/<[^>\d]+>/g, '')
.replace(re, '')
.replace(/\s/g, '-')
.replace(/-+/g, '-')
.replace(/^(\d)/, '_$1')
let count = cache[slug] But this merge removed it, Fix #895 (#896) in v4.11.0. let slug = str
.trim()
.replace(/[A-Z]+/g, lower)
.replace(/<[^>\d]+>/g, '')
.replace(re, '')
.replace(/\s/g, '-')
.replace(/-+/g, '-');
let count = cache[slug]; |
Please try new version @Koooooo-7 can you check this and see if we can merge these two cases. Else can you create a separate issue. We can surely discuss about it, it looks good to have |
the latest
I opened a new one #1093 , and I may miss some relative issues, u could add them in. |
you meant |
I didn't find the |
I didn't find the
……okay, maybe I missed something.:cat: could u test the |
it has been changed in slugify.js . check 154abf5 |
sounds good. 👍 |
I ran |
😂 that's okay. and I tested on the |
Thank you both very much, @Koooooo-7 @anikethsaha, just tried the latest version and it works well. I will close this issue. Regards, |
Bug Report
Thanks for this great app and I just got one issue for now, if the header text in the document starts with numbers, the auto links in the sidebar will not work. For example:
Header text in the document as follows:
1.1 Purpose
The auto links will be resolved as like http://localhost:3000/#/mybook?id=1-introduction, it will not redirect to the right section when this link was clicked.
If I add any other characters before that, e.g. Chapter 1 Introduction, then it works very well.
I am wondering whether it could support this kind of scenario, or it does support and I may miss something in configuration, please advise. Thanks very much!
Steps to reproduce
What is current behaviour
What is the expected behaviour
Other relevant information
Bug does still occur when all/other plugins are disabled?
Your OS: Windows WSL
Node.js version: v10.16.3
npm/yarn version: 6.14.3
Browser version: Firefox 74.0
Docsify version: docsify-cli 4.4.0
Docsify plugins: default
The text was updated successfully, but these errors were encountered: