Home / GitHub Page

Feature request: Folding sections of text

I would love a way to fold sections of code like you can do in FoldingText, and also in most IDEs (VSCode, etc.). Is this possible in Joplin?

1 Like

We use ace editor. Please submit a feature to the Ace editor team.

Also, please note that the ace editor is only used on desktop.

1 Like

hello everyone.
I’ve been taking a look to ace editor, and it seems to have this functionality:

Look at this sandbox: https://ace.c9.io/kitchen-sink.html?doc=Markdown

Peek 2020-02-11 07-26


This works for me (took it from Markor :slightly_smiling_face:)

I think the OP was talking about the text editor, not the preview pane. At one point I suggested to add this as a markdown plugin to be able to use the same code as in this forum:

This text will be hidden

and this one

[spoiler]This text will be blurred[/spoiler]

Ok, my mistake, didn’t read carefully enough.

Where can I find more about the markup for this forum? I didn’t know about any [something][/something] tags.

Haha, this is a very good question. The developers of Discourse do not believe in documentation. (That’s why being an admin for this forum is not that easy.) Sometimes things are mentioned in topics on their forum.

I stumbled upon it when clicking on this button:

Aha! And a third one: Build Poll. There might be more under the hood. Let’s try, doing it systematically. First experiment: [aardvark]a large burrowing nocturnal African mammal[/aardvark]… nope!


The poll woudn’t be very useful in Joplin, but the other 2 are. Some people expressed their wish to mask passwords in the preview, thus the blur function could help with that. The other one is really good to hide info that is not always required when reading a note.
Anyway, nothing came of my suggestion.

P.S.: Apologies to the OP. It was not my intention to hijack this topic. I’ll stop now.

Hi tessus,

Folding on editor side

I had a look at the ace editor configuration and for me it would be very helpful to be able to configure the ace editor gutter (left side pane which could show line number, displays folding arrows).

Would it be possible to add the following options to Joplin configuration?

  • show line numbers (on the ace gutter)
  • show folding indicator arrows (on the ace gutter)

Folding on rendered markdown

For me the solution of ipra worked very well. In order to make the experience with this feature better, I could imagine two levels of integration of this feature:

  1. Simple integration: Joplin could have a format bar icon for inserting the code below:
    Snippet for default open
        <details markdown='1' open>
        <summary>Summary of folded text</summary>
        Extended information which is folded by default.
    Snippet for default closed
        <details markdown='1'>
        <summary>Summary of folded text</summary>
        Extended information which is folded by default.
  2. Full integration: The renderer could automatically push the html code for open / closed sections depending on the folding state of the ace editor. I’m not sure if Joplin can access the folding state from each ace editor sub part and if this injection of the folding html code is possible.

What do you think about it? In general the folding feature could be a big improvement for people who have well structured big notes.

1 Like

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.

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.

1 Like

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.


<details markdown='1'><summary>

### 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

Extended information which is folded by default.

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


Extended information which is folded by default.

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…


### Standard headline - as supported right now

### [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


Summary of folded text

Text which is folded at the moment

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.