badboy / mdbook-toc

A preprocessor for mdbook to add inline Table of Contents support.
Mozilla Public License 2.0
163 stars 20 forks source link

Support for per-toc settings #46

Open dnaka91 opened 1 year ago

dnaka91 commented 1 year ago

Currently, I have some pages where I want to have a lower max level for the ToC content than on the other pages.

For that, it would be great to have some way of applying the max-level (and potent future settings) on a per-toc basis, that can override the global setting.

My idea is to use a comment like the following <!-- toc:max-level = 2 -->.

This could be parse fairly easy, as long as the setting value is limited to a single-line statement.

I saw in the readme that the basic toc marker can be replaced with a multi-line element. That would be very tricky to handle as we have to match the cmark-pulldown events, as well as matching substrings in case they don't fully match.

Maybe it's okay to start with a restriction to single-line elements first, and if anyone needs a multi-line version it could be added later?