Markdown code folding

Markdown code folding

2
NewbieNewbie
2

    Apr 08, 2020#1

    Hello,

    Does anyone have any luck with using code folding on Markdown files? I.e., so that sections, such as #... ##..., have folding supported like in other languages?
    I could not figure out what the fold open and close strings could be to support this properly...

    Regards,
    Hagai.

    6,606548
    Grand MasterGrand Master
    6,606548

      Apr 08, 2020#2

      The simple solution to fold a chapter in a markdown file is with:

      Code: Select all

      /Open Fold Strings = "# "
      /Close Fold strings = "# "
      Then UltraEdit/UEStudio offers to fold a block from one line containing a hash and a space to next line containing a hash and a space independent on line being really interpreted by markdown processor as heading line or not, i.e. when there is a hash and a space in a code block or a quote.

      But it is impossible to get a hierarchical code folding depending heading structure. Code folding is not designed for such a hierarchical folding. It is not possible to define that on having found
      1. a line being interpreted as heading 1 to search for one more line being interpreted as heading 1 or end of file
      2. a line being interpreted as heading 2 to search for one more line being interpreted as heading 2 or heading 1 or end of file
      3. a line being interpreted as heading 3 to search for one more line being interpreted as heading 3 or heading 2 or heading 1 or end of file
      4. and so on for the other heading levels
      5. and run the searches for headings with recursive called subroutines whereby each subroutine is responsible for one heading level.
      The code folding engine simply parses the character stream of a file from top to bottom and searches for open or close fold strings and for block comments and line comments without using a recursion and without specialized subroutines for a hierarchical fold of markdown formatted headings.

      It is perhaps possible to define regular expressions to get in function list view a hierarchical list of the headings like the navigation view of Microsoft Word for a Word document. But I doubt that this can be done due to most likely required recursion with special conditions for each level as regular expression engines are not designed in general for such purposes.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Apr 09, 2020#3

        Mofi,
        Thanks a lot for that! Actually, this is kind of what I expected, particularly as I noticed that the fold open and close strings are searched for literally, without the richness of how function strings are defined (nested, with regexp, etc.)
        I appreciate your taking the time to explain it thoroughly.