Skip to content

Markdown table of contents doesn't handle YAML frontmatter #14200

@bollwyvl

Description

@bollwyvl

Description

When editing a Markdown document with YAML front-matter, the Table of Contents shows only the last item of frontmatter.

image

Reproduce

  • Open the Launcher

  • Click on Markdown File

  • Open the Table of Contents sidebar

  • Add a header

    # Hello World
  • See Hello World in the Table of Contents

  • Add some YAML front matter before the header

    ---
    foo: bar
    boo: baz
    ---
    
    # Hello World
  • See only boo: baz in the Table of Contents

This was found while working on a JEP in JupyterLab.

By adding a newline above the second ---, the problem also goes away, so presumably it's treating that last item as an h2 which counterfeits everything below it.

Expected behavior

  • Definitely see all the headers
  • Maybe see a collapsible table above/below the rest of the items
    • but definitely not worth adding/faking a YAML parser
    • maybe just a chunk of YAML-formatted code (e.g. if the first line starts with [^:]+:

Context

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions