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
Can you add exclude a header from toc in secondary sidebar? #313
Comments
I believe something like this could help: #136, but you'd have to adjust the CSS to target your desired level. |
This can not solve my problem. I want to hide heading 5 not level 2 in toc Because I want to use headings in documents in a certain file, But I do not want them to appear in TOC. |
That isn't what #136 means. The person wanted to hide anything greater than 2 levels deep (this isn't referring to h1). So they wanted to show h2 and h3, so the solution hides h4+. If I understand correctly, you want to hide h5+, so you would need to tweak the CSS to start hiding 1 level deeper. Unless I am still misunderstanding. |
Simple I want to use a heading (h5) in documents in a certain file, But I do not want them to appear in TOC. |
At most, all that can be done is excluding a certain header level with CSS. So the solution above is based on header levels (forth in the nested hierarchy), but not header type (h5). The TOC generator (which is separate from this theme), does not have the ability to exclude a specific header type. And the TOC in the sidebar does not track the header type, but simply nests them in a logical hierarchy. So targeting specifically h5 in the sidebar TOC (with the purpose of hiding it) is not possible, but targeting the 4th level nesting is possible. label[for="toc"]+.md-nav__list .md-nav__list .md-nav__list .md-nav__list {
display: none;
} But if you skipped nesting levels, for example nest h5 directly under h2, then this would not hide h5 as it would not be at the proper nested level. So if this is not sufficient for you, I don't think what you want is possible |
When you specify your heading in the Markdown file not like this: ##### Heading but like this: <h5>Heading</h5> It will render correctly and won't appear in the table of contents. |
thank a tip of @squidfunk . |
Never realized this was built-in to the current TOC plugin. Nice to know! |
Well, technically it isn't. The TOC plugin is only parsing the Markdown headline definitions, so by using HTML tags, you sneak them past the TOC plugin unoticed, as it doesn't parse the HTML. Closing this, as it seems to be solved. Otherwise please re-open. |
Hi @squidfunk , is this still the case? It seems like now the TOC is able to render headings which are parsed using HTML tags. Is there any other way in which we can exclude any header from being added to the TOC? Thank you. |
The fix mentioned in #313 (comment) should still work, and it should be unaffected by the new built-in typeset plugin. If that's not the case, please open a new bug report. |
Description
Can you add exclude a header from toc in secondary sidebar? I want add a header 5 to content, but I don't want display header 5 in secondary sidebar (md-sidebar md-sidebar--secondary)
Package versions
2.7.12
0.16.3
1.6.1
The text was updated successfully, but these errors were encountered: