vscode-markdown
vscode-markdown copied to clipboard
Set the TOC levels range at document level
Proposal
Today, you can set the TOC levels thanks to the extensions settings key markdown.extension.toc.levels
.
However, it may happen documents do not have the same structure and range 1..3
is good for some of, whereas a 2..3
would be more appropriate.
An option in the document itself could be very useful:
<!-- toc.levels="1..2" -->
- [Introduction](#introduction)
- [Section1](#section1)
- [Subsectionsection1](#subsection1)
or
<!-- toc.levels="1..3" -->
- [Introduction](#introduction)
- [Section1](#section1)
- [Subsectionsection1](#subsection1)
- [Conclusion](#conclusion)
Another option might be to use VS Code workspace settings, and be able to specify toc.levels
per-file, like so:
{
"markdown.extension.toc.levels": {
"wiki/Upgrade-Guide.md": "2..2"
}
}
Having said that, I personally prefer specifying it inline via HTML comment as the OP requested.
Thanks for the feedback. I agree this can be useful.
And for your case (@rcdailey), you can add <!-- omit in toc -->
to the first-level heading if you already have toc levels 1..2
in your user or workspace settings.
@yzhang-gh I'm not sure what you are suggesting. In my case, I only want 2..2
. And in my preferences, I have 2..6
. And omit in toc
only works per-header, right? So I'd have to repeat it for every single header below level 2. I'm not sure how that addresses the issue.
And in my preferences, I have
2..6
.
I see. Then there is no workaround for now.
I recently came across the same need; that is, to be able to specify toc levels on a per file basis. I agree with the OP that in-lining something in the file itself (akin to <!-- omit in toc -->
) is the most intuitive, discoverable and maintainable.
Thanks for an awesome VSCode extension - love it!
Is this a duplicate of #208 ? Anyway, I would also vote for per document settings especially for TOC level range.