Community
    • 登入

    own language: handling for special characters

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    languageuser-defined lakeywords
    3 貼文 2 Posters 2.4k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Jan KischelJ
      Jan Kischel
      最後由 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 條回覆 最後回覆 回覆 引用 0
      • Jim DaileyJ
        Jim Dailey
        最後由 編輯

        @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 條回覆 最後回覆 回覆 引用 0
        • Jan KischelJ
          Jan Kischel
          最後由 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 條回覆 最後回覆 回覆 引用 0
          • 第一個貼文
            最後的貼文
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors