Community
    • Login

    own language: handling for special characters

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    languageuser-defined lakeywords
    3 Posts 2 Posters 2.3k 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.
    • Jan KischelJ
      Jan Kischel
      last edited by Jan Kischel

      I’ making an own language highlighter for a special log file and have the problem that the trigger words contain special characters that NPP simply ignores.

      Example log text:

      2017-12-34 [1] INFO starting 'foo!bar', version 1.2.3.4
      ...
      2017-12-34 [1] INFO closing foo!bar (exiting main thread)
      

      Now, I put the trigger

      "] INFO starting 'foo!bar', version"
      

      as start in text block, here: text block code 2, and also

      "] INFO closing foo!bar"
      

      in the end box in text block code 2.

      Also, key words are ignored if they doesn’t stand alone (foo bar works, [foo bar] not.).
      Well, doesn’t work. Also, escaping the characters -, /, ", ', … with a leading backslash doesn’t work.

      Now, what is the exact syntax for escaping special characters?

      And also: How can I add two empty lines as trigger for ending a folded block?

      1 Reply Last reply Reply Quote 0
      • Jim DaileyJ
        Jim Dailey
        last edited by

        @Jan-Kischel
        Sorry, I don’t quite understand what you are trying to do. I assume you are using the UDL feature.

        If you want a keyword to show up when it is adjacent to certain special characters like “[”, “]”, “{”, and “}”, you can try adding those characters to the Operators group.

        1 Reply Last reply Reply Quote 0
        • Jan KischelJ
          Jan Kischel
          last edited by Jan Kischel

          Sorry, I don’t quite understand what you are trying to do.

          Basically, I try to make a special kind of log file more readable using the user defined language feature.

          I want to utilize the folding feature as my log file contains some sessions I want to ‘group’. It the same as an

          if { 
            code here
          } 
          

          block in JavaScript.

          Now, imagine “starting ‘foo!bar’, version” instead of “if” as starting mark. I added

          ! ’ " * # \ / _ - + : ;
          into my operators, but doesn’t work.

          Or, to be more clear:
          I want NPP to and handle every line as a stupid raw string, no matter what characters are in it.
          (alternatively, a nice regex would be welcome, but NPP doesn’t support regex in keywords, I guess due to performance.)

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