-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
The toc (with subMaxLevel) is generated twice when there's 2 embedded links in a page #1822
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
I tried to debug, and I think the issue is that the 2 callbacks are called for each of the token: docsify/src/core/render/embed.js Lines 75 to 78 in c49c39a
As a result, docsify/src/core/render/embed.js Line 152 in c49c39a
And then this is called twice: docsify/src/core/render/index.js Lines 340 to 341 in 54cc5f9
Which isn't usually a problem (except things may be rendered twice), but in the case of the sidebar toc, this causes the toc to be rendered twice with: docsify/src/core/render/compiler.js Line 239 in 54cc5f9
Then the duplicated toc is used in this routine: docsify/src/core/render/compiler.js Lines 306 to 327 in 35002c9
Here only the first toc entry is removed, if it's a depth 1. Therefore I can see these possible fixes:
Hpoe this helps! |
I think I understood the dance with the incrementations: when the token has a url, then the process is asynchronous, so the condition is there to ensure that we call the callback after everything has been fetched. But this doesn't work when the token is just some html, because in that case the process is synchronous. update: Studying the code some more, I decided to use the length of the |
Bug Report
Steps to reproduce
_sidebar.md
, it could be as simple as:You can also see it live in https://codesandbox.io/s/problem-with-docsify-4cyldv
What is current behaviour
The Toc is generated twice, but in a nested way. In the above example, this looks like it:
See also this screenshot:

What is the expected behaviour
We have the TOC only once, this should look like this in this case:
This happens when there's only one embedded asset.
Other relevant information
Bug does still occur when all/other plugins are disabled?
Your OS: not relevant
Node.js version: not relevant
npm/yarn version: not relevant
Browser version: Firefox 103, but I also tried in Chrome stable, so I believei t's not relevant
Docsify version: 4.12.2
Docsify plugins: none
Please create a reproducible sandbox
https://codesandbox.io/s/problem-with-docsify-zl23lm
Mention the docsify version in which this bug was not present (if any)
I haven't tried earlier versions, it's the first time I try this.
The text was updated successfully, but these errors were encountered: