Sublime Forum

JSON Syntax Highlighting newlines as errors

#1

I know that it’s wrong to have a \n character inside a JSON value, but I really need to be able to “ignore” those kind of errors. I’ve just updated Sublime Text to 3.0 3143 and as soon as I opened a JSON file I noticed the new error highlighting for those cases. With my previous Sublime Text version I did not have any of that.

I tried installing SublimeLinter and the sublimelinter-json plugin, but I see no option to ignore that.

Can I disable the \n checking in JSON files somehow?

Thanks!

0 Likes

#2

Unfortunately not.

You’d have to copy the JSON syntax definition, name it something else, and remove the match for \n that sets the invalid.illegal scope name.

0 Likes

#3

You could also exclude invalid.illegal.unclosed-string.json from your color scheme’s invalid selector, but that will still leave the following lines in read since the tokenizer (correctly, imo) terminates the string context at this point.

I suggest making a custom syntax based on the default JSON one, as suggestes by wbond.

0 Likes

#4

I see. And where’s that syntax definition so as to create a new one? I’m kind of new to tinkering with sublime :stuck_out_tongue:

0 Likes

#5

also accessible via https://packagecontrol.io/packages/PackageResourceViewer

0 Likes

#6

Excellent, I see the line to remove would be:

  • match: $\n?
    scope: invalid.illegal.unclosed-string.json
    pop: true

Now, where do I do this? I’m on Ubuntu and installed this via the package manager.

Thanks.

0 Likes

#7

Create a copy of the file in your Packages/User/ dir and give a name like JSON (Custom).sublime-syntax.

0 Likes

#8

Thanks!! Solved!!

0 Likes