facelessuser / pymdown-extensions

Extensions for Python Markdown
https://facelessuser.github.io/pymdown-extensions/
Other
931 stars 248 forks source link

Collapsible sections in code fences #2386

Closed maldoinc closed 1 month ago

maldoinc commented 1 month ago

Description

Hi all, I've been using this indirectly through mkdocs-material for the docs of my project at https://maldoinc.github.io/wireup/.

Given that it's a library it includes a lot of code fences. Often I find myself debating whether I should include imports in the example or not. I want them there for easy copy-paste of the code and for users to discover where imports are but they also make the code feel a bit more cluttered.

What if there was an option to allow you to collapse a particular part of the code so that it could be used for imports. Perhaps this could be expanded to allow collapsing/expanding any wrapped section in the code fence.

Benefits

This makes the code examples look cleaner by removing imports.

Solution Idea

JOOQ documentation has collapsible import sections https://www.jooq.org/doc/latest/manual/getting-started/the-manual/

facelessuser commented 1 month ago

SuperFences relies on Pygments. Since this functionality does not exist in Pygments, it will not exist in SuperFences. I currently have no plans to try and override Pygments to provide such functionality.