nagaozen / markdown-it-toc-done-right

A table of contents (TOC) plugin for Markdown-it with focus on semantic and security. Made to work gracefully with markdown-it-anchor.
MIT License
133 stars 26 forks source link

Only H2s? #55

Closed pburrows closed 3 years ago

pburrows commented 3 years ago

Is there a way to specify in the options that only certain header levels are included in the Table of Contents? For instance, if I want only H2 and H3 in the ToC, but not H4, H5, and H6?

The only thing that looks close is "level", which specifies the maximum level.

Perhaps as an enhancement, keep the existing functionality for level when a single value is passed in, but if an array is passed in, use just the levels in the array?

nagaozen commented 3 years ago

Level option is overloaded with two different inputs.

(as an integer) -> takes all headers with levels >= level (as an array) -> take only the levels specified by the array

So, you are probably looking for [2,3].

Since it's already implemented, I'm closing this issue.

pburrows commented 3 years ago

Cool! Thanks! (that's what I was suggesting)