Skip to content

The toc directive with page context is missing all sections except one when the title in the metadata is the same as the heading title #2723

@Polirecyliente

Description

@Polirecyliente

Good day team, when the title in the metadata is the same as the title of the first section of the document, only the subsections of that first section will appear in the output of the toc directive using the page context.

This is the output of myst -v:
v1.8.1

This seems to be the current release at the moment of this writing.

Description

This is a minimal working example to see the problem with the toc directive.

---
title: Working title 1
---

# Working title 1

## Heading level 2

# Next section

::: {toc}
:context: page
:::

# Next next section

# Last section

After running myst init and myst start, these are the observed results:

Image

Workaround

This only happens when the title in the metadata "Working title 1" is the same as the title of the first section "Working title 1", so a workaround is to change either of them, and then all the sections are rendered in the toc, here is an example for reference:

Image

As can be seen, the full toc is now formed.

Proposed solution

When using the context page on the toc directive, the full toc should be formed, showing all the sections of the page.

Additional notes

Team please let me know if I made a mistake and this is not an error. The minimal working example was created with default configurations from myst init. If there is need, I can try to fix this issue, I work with TypeScript daily so maybe I can give it a shot, please let me know so as to avoid duplicate work. Thank you very much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions