Skip to content

[[toc]] does not include headings inside :::details blocks, while "On this page" sidebar works correctly | [[toc]] 无法识别 :::details 块内的标题,但侧边栏“本页结构”正常显示 #5383

Description

@gforoosge

Describe the bug

When using [[toc]] to generate a table of contents in VitePress, headings (e.g., ## Heading) placed inside a :::details custom container are missing from the generated TOC list. However, the "On this page" sidebar on the right side correctly includes those headings.

在 VitePress 中使用 [[toc]] 生成页面目录时,发现如果某个标题(如 ## 标题)被包裹在 :::details 自定义容器内,则该标题不会出现在由 [[toc]] 生成的目录列表中。然而,页面右侧的“On this page”(本页结构)侧边栏却能正确包含该标题

# VitePress 💙 StackBlitz

[[toc]]

## foo

123

:::details

## bar

345

:::
Image

Reproduction

https://stackblitz.com/edit/vite-w37rq9sf?file=docs%2Fexample.md

  1. Place [[toc]] in a Markdown file.
  2. Put a heading inside a :::details block, e.g.:
    :::details Click to expand
    ## Wrapped heading
    :::
  3. Build or preview the page and compare the TOC generated by [[toc]] with the right sidebar.

  1. 在 Markdown 文件中使用 [[toc]]
  2. :::details 块内放置一个标题,例如:
    :::details 点击展开
    ## 被包裹的标题
    :::
  3. 构建或预览页面,查看 [[toc]] 生成的目录和右侧侧边栏的差异

Expected behavior

[[toc]] should use the same heading extraction logic as the "On this page" sidebar, so it should also include headings inside details blocks.

[[toc]] 应与“On this page”侧边栏保持一致的标题提取逻辑,即同样包含 details 块内的标题

System Info

Vitepress: Latest (alpha.17 and .19)
OS: Windows 11 25H11

Additional context

Not sure if it was done on purpose

不确定是不是有意而为之

🤔

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions