Right TOC does not include headings generated outside of markdown
See original GitHub issue🐛 Bug Report
This is for v2. The right TOC for documentation pages does not include headings that were generated outside of the markdown syntax.
Have you read the Contributing Guidelines on issues?
Yes
To Reproduce
- Add a
<h2 id="my-anchor">Title</h2>HTML tag anywhere in a documentation markdown file. - Notice it does not show up in the right TOC.
Expected behavior
I expect for the title to show in in the right TOC just as it would if I provided a ## Title line.
Actual Behavior
The heading does not show up in the right TOC.
Reproducible Demo
n/a
My primary issue with this is adding heading in custom components. Even when I import Heading:
import Heading from '@theme/Heading';
let Title = Heading('h2');
return (<Title>My title</Title>);
While this includes the appropriate anchor links, it still does not show up in the right TOC.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
4.18 Omit a heading in the table of contents - Bookdown
If you do not want certain section headings to be included in the table of contents, you can add two classes to the...
Read more >How to add table of contents in Rmarkdown? - Stack Overflow
## Header 2 When you click the **Knit** button a document will be generated that includes both content as well as the output...
Read more >Headings and Table of contents - Docusaurus
Markdown headings within hideable areas will still show up in the TOC. For example, headings within Tabs and details will not be excluded....
Read more >Add a Generated Table of Contents Anywhere in RMarkdown
When I use toc: true in a post the toc is inserted at the very top of the post. … If you could...
Read more >8.5 R markdown anatomy | An Introduction to R
In RStudio a minimal YAML header is automatically created for you when you ... your R markdown document outside a code chunk which...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @jacksongoode
I’d like to enable better MDX composition patterns (ie mdx partials/fragments) without loosing that TOC feature like we currently do.
Unfortunately have to finish i18n support in v2 first, but it’s in my mind to work on this problem.
Hi.
I wanted to bring this topic back up since there doesn’t currently appear to be a way to generate a TOC from an .mdx/.js - only through markdown. Is there a hacky way to achieve this through html alone?
I am rendering new pages with content in an mdx and it would be nice to have a TOC for them.