framework icon indicating copy to clipboard operation
framework copied to clipboard

Customize which headings are shown in the TOC

Open mbostock opened this issue 1 year ago • 2 comments

Currently it’s hardcoded as

h1:not(:first-of-type)[id],
h2:first-child[id],
:not(h1) + h2[id]

Should we allow this to be customizable?

mbostock avatar Jul 23 '24 14:07 mbostock

One issue here is that with multiple levels in the TOC (say, h2, h3), users will want the hierarchy be reflected visually. We could at a minimum provide some classes that reflect the hierarchical level?

Fil avatar Jul 24 '24 08:07 Fil

users will want the hierarchy be reflected visually

I could understand how the current limitation makes the visual noise on the report more manageable.

Though, from another side, I think there're use cases where the user intends to present a structure in the report/dashboard and expects that the structure is also visually represented.

I am not not expert on the front-end tech stack here, but maybe this could controlled by an ObservableHQ configuration at first which could have a default, then it becomes the decision of the user; observablehq.config.js:

export default {
  toc: true,
  maxHeadingLevel: 2
}

nobeh avatar Jan 25 '25 07:01 nobeh