Community
    • Login

    How to add custom color to a tag in json language

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 380 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.
    • ziggi slawZ
      ziggi slaw
      last edited by

      Is it possible to add a custom tag and color to the default json language? For example, if the tag would be ‘MyCustomError’ it would be red, ‘MyCustomComment’ green and so on…

      I tried to add it to langs.model.xml and/or stylers.model.xml, but so far couldn’t figure it out yet.

      Thanks!

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

        @ziggi-slaw ,

        Sorry, builtin languages don’t work that way. The syntaxes that they highlight are compiled into the Notepad++ executable, and you cannot add an extra style to the list just by editing the config file, because the compiled code doesn’t know what to do with that extra data (and just ignores it).

        Your next choice is to use a User Defined Language (UDL), which would mean starting from scratch and not inheriting the existing highlighting from the builtin JSON lexer. You probably wouldn’t be able to replicate the existing behavior exactly, so that’s not likely what you want.

        Finally, you can add extra highlighting to a builtin lexer (like the JSON lexer) or to a User Defined Language (UDL) using regexes via the PythonScript plugin in conjunction with the script EnhanceAnyLexer.py that @Ekopalypse shares in his github repo – that script has the documentation of how to use it.

        ziggi slawZ 1 Reply Last reply Reply Quote 3
        • ziggi slawZ
          ziggi slaw @PeterJones
          last edited by

          @peterjones Thanks, I’ll check it out.

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