FIXED: Markdown Folding

Make a request or discuss new features.
Post Reply
ScrKiddle
Posts: 39
Joined: 05 Aug 2026 03:15

FIXED: Markdown Folding

Post by ScrKiddle »

RJ TextEd should provide some Code-Folding for Markdown-Files.
In Plain-Text folding is mostly done with indent by tag or space.
This does not work the same way in markdown.

Actually the folding works in the YAML-Header of Markdown-Files.
But the rest of the Markdown file works like plain-text when it comes to code-folding.
But in Markdown the different headings should start at the beginning of the line, and mostly that is what at least should be foldable in Markdown-Code.

# Heading 1
Text and more

# Heading 2
Text and more fold me

# Heading 3
Text and more

When folded it should look similar to

# Heading 1
Text and more

# Heading 2 (...)

# Heading 3
Text and more

This should be possible on all Levels of Headings like h1 to h6.
ScrKiddle
Posts: 39
Joined: 05 Aug 2026 03:15

Re: Markdown Folding

Post by ScrKiddle »

I also notice the code explorer in Markdown files is empty.
Nothing about Markdown gets listet

I just see some entries with codeblocks in backticks.
No Headings at all.

:roll:
User avatar
Rickard Johansson
Site Admin
Posts: 6973
Joined: 19 Jul 2006 14:29

Re: Markdown Folding

Post by Rickard Johansson »

Fixed in next release. Thanks!

markdown10.png
markdown10.png (15.03 KiB) Viewed 397 times
markdown11.png
markdown11.png (6.79 KiB) Viewed 397 times
ScrKiddle
Posts: 39
Joined: 05 Aug 2026 03:15

Re: FIXED: Markdown Folding

Post by ScrKiddle »

Version 16.66 beta 4 is in fact a huge improvement !!! :-D

There are still some minor issues, but at the side of the previous versions it looks skyrocket.

Now the Headings in markdown can get folded, and they also appear in the code-view. This is a huge step forward in markdown handling.

Thank you very much for that!

Some minor issues do still exist.

Now the YAML File-Header lost its ability to fold.

The YAML Header is always on top of MD-Files between its leading mark ---.

Code: Select all

---
title: "some string"
description:
  some string
  with multiple
  lines
version: 1.2.3
keywords:
  - list
  - of
  - words
---
<!-- MD follows -->
Here indent does not fold any more, it did before how ever the MD-folding is much more important.

Idealistic it would fold again on indent:

Code: Select all

---
title: "some string"
description: (...)
version: 1.2.3
keywords: (...)
---
<!-- MD follows -->
---

An other thing:

Code: Select all

# Heading 1

some text.

## Heading 1.1

some text

### Heading 1.1.1

some text

#### Heading 1.1.1.1

some text

##### Heading 1.1.1.1.1

some text

###### Heading 1.1.1.1.1.1

some text

# Heading 2

some text
Now when folding a Heading should fold it self including all its sub-headings but no the next heading of the same level and its sub-headings.

Code: Select all

# Heading 1

some text.

## Heading 1.1

some text

### Heading 1.1.1 (...)

# Heading 2

some text

Code: Select all

# Heading 1 (...)

# Heading 2

some text
Actually it looks like the following, where sug-headings do not get folded in theyr super-heading:

Code: Select all

# Heading 1 (---)

## Heading 1.1 (---)

### Heading 1.1.1 (---)

#### Heading 1.1.1.1

some text

##### Heading 1.1.1.1.1

some text

###### Heading 1.1.1.1.1.1 (---)

# Heading 2

some text
How ever, the folding headers even without folding the sub-headers are a huge improvement !!!
User avatar
Rickard Johansson
Site Admin
Posts: 6973
Joined: 19 Jul 2006 14:29

Re: FIXED: Markdown Folding

Post by Rickard Johansson »

I think all fold issues are fixed now in the next version.

markdown20.png
markdown20.png (27.08 KiB) Viewed 369 times
markdown21.png
markdown21.png (7.81 KiB) Viewed 369 times


YAML block is foldable and listed in the code explorer. Indent should fold as well.

Header blocks are nested both in the editor window and code explorer.
ScrKiddle
Posts: 39
Joined: 05 Aug 2026 03:15

Re: FIXED: Markdown Folding

Post by ScrKiddle »

Awww, this looks promising :-D
User avatar
Rickard Johansson
Site Admin
Posts: 6973
Joined: 19 Jul 2006 14:29

Re: FIXED: Markdown Folding

Post by Rickard Johansson »

A new beta version to try viewtopic.php?t=5988
ScrKiddle
Posts: 39
Joined: 05 Aug 2026 03:15

Re: FIXED: Markdown Folding

Post by ScrKiddle »

Rickard Johansson wrote: 13 Aug 2026 18:32 A new beta version to try viewtopic.php?t=5988
Testing that :-D

The idea of folding makes it definitively better!

But we have still some funny odds:

Given text:

Code: Select all

# Heading 1

After a blank line there is a paragraph followed by a blank line.

## Heading 2

After a blank line there is a paragraph followed by a blank line.

### Heading 3

After a blank line there is a paragraph followed by a blank line.

#### Heading 4

After a blank line there is a paragraph followed by a blank line.

##### Heading 5

After a blank line there is a paragraph followed by a blank line.

###### Heading 6

After a blank line there is a paragraph followed by a blank line.

# Heading One

After a blank line there is a paragraph followed by a blank line.

## Heading Two

After a blank line there is a paragraph followed by a blank line.

### Heading Three

After a blank line there is a paragraph followed by a blank line.

#### Heading Four

After a blank line there is a paragraph followed by a blank line.

##### Heading Five

After a blank line there is a paragraph followed by a blank line.

###### Heading Six

After a blank line there is a paragraph followed by a blank line.

# Heading I.

After a blank line there is a paragraph followed by a blank line.

## Heading II.

After a blank line there is a paragraph followed by a blank line.

### Heading III.

After a blank line there is a paragraph followed by a blank line.

#### Heading IV.

After a blank line there is a paragraph followed by a blank line.

##### Heading V.

After a blank line there is a paragraph followed by a blank line.

###### Heading VI.

After a blank line there is a paragraph followed by a blank line.

Now let us fold that:

[OK] "# Heading 1" does fold until "# Heading One" and stops there.
[Problem] "# Heading 2" does fold until "# Heading Two" but it should fold until "# Heading One" and stop there.
[Problem] "# Heading 3" does fold until "# Heading Three" but it should fold until "# Heading One" and stop there.
[Problem] "# Heading 4" does fold until "# Heading Four" but it should fold until "# Heading One" and stop there.
[Problem] "# Heading 5" does fold until "# Heading Five" but it should fold until "# Heading One" and stop there.
[Problem] "# Heading 6" does fold until "# Heading Six" but it should fold until "# Heading One" and stop there.

Now let us fold the next chapter:
[Problem] "# Heading 6" does not offer any folding, and all following headings do not offer folding until "###### Heading Six".
[Problem] "###### Heading Six" does fold until "###### Heading VI." but it should fold until "# Heading I." and stop there.
[Problem] "# Heading I." does not offer any folding, and all following headings do not offer folding until "###### Heading VI.".

I guess from there on this strange behavior gets repetitive...

There is an other thing about Markdown-Headings:

In Markdown there are two special cases to format headings:

Code: Select all

Heading Level 1
===============

After a blank line there is a paragraph followed by a blank line.

Heading Level 2
---------------

After a blank line there is a paragraph followed by a blank line.
The trick is, after each heading there must follow a blank line in any case, but if there ist not a blank line then it can be a line of equal symbols or minus symbols as long as the heading is, equal means level 1 and minus means level 2.

But attention:

If there is a blank line before three or more equal or minus symbols, followed by a blank line, then it is a separator line (in HTML the <hr />-Tag).

Separator-Lines can look like the following (pretty strange):

Code: Select all


* * *

***

*****

- - -

---------------------------------------

They can have spaces between the asterisk or the minus symbols,
the horizontal rulers begin always at the begin of line no space or tabs before them,
the symbols repeat at least three times but they can repeat them self even more times,
before and after a horizontal ruler is a blank line to distinguish them from YAML-Blocks.

Most people repeat the symbols three times without space in between.
Some people who often use JavaScript use *** others who are more in HTML use --- but then some repeat them more than three times to get nice code formatting.

Some interpreters also allow fancy rulers like three equal symbols, after and before a blank line, what makes then different from level 1 headings which use equal signs on the next line.

While editing it often happens that there appear some spaces after a HR, mostly they get deleted on save-file.

---

And just to have it said, between # and a string at the beginning of a line there is a space, so it is a heading, if there is no space between # and the directly following string, then it is a #Hashtag.
User avatar
Rickard Johansson
Site Admin
Posts: 6973
Joined: 19 Jul 2006 14:29

Re: FIXED: Markdown Folding

Post by Rickard Johansson »

Folding for headings seems to work properly now after some minor code changes and modifications to the syntax file.

markdown30.png
markdown30.png (43.7 KiB) Viewed 293 times


As for underlined headings, I'm not even sure I can make that work with folding...
ScrKiddle
Posts: 39
Joined: 05 Aug 2026 03:15

Re: FIXED: Markdown Folding

Post by ScrKiddle »

Works remarkable better since 16.66 beta 6 !
Headings from 1 to 6 do now fold perfectly. :-D
Heading 7 does not exist and dost not fold perfectly as it should be. :-D
#Hashtags do work, perfectly. :-D
<URL> links do not anymore create blockquote. :-D
There still are some minor issues, but it looks a lot better!!! :-D
after a quick look i see an issue with HR-Lines

Code: Select all

***

* * *

---

- - -

_________________
*** is normal text

* * * the last star is normal text

--- looks similar to a nunber

- - - the last - looks like text

_________________ looks nice

with b**ol**d / b__ol__d and it*al*ic / it_al_ic without space before or after are problematic, mixed formats also have some problems and odds.

Mixed Format test:

Code: Select all

Text with ***bold italic text*** in it.

Text with ___ bold italic text___ in it.

Text with _**bold italic text**_ in it.

Text with *__bold italic text__* in it.

Text with **_bold italic text_** in it.

Text with __*bold italic text*__ in it.

String with bo_**ld ital**_ic in it.

String with bo*__ld ital__*ic in it.

String with bo**_ld ital_**ic in it.

String with bo__*ld ital*__ic in it.

Bold italic with ***st***ri***ng*** in it.

Bold italic with ___st___ri___ng___ in it.

Bold italic with _**st**_ri_**ng**_ in it.

Bold italic with *__st__*ri*__ng__* in it.

Bold italic with **_st_**ri**_ng_**_ in it.

Bold italic with __*st*__ri__*ng*__ in it.
But over all, its much better than ever before :-D :-D :-D
User avatar
Rickard Johansson
Site Admin
Posts: 6973
Joined: 19 Jul 2006 14:29

Re: FIXED: Markdown Folding

Post by Rickard Johansson »

Does this look correct?

I've tried in different editors and they all give different results.

BoldItalic1.png
BoldItalic1.png (43.25 KiB) Viewed 116 times
BoldItalic2.png
BoldItalic2.png (4.19 KiB) Viewed 116 times
ScrKiddle
Posts: 39
Joined: 05 Aug 2026 03:15

Re: FIXED: Markdown Folding

Post by ScrKiddle »

Rickard Johansson wrote: 20 Aug 2026 17:06 Does this look correct?

I've tried in different editors and they all give different results.


BoldItalic1.png


BoldItalic2.png
Actually in Beta 6 (there is no newer) here it looks like that...
Mixed_Format.png
Mixed_Format.png (138.96 KiB) Viewed 93 times
If it will look as in your example above, it will be great!
Dont care how it looks in other editors, RJ TextEd will get and do better :P :-D

There are some references on Markdown which are not consistent:
This is Pandoc which has some special formats https://pandoc.org/MANUAL.html
They say it that way...
Pandoc understands an extended and slightly revised version of John Gruber’s Markdown syntax.
With "John Gruber’s Markdown syntax" they mean that one https://daringfireball.net/projects/markdown/syntax

there is also a basic reference that is often used by people who just search for an markdown reference, they have three relevant chapters, basics, extended and hacks.
https://www.markdownguide.org/basic-syntax/
https://www.markdownguide.org/extended-syntax/
https://www.markdownguide.org/hacks/

There is also the obsidian editor they are very advances on markdown https://obsidian.md/help/syntax and also support stuff like Mermaid-Blocks (hehe just like RJ TextEd), MathJax-Blocks, Inline-HTML, different types of Links like Wiki-Style, internal or external links and so on, different types of formatting like Strike, Notes, Callouts and so on, and like RJ TextEd they also know #Hashtags, but again the base is as in Pandoc "John Gruber’s Markdown syntax" https://daringfireball.net/projects/markdown/syntax

Many chat messenger apps also know some very basic markdown formattings like Bold, Italic, Underline, Strike, and all of that mixed but also monospace/code (WhatsApp, ...) and #Hashtags (Telegram, Matrix, ...).

There is also Git-Hub with some fancy Stuff https://github.github.com/gfm/, they also support Mermaid and MathJax like many but also exotic stuff like GeoJSON or TopoJSON and ASCII STL syntax for 3D models.

The difference between a text-editor or code-editor and an explicit markdown-editor ist mostly the ability to use the Zettelkasten-Method https://zettelkasten.de/introduction/ directly in the Markdown-Editor like in obsidian or Zettlr https://docs.zettlr.com/en/editor/markd ... ndium.html, beside of all the other common references zettler also names https://spec.commonmark.org/0.31.2/ as an reference.

Mostly the basics are always the same, what most take into account for preview are some types of blocks like Mermaid, MathJax, ... Some do support some special comments formats like for blocks or even inline, most are fully prepared to fully support Pandoc because this tool is very often used to format all kind of text-files into any thing else.

How ever, since shortly RJ Text seems to be on a very good way to support full-blown Markdown Code very nicely and lovely!!! :-D

Why does markdown even matter...
I think there are many projects in near to any "normal", exotic or fancy coding-language who use markdown in theyr documentation, many projects get hosted on some git-hub style platform and most of them invite theyr users to use markdown in theyr docs, so many editors are maybe good in one or more coding-languages but all of them should be at least fine in markdown.

If such editors also provide fancy stuff like clickable hashtag clouds or gephy style graphs, dead-link detection, clickable links which open the linked document, what may is beyond of just a text-editor then it turns into some thing of high interest for not only program-code but also for story-tellers and creators of text-adventures and other people who are not exklusivelly interested in coding of some apps in python, c++, JS or some thing around that.

But for now... we already got a lot of improvements on markdown, and the whole world is humble awaiting the next superb awesome betas :-D

> Hey .. Thank you very much for all your passioned work !!! 👍
Post Reply