Use case or problem
Obsidian is awesome for taking notes on code.
I have gotten in the habit of explaining my code or code that I am learning about using the following setup:
- comment of LINE 1
- comment of LINE 2
- comment of LINE 3
- comment of LINE 2
LINE 1
LINE 2
LINE 3
But, it can become quite arduous to keep the comments and the lines straight, especially for complex code.
Proposed solution
It would be helpful if the implementation of code blocks allowed for collapsible comments that get rendered into the view of the code block in the note without having to actually add those comments into the code.
Instead, one possible solution would be to use the matching indentation setup, like I use, and even let the collapsible code block comments have a collapse/expand all command as well as individual collapse and expand functionality for each comment via a button on the comment as well as possibly hotkeys triggered from the current line in the comment hierarchy or the code.
In addition to allowing us to keep the actual code clean from comments, I could also imagine some sort of highlighting/color coordination setup that would make drafting the comments easier. In order to make this work, the code block would render the collapsible comments while we are modifying them in the comment hierarchy.
This could create a situation that would be a throwback to the old days of split screen with edit on left and preview on right except both would actually be using Live Preview, but the split screen would be necessary to allow for an easy side by side of the comment and the code hierarchy. I imagine all kinds of additional features where there could be folding and expanding of the visible code based on folding and expanding of the comment hierarchy and vice versa.
I understand I will have to likely remove a bunch from this request to make it more valid and realistic, but I just wanted to get the idea down while it was fresh. It could be a cool standalone tool or a plugin, but something tells me a feature like this might actually register as a feature request because it could make Obsidian that much better for a usage I imagine is quite common.
Thanks!