Feature request: Folding sections of text

Folding on editor side is easy to achieve. I could add an option to the Appearance tab in settings.
But I am not the one who makes the decisions. Laurent will have to approve and I can add it.

The integration to the rendered markdown is a bit more involved. You’d basically need 2 toolbar buttons for a section (collapsed/not collapsed), so I don’t think Laurent would go for that. (I wouldn’t.) But I could be wrong.
IMO this makes no sense. If you wanted to add a section, it should be closed by default.
You are not going to read a text and stumble across an open section and just close it. In that case, it should not have been open in the first place. The whole idea is to hide details in a text that you can look at, if you need it. Not the other way around.

2 Likes

Now @laurent has to accept it…

This is completely good for me. The “Full integration” was just an idea. I did not know if this is needed by other users and if this is wanted by laurent. It was just an idea.

Thank you for your ideas about that and your commitment to implement the config change.

You are welcome. Now we have to see, if the PR gets accepted.

Unfortunately the details text is not treated as markdown. This makes this feature pretty useless.

3 Likes

Hi sciurius,

yes, you are right. I’m sorry for not retesting the stuff, I used the code from ipra and just tested the folding…

I found out that for rendering markdown code inside the <summary> and inside the folded text an empty line before the markdown code is needed. The markdown renderer inside this forum here shows the exact same behavior.

The following example shows how to render markdown inside the summary and the content of a folded section. The only issue that it shows, is that the folding arrow is shown in an empty line before the summary headline.

Code

<details markdown='1'><summary>

### Summary of folded text
</summary>

Test List
* first item
* second item

#### Test subchapter 1

Test numbered list
1. Numbered list item 1
2. Numbered list item 2

#### Test subchapter 2
Text

Extended information which is folded by default.
</details>

Rendered result

Summary of folded text

Test List

  • first item
  • second item

Test subchapter 1

Test numbered list

  1. Numbered list item 1
  2. Numbered list item 2

Test subchapter 2

Text

Extended information which is folded by default.

3 Likes

Hi tessus,

my idea behind the whole folding stuff is coming from an experience I made with a wysiwyg text editor. It displays a folding arrow besides each headline. With that you can fold down your document to have a better overview and to blend out not needed details.

Do you think that maybe such a behavior (automatically support folding of headlines inside the rendered markdown) can be implemented inside the markdown renderer? This would not need to extend toolbars etc, so the main user will not see any change but the arrows shown in the rendered markdown besides each headline...

For me this would be very great. A second step for this feature could be that the state of the folding would be safed inside the markdown code of the headline. With this it would be like importing antigravity... :snake: :wink:
I think about something like extending the markdown code for headlines with an optional part that tells if the content is folded or not. As soon as the user folds down a headline inside the markdown preview (rendered), the [folded] tag appears inside the editor between the headline start tag ### and the headline text.

@laurent What do you think about that? This could make the work with long notes much more comfortable for power users...

Code

### Standard headline - as supported right now
Text

### [folded] Folded headline
Text which is folded at the moment

Expected rendered markdown

(the displayed arrows should be in the same line as the headline, sorry for that)

Standard headline - as supported right now

Text

Summary of folded text

Text which is folded at the moment

2 Likes

I think there are 2 topics around folding: one is the text (source/markdown)and the other is the rendered text (preview).

The folding marks in the editor will allow you to fold text in the editor. Nothing will happen on the preview side.And the folding marks will be whereever the ace editor thinks they should be. (I know they will fold sections (header to the next header), or code blocks, but I’m not sure what else. I don’t use code folding for taking notes. Especially since those will be uncollapsed again when you open the note. They do not persist. So what’s the point?

Folding in the preview is only possible with the HTML that was discussed earlier.

I think any more than that is out of the scope of this project. This is a note-taking application, not a content management system with word processor capabilities. And I am glad that it isn’t. I despise word processors for many reasons which I don’t want to go into.

I certainly understand your wish to add certain features, but IMO there are more important things to tackle first.

My last post here was for “Folding on rendered markdown”.
For me it is ok, if there is a decision to not do anything in such a direction. It was just an idea, because I think this could help all power users that have big notes.

Clear statement from your side tessus.
Thank you.

I’m not saying that this will never make it into Joplin. First Laurent has to accept it and then you will have to find someone to implement it.

2 Likes

Couldn’t agree more!! It also becomes easy to navigate in large notes

I am working with large notes and I also think that folding sections will be extremely useful to help navigation within the relevant parts of a note in both editor and rendered HTML (could be an option for both).

Even if they are unfolded on each note reload, it is better than nothing (a simple "collapse all" button would be nice though).

1 Like

Throwing a vote in on editor folding! :wink: My two cents:

  • I couldn't care less about folding within the rendering.
  • Folding within the editor is one of the most valuable features for any editor.
  • Folding lets you easily work within a particular scope of a document without being getting totally and completely lost; especially when working in larger documents.

+1 for editor folding. :wink:

This is possible to add with a plugin, but likely won't make it to the base application. Just keep your eyes open, I'm sure a plugin will popup soon

Please don't forget that Joplin is not a text editor - or at least it is not its main purpose.
Also, even if there was code folding, it would not be persistent, so how useful is it really? Anyway, Caleb is right. This might be done via plugin at one point.

Had really little time so its as basic as can be.

@tessus makes good point about persistence,
maybe rewriting cm addon itself would allow for
programmatic folding, hence saving folding

Just my two cents: while Joplin is made to be a coding application first, it should be equally friendly for those that want to put notes in Joplin. One of the reasons I moved to Joplin was because of its encryption. Unfortunately, Joplin doesn't seem to have easy access to features OneNote had - such as using Tab easily, as well as collapsible text. In OneNote, you could collapse any text that was tabbed underneath the text. All you would do would be to double click the left side of the main title and BAM, all text would be collapsed. PLUS, it would stay that way until you un-collapsed it.

This is a misconception that comes up on this forum every now and then. Where did you hear this? Or at least what made you think that Joplin is even suitable for coding?

I read tessus' post that "Please don't forget that Joplin is not a text editor - or at least it is not its main purpose." on this thread. I defaulted to assuming that it was for code, as it does use the markdown editor heavily.

Hmm, for coding one actually use a text editor. :wink: