Community
    • Login

    JSON Styles Broken on v7.9.1

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 1.6k 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.
    • ClonkexC
      Clonkex
      last edited by Clonkex

      I just installed 7.9.1 (brand new install on a brand new installation of Windows 10) and found that the styles for JSON files are eye-searingly broken. Is this a known issue? Is there a fix?

      1f04bdf0-5137-442c-85de-8a488f8061b7-image.png

      PeterJonesP 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Clonkex
        last edited by

        @Clonkex,

        The JSON parser, inherited from the Scintilla library, despite claiming to support LINECOMMENT and BLOCKCOMMENT styles, interprets comments as errors, so applies the ERROR style to such text.

        Your choices are

        1. ask and wait for Scintilla to fix that bug, then ask and wait for Notepad++ to upgrade its internal Scintilla version.
        2. workaround: using the PythonScript plugin, you can add extra highlighting to a builtin lexer (like the JSON lexer) using regexes via the script EnhanceAnyLexer.py that @Ekopalypse shares in his github repo . So you could use a regex like //.*$ and apply some other style values.
        3. change the ERROR styling to be similar to the comment style – maybe use a slightly different color, so if the line really is an error, you will still see it.
        1 Reply Last reply Reply Quote 0
        • PeterJonesP
          PeterJones @Clonkex
          last edited by

          @Clonkex ,

          Actually, this sounded like a familiar question, so I searched for “JSON comment” in this forum, and found this earlier discussion.

          If you use PythonScript, you can use editor.setProperty("lexer.json.allow.comments",1) in your startup.py to always enable JSON comments, those comments will properly highlight:

          c12978b2-5102-48fe-8c7c-be7f84ceeceb-image.png becomes 8471ef8e-6ee8-44e6-96c4-95221b6a5281-image.png

          AFAIK, no one followed my advice of submitting a feature request to have Notepad++ provide that option. If you do put in that feature request (I even gave potential text for the request in that other topic), if you could link the issue you create both in this topic and that one, that way future readers can see how it progressed.

          1 Reply Last reply Reply Quote 1
          • Daniel FuchsD
            Daniel Fuchs
            last edited by

            Just to add to that, JSON by design does not have comments. It is a data only file type. Some if not most parsers error upon finding comments, so I guess Notepad++ is right here.

            See also https://stackoverflow.com/questions/244777/can-comments-be-used-in-json

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