-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prism plugin Code Folding prototype #1045
Conversation
Hi! I checked to demo and I admit this looks really promising! ;) |
@Golmote do you think it has a chance to be merged if I fix the open issues from above or should I better develop it outside of Prism? |
Yes, it could be merged as a plugin in the official repo, no problem. Just tell us once you consider it done so we can test it. |
My usability 2 cents: I would be opposed to specifying line numbers for collapsed sections. That's very fragile and unmaintainable. It would be good as an override, but not as the only way to collapse sections. Sections should be determined by code structure. |
Haha yes that crossed my mind too. But that would imply Prism has info about the code structure for each and every language we support... That's a huge feature to add, don't you think? I agree it would be awesome though! |
True. Alternatively, how about it requires the keep markup plugin and uses |
I like the idea with the keep markup plugin. |
I have tested the idea with |
Nice! While |
Hello @Golmote @LeaVerou |
No, replacing semantic elements with spans is terrible. |
I've released my implementation of code folding for Prism here: https://github.com/nlundquist/prism-js-fold It works via the I haven't run into any problems styling the toggle or collapsible regions as desired. |
Hello,
I'm very thankful for Prism. This pull request is more like a feature request with a prototype. A plugin to fold lines in the code, like some text editors are doing it with functions and loops.
The main idea was to split the text nodes on a newline character and to wrap all nodes inside of the
code
element that are between a given start and end into aspan
element that is collapsible.As said above, this pull request is just a prototype to see if you are interested in a plugin like this.
Known issues at the moment:
the black background of the Funky theme is not working inside of thespan
blockthe foldablespan
elements can not be nestedI have created a small Demo for you. Let me know if you think it would be better to develop a plugin like this outside of Prism.