mdBook
mdBook copied to clipboard
Adding section titles to ToC / sidebar
@ehuss , Eric, would you consider a PR for the following feature ...
At the moment the sidebar is constructed out of the items listed in SUMMARY.md. It would be helpful to include an additional level out of Hx titles found in the markdown content in the ToC as an optional feature.
At the moment Hx tags are wrapped into with #-anchors, so we just need to add them to the ToC in the right place.
The list of H-levels can be included in book.toml as a setting.
I'm interested, but I think several points need to be settled on before this can be implemented:
- [ ] How does this interact with folding levels? Are those part of the same folding level set as pages, or do they use their own set of levels?
- [ ] Should this be put behind a global toggle? It may be costly due to requiring a parse of all content files instead of just
SUMMARY.md. - [ ] Should all sections be shown for all pages, or only the current page?
@ISSOtm Can it be this form https://github.com/rust-lang/mdBook/issues/167#issuecomment-1293626374? It is very convenient if we can render section titles in sidebar just by adding anchors.
I guess it could, but the above points as well as those still need to be resolved.