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

[[toc]] not working after using custom containers #1093

Closed
trwnh opened this issue Aug 1, 2022 · 2 comments · Fixed by #1207
Closed

[[toc]] not working after using custom containers #1093

trwnh opened this issue Aug 1, 2022 · 2 comments · Fixed by #1207
Labels
bug Something isn't working build Related to the build system

Comments

@trwnh
Copy link

trwnh commented Aug 1, 2022

Describe the bug

Placing a table of contents shortcode after a custom container (tip, warning, danger, etc) will cause the table of contents element to render empty with no children.

Reproduction

index.md:

# Test page

::: warning
This will cause the toc to be empty
:::

[[toc]]

## section 1
## section 2
### subsection 2a
## section 3

Expected behavior

The TOC outline should be populated with children but instead it just renders as <nav class="table-of-contents"></nav>

System Info

System:
    OS: Linux 5.18 Arch Linux
    CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
    Memory: 91.45 GB / 125.72 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.7.0 - /usr/bin/node
    npm: 8.15.1 - /usr/bin/npm
  Browsers:
    Chromium: 103.0.5060.134


### Additional context

_No response_

### Validations

- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)
- [X] Read the [docs](https://vitepress.vuejs.org).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@trwnh trwnh added the bug: pending triage Maybe a bug, waiting for confirmation label Aug 1, 2022
@brc-dd brc-dd changed the title TOC outline not rendered after Customer Container [[toc]] not working after using custom containers Aug 1, 2022
@brc-dd brc-dd added bug Something isn't working build Related to the build system and removed bug: pending triage Maybe a bug, waiting for confirmation labels Aug 1, 2022
@meteorlxy
Copy link
Member

meteorlxy commented Aug 18, 2022

Caused by #768.

Seems that the token structure is somehow broken by the md.renderInline

🤔🤔 Need more investigation later

@meteorlxy
Copy link
Member

Oh I know the reason. The headers are collected inside the toc-plugin, and calling md.renderInline will override the previously collected headers before they are rendered 🤦‍♂️

meteorlxy added a commit to meteorlxy/vitepress that referenced this issue Aug 18, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working build Related to the build system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants