[NEW] Hidden & collapsable lines in the HTML formatter
What problem does this feature solve?
Line highlighting is a mechanism that draws attention to specific regions in the content. However, due to technical considerations (e.g., boilerplate for testable examples), the code content becomes too verbose, making a line highlighting less-than-effective means by itself alone.
What feature do you propose?
The proposed feature will allow lines (and ranges of) to be marked as highlighted (the existing), hidden, or collapsed.
Single and ranges of lines marked as hidden will not be displayed via CSS display: none.
Collapsable ranges will be rendered as a placeholder (e.g. "Click here to expand").
A collapsed range can be expanded via user interaction.
Collapsed ranges can be set to display expanded initially.
The HTML <details> tag appears to be a suitable mechanism for that.
More:
- Intuitively, I think we'll be ok if we allow contained ranges like highlight inside/covering a collapsed range (although who'd do that?), but extra care is probably needed to err on overlaps.
- Line numbers, w/ and w/o tables, is probably gonna be a pain :)
#340 seems also relevant in this context.
This seems reasonable, but I think we need a more holistic solution to customising the HTML output. The proliferation of options is getting pretty out of hand.
I'm thinking perhaps something like a post-processing hook that receives a parsed HTML object.
Sounds like a promising approach - I'd be happy to take a stab at it. That said, I'm unclear how this would look. I can envision a hook when Chroma is used from another package, but I'm hitting a wall thinking about the cli. Can you draw me a picture in broad strokes?