Community
    • Login

    Add Parse Rules to Language None (Normal Text)?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 825 Views
    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.
    • Robin Andrews 0R
      Robin Andrews 0
      last edited by Robin Andrews 0

      I have spent a long time trying to get markdown to generate a function list so I can navigate easily. It’s been a right headache and I did not succeed. I tried creating a UDL, which I didn’t want to do as I then had to manually define the colours to match my theme etc, and I write markdown as plaintext and want no highlighting. I persisted though as it looked like there was no other way, but I couldn’t get overrideMap.xml to be read for the UDL…

      As a workaround I tried using JSON as my language (no formatting, just like I want) and it worked, but unfortunately my spell checker doesn’t work with JSON.

      Ideally I just want to keep things simple and add this parse rule:

      		 <parser
                      displayName="Markdown"
                      id         ="Markdown"
                      commentExpr=""
                  >
                      <function
                          mainExpr="(?x)((?:^|\n)[#]+\s+(.*?)(\r*|\n*)$)">
                          <functionName>
                              <nameExpr expr="(?:[#]+\s+)(.*)"/>
                          </functionName>
                      </function>
                  </parser>
      

      To the default language (None, Normal Text). Is this possible please? Or is there some simple way to make markdown work with a function list for headings and zero formatting, just like plain text?

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by

        @Robin-Andrews-0 said in Add Parse Rules to Language None (Normal Text)?:

        I have spent a long time trying to get markdown to generate a function list so I can navigate easily.

        Getting the regex right for functionList parsing can be tricky. It’s easier when you’ve just got a function, rather than also having a class… but things that you really think should work don’t always work in practice, and it’s really hard to debug.

        It’s been a right headache and I did not succeed.
        I tried creating a UDL, which I didn’t want to do as I then had to manually define the colours to match my theme etc, and I write markdown as plaintext and want no highlighting.

        You can define a UDL that has nothing more than a name, and no other formatting. Well, I guess, as you said, if you are not using the default theme then you’ll have to define the Default style for that UDL to match your theme’s default standard text style; and maybe the number formatting, too. But that’s only a few clicks to get it all set up. And you don’t have to add any keywords or similar

        I persisted though as it looked like there was no other way, but I couldn’t get overrideMap.xml to be read for the UDL…

        I don’t understand why users have so much trouble with this aspect. This has worked the first try, every time for me.

        To the default language (None, Normal Text). Is this possible please? Or is there some simple way to make markdown work with a function list for headings and zero formatting, just like plain text?

        You cannot associate a functionList parser with Normal Text.

        I just unzipped a fresh v8.0-64bit portable to experiment with your situation. But these instructions should work with v7.9.1 and newer.

        • Set theme to “Solarized-light”, which has FG=(101,123,131) BG=(253,246,227)
        • Saved a text file called 21302.ra which contains the text
          # one
          
          This is a test
          
          ## two
          
          123456789
          
          ### three
          
          blah
          
          
        • Language > Define Your Language > Define Your Language
          • Folder & Default > Default Style > Styler = FG and BG as with “Solarized-light”
          • Comment & Number > Number Style > Styler = FG and BG as above
          • SaveAs = Markdown
          • Ext. = ra
          • Close UDL editor
        • In 21302.ra, select Language > Markdown: the text file I showed matches the FG and BG of the selected theme
        • Open your overrideMap.xml and in the User Defined Languages section, add
          <association id= "markdown.xml"			userDefinedLangName="Markdown"/>
          
          and save
        • Create markdown.xml in the same directory as overrideMap.xml, where the <parser...>...</parser> you showed goes inside the <NotepadPlus><functionList>...</functionList></NotepadPlus> container. Save.
        • Exit Notepad++ application
        • Start Notepad++ application, open 21302.ra.
        • Display Function List panel

        f2d8ea8d-9212-4459-82b9-5b66912c8106-image.png

        1 Reply Last reply Reply Quote 1
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors