Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    can i use function list in Notepad++ 7.9.5?

    Help wanted · · · – – – · · ·
    4
    10
    792
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bge low
      bge low last edited by bge low

      i want outliner for mark down file.
      i just want the header like vs code,not the markdown preview.
      markdown.JPG
      is it possible by extension?

      PeterJones 1 Reply Last reply Reply Quote 0
      • PeterJones
        PeterJones @bge low last edited by

        @bge-low ,

        Is it possible by extension?

        If by “extension” you meant “plugin” – that’s not necessary, at least for the first-level of what you requested; as shown below, it will work with builtin Notepad++ features.

        If by “extension”, you mean “file extension”, then yes; if your Markdown UDL defines the ext box as md markdown or similar, any files ending in .md or .markdown will have the Markdown UDL lexer applied automatically, and will also have the functionList feature applied if you’ve followed the steps described below. (Since there is a pre-installed Markdown UDL included with Notepad++, and it does define the extensions, then it will probably work by extension without extra effort beyond what’s described below.)

        Instructions

        Notepad++ has the built in Function List tool, which is meant for showing functions, classes, and the like. However, to some extent, it can be used to find the headers in markdown.

        To accomplish this, follow the instructions in the npp-user-manual.org Function List page as well as the Function List config files section

        1. Exit all instances of the Notepad++ application
        2. Edit %AppData%\Notepad++\functionList\overrideMap.xml .
          Just before the ending </associationMap>, add a line
          <association id= "markdown.xml" userDefinedLangName="Markdown (preinstalled)"/>
          
          If you have an unedited copy of overrideMap.xml, putting it in the group with the other example UDL is a good idea:
          692985a6-28e3-4b9f-9784-5444fc537991-image.png
          and Save overrideMap.xml
        3. Edit %AppData%\Notepad++\functionList\markdown.xml. Give it content like the following:
          <?xml version="1.0" encoding="UTF-8"?>
          <!-- ==========================================================================\
          |
          |   To learn how to make your own language parser, please check the following
          |   link:
          |       https://npp-user-manual.org/docs/function-list/
          |
          \=========================================================================== -->
          <NotepadPlus>
              <functionList>
                  <parser displayName="Markdown (preinstalled)"
                          id="Markdown (preinstalled)"
                          commentExpr="">
                      <function mainExpr="(?x-s)(^[#]+\s*(.*?)$|^(.*)(?=[\r\n]+^([-=])\4{2,}\s*$))"/>
                  </parser>
              </functionList>
          </NotepadPlus>
          
          The function expression will recognize markdown headers that are prefixed with one or more #, or headers that are indicated by a following line consisting of --- or ===. If you have other requirements, you can add them into the regular expression
          Save markdown.xml
        4. Exit Notepad++ and re-start the application (required to get it to re-read the config files)
        5. Now when you open a Markdown file in Notepad++, the View > Function List panel will show the outline, like in my screenshot below.

        16a8abf5-5b13-4cdf-a189-898dc7aa293a-image.png

        As you can see, it doesn’t make a multi-layer hierarchy, like you showed… but since it keeps the # prefixes, you can still see which level of hierarchy you are on. Using the “class” feature of the Function List syntax (see the FAQ, linked below), you could make it give one level of hierarchy, though it would require some additional development on your part to update the markdown.xml contents per the FAQ and npp-user-manual.org instructions. And personally, I don’t think a single layer or hierarchy is worth the effort for Markdown “functionList” features.

        References:

        • FAQ: Function List Basics
        • npp-user-manual.org section: Function List
        • npp-user-manual.org section: Config Files > Function List
        Alan Kilborn bge low 2 Replies Last reply Reply Quote 2
        • Alan Kilborn
          Alan Kilborn @PeterJones last edited by

          FYI, I followed Peter’s instructions and it worked perfectly.
          I was somewhat of a risk-taker and skipped step 1, with no problems. :-)

          1 Reply Last reply Reply Quote 0
          • Alan Kilborn
            Alan Kilborn last edited by

            @PeterJones

            I notice that the dynamic highlight color in the Function List of the function your caret is in in the editor window is rather subtle (using the default theme).
            In case it is unclear, I mean as you caret around in your main document area, the Function List shows you which “function” you are currently in.
            I don’t mean when you click on a function in the FL window – when I do that, the background highlight of the function clicked is suitably contrasting.

            For me the background coloring is much more subtle than your screenshot shows for ## Another Level 2.

            Is there a technique for making this more visible (i.e., making the background color of that function name darker)?

            This feels like it might have been something discussed before?

            1 Reply Last reply Reply Quote 1
            • guy038
              guy038 last edited by guy038

              Hello @bge-low, @peterjones, @alan-kilborn and All,

              After some tests on our NodeBB forum and some searches on legal Markdown syntax, I think that we should change the present syntax :

                          <function mainExpr="(?x-s)(^[#]+\s*(.*?)$|^(.*)(?=[\r\n]+^([-=])\4{2,}\s*$))"/>
              

              into this new one :

              
                          <function mainExpr="(?-s)^#{1,6}(?:(?=[\t\x20]*$)|[\t\x20]+\K.+)|^.+(?=\R\x20{0,3}[-=]+[\t\x20]*$)"/>
              

              You may test it against this text, using the Markdown (preinstalled) language :

              Line 1
              Line 2
              ###### HEADER Text of level 6
              Line 3
              Line 4
              Line 5 is a HEADER line
              =======	        	
              Line 6
              Line 7 is ALSO a HEADER line
                 -
              Line 8
              Line 9
              
              # Level 1 HEADER Text
              Line 10 : the NEXT line is an EMPTY HEADER text
              ###
              Line 11
              Line 12
              

              With the free-spacing mode, this regex can be re-expressed as below :

              (?x-s)                 #  FREE-SPACING mode and any DOT matches a SINGLE STANDARD char ONLY
                ^ \# {1,6}           #     From 1 to SIX '#' characters ...
                (?:                  #     START of a NON capturing group 1 
                  (?= [\t\x20]* $ )  #       IF followed with POSSIBLE TAB or SPACE character(s) till the END of CURRENT line
                |                    #     OR
                  [\t\x20]+          #       followed with, at least, one TAB or SPACE character
                  \K .+              #       and, AFTER a RESET, followed with the REMAINDER or CURRENT line
                )                    #     END of the NON-CAPTURING group 1
              |                      #   OR
                ^.+                  #     CURRENT line contents ...
                (?=                  #     Start of a POSITIVE look-ahead
                  \R\x20{0,3}        #       IF followed with A LINE-BREAK, and from ZERO to THREE SPACE character(s)
                  [-=]+              #       followed with, at least, ONE DASH or EQUAL sign
                  [\t\x20]*$         #       Followed with POSSIBLE TAB or SPACE character(s) till the END of CURRENT line
                )                    #     END of the POSITIVE look-ahead
              

              Best Regards,

              guy038

              1 Reply Last reply Reply Quote 1
              • bge low
                bge low @PeterJones last edited by

                @PeterJones
                thanks peter.your tutorial worked perfectly.

                but i still have other question.
                can the function list be “fold” like vs code?
                header1 locate in top,header2 and header3 locate in under of header1.

                Alan Kilborn 1 Reply Last reply Reply Quote 0
                • Alan Kilborn
                  Alan Kilborn @bge low last edited by

                  @bge-low said in can i use function list in Notepad++ 7.9.5?:

                  but i still have other question.
                  can the function list be “fold” like vs code?

                  I think Peter answered this one:

                  As you can see, it doesn’t make a multi-layer hierarchy

                  So the very short answer is No.

                  1 Reply Last reply Reply Quote 1
                  • bge low
                    bge low last edited by

                    thanks for comment.do i have to develop for folding function?
                    that looks like very hard.

                    Alan Kilborn 1 Reply Last reply Reply Quote 0
                    • Alan Kilborn
                      Alan Kilborn @bge low last edited by

                      @bge-low said in can i use function list in Notepad++ 7.9.5?:

                      do i have to develop for folding function?

                      If you want that feature, I’d say Yes.
                      Otherwise you can make a FEATURE REQUEST for the N++ developers, but that offers no guarantee of implementation.

                      bge low 1 Reply Last reply Reply Quote 2
                      • bge low
                        bge low @Alan Kilborn last edited by

                        thanks for comment.
                        i may have to make plugin.
                        https://npp-user-manual.org/docs/plugins/

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Copyright © 2014 NodeBB Forums | Contributors