Display markdown outline view through Functionlist

  • functionList.xml:

          <association id=  "Markdown(Monokai)"     userDefinedLangName="Markdown(Monokai)" />
          <association id=  "Markdown(Monokai)"     ext=".md"                               />
          <association id=  "Markdown(Monokai)"     ext=".markdown"                         />
            id         ="Markdown(Monokai)"

  • @linpengcheng

    Is there a question lurking somewhere there??

  • I interpreted it as someone sharing a hack / tip / trick to be able to use the FunctionList feature to give an outline of a markdown document. I didn’t try it (yet), but I think sharing hacks, tips, and tricks is a great thing to have in this forum, which is why I upvoted it.

    It should be noted that users will need to use their association ID for markdown, if their Markdown UDL doesn’t happen to be called Markdown(Monokai). If you use the default Markdown UDL that ships with Notepad++, it’s Markdown (Default).

    I just confirmed that replacing Markdown(Monokai) with Markdown (Default), and doing a simple markdown file, worked as expected:


  • See also issue 5986 and issue 5945.

  • @PeterJones said in Display markdown outline view through Functionlist:

    I think sharing hacks, tips, and tricks is a great thing to have in this forum, which is why I upvoted it.

    I agree with that. However, if you’re going to share something, at least put a little effort into describing what it means and how to use it. Clearly from my earlier comment, I at least had no idea…

  • @linpengcheng

    Awesome - thanks!

    Didn’t work exactly like I wanted - it would highlight the line above the heading so I did a slight modification:

                    id         ="Markdown"
                            <nameExpr expr="(?:[#]+\s+)(.*)"/>


  • @Michael-Vincent said:

    it would highlhght the line above


    But the original was intended to catch the daring-fireball-style header-above------or-====, which yours didn’t catch.

    I combined both philosophies:

    # H1
    ## H2
    ### H3
    ### H3.2
    ## H2.2
    # H1
    DaringFireballUnderline- Indicated Header Too
    DaringFireballUnderline= Indicated Header Too
    Not sure that mixed =-=- should be header
    Normal text
    # END

    This version catches either style, doesn’t require a space after the # for the header (I’ve seen some markdowns that don’t require that space); for the underline style, I made the executive decision that it only counts if it’s all-hyphen or all-equal, so mixed-hyphen-equal will not trigger the header recognition


    This could be endlessly tweaked for everyone’s markdown-interpreting preferences. :-)

  • Or try this one:

    			<!-- ======================================================== [ Markdown ] -->
    			|   Based on:
    			|       https://github.com/notepad-plus-plus/notepad-plus-plus/issues/5945
    				displayName="[TODO] Markdown"
    				id         ="markdown_header"
    				commentExpr="(?x)                                               # free-spacing (see `RegEx - Pattern Modifiers`)
    						(?ms:                                                   # Code block
    							^                                                   # ...at start-of-line a
    							(?'BLOCK'\x7E{3}(?!\x7E)|\x60{3}(?!\x60))           #    block-start indicator
    							\w*\h*$                                             #
    							.*?                                                 # ...whatever,
    							^\x20{0,3}                                          # ...optional indentation for a
    							\k'BLOCK'                                           #    block-end indicator
    							\h*$                                                #    with trailing white-space only
    					mainExpr="(?x)                                              # free-spacing (see `RegEx - Pattern Modifiers`)
    							(?m-s)                                              # ^ and $ match at line-breaks, dot does not
    							^                                                   # at start-of-line
    								\x20{0,3}(?!\x20)                               # indent of 3 spaces max, otherwise it's code
    							(?:                                                 # ATX-style heading
    								(?'LEVEL'\x23{1,6}(?!\x23))                     # nr. of hashes indicate level
    								\h+                                             # at least one white-space
    								\K                                              # discard text matched so far
    								|	\x5C.                                       # backslash escape sequence
    								(?:                                             # closing sequence
    									\h+                                         # ...starts w/ at least one white-space
    									\x23+                                       # ...contains only hashes, amount arbitrary
    								)?                                              # ...is optional
    								\h*$                                            # trailing white-space up till line-break
    							|                                                   # Setext-style heading
    								\K                                              # discard text matched so far
    								[^\r\n]+                                        # whatever,
    								(?=                                             # ...up till
    									\h*(?:\r?\n|\n?\r)                          # ...any trailing white-space and a line-break,
    									(?&amp;NOCODE_INDENT)                       # ...indent for header indicator
    									(?:={3,}|-{3,})                             # ...H1- or H2-header indicator resp.,
    									\h*$                                        # ...trailing white-space up till line-break
    						<nameExpr expr="(?x)
    								|	.*

  • @linpengcheng said in Display markdown outline view through Functionlist:


    This paragraph is used to write Marp-markdown-Slide, I use marp-cli to generate Slide.

    Marp home

    Marp github

  • @MAPJe71 The parser works nicely. However indentation is lost (Subtitles, Subsubtitles, … are listed at the same level). Is there somehow a way to replace the ‘#’ with a empty space or ‘_’ but only for the visualization in the function list?
    Best regards and thanks for contributing and sharing

  • @Ernesto-Saavedra said in Display markdown outline view through Functionlist:

    Is there somehow a way to replace

    Sorry, the functionList processing is a match-search, not a search-and-replace.

    You can make a single-level hierarchy by doing a “class” vs “function” in the definition, as described in the function list overview and function list config files documentation, or in @MAPJe71’s FAQ Desk: Function List Basics entry.

Log in to reply