-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
What’s the request
Add optional support for code-folding / collapse-expand in PrismJS for large code blocks or multi-file code snippets.
Motivation / Why this is useful
For long code blocks (e.g. 200+ lines) or when embedding multiple files in a single page, scrolling becomes cumbersome and readability suffers.
Code-folding would help maintain clean layout and improve usability when viewing big code samples (especially for documentation, tutorials, or code reviews).
Many other syntax-highlighters support folding — adding it to PrismJS would make it more feature-rich and user-friendly.
What I propose / Feature details
Provide an optional plugin or built-in mechanism to allow folding of code blocks: by default collapsed (first few lines visible), with toggle to expand.
Support collapse per block — not mandatory: user/developer must opt-in (e.g. via data-attribute or config) so it doesn’t break lightweight usage for small snippets.
Ensure that syntax highlighting still works correctly when folded/unfolded, and that HTML output remains valid (colors, line numbers, etc.).
Additional context / Use-cases
Useful for documentation sites, blogs, tutorials where large code examples are common.
Helpful when embedding multiple code examples on one page.
Could optionally integrate with existing Prism plugins (if feasible) or be developed as a new plugin to maintain modularity.