New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lexer request: add jsonc lexer #1680
Comments
@kurtmckee Does this sound like something you could look at? |
Yep! I saw the request earlier this week and mulled over whether to make this part of the default JSON lexer or not. Haven't reached a conclusion yet, though; I need to review the JSONC spec a little more.
|
After review, it appears that every JSONC proposal (and there are multiple) is just an attempt to make a subset of Javascript into a superset of JSON. In other words, Pygments' Javascript lexer appears to be more than sufficient to parse JSON with comments added.
For this reason, I recommend closing this ticket and directing users to use the full Javascript lexer. |
Perfect, thanks for checking. I wasn't aware you handle comments already -- and yes, it totally makes sense to not cater for various JSONC flavors if all they add are comments. |
Does that work? { So javascript cannot work for json. |
@alainpannetier, you're correct that the object keys and string values are a single color in Javascript. This is because the Javascript lexer interprets anything in double quotes as a As I wrote above, every specification that introduces comments in JSON (and there are many!) just introduces features that are already handled by the Javascript parser. Whether it's called "JSONC", "JSON-C", or "JSON5", it appears that each specification introduces comments and other things that make them something more than JSON...but something less than Javascript, which already supports all of their proposed features.
My recommendation is to target an improvement to the Javascript parser. |
I've added comment support to JSON in #2049. It's not part of the JSON spec but adding it doesn't affect parsing of valid JSON documents. |
Add a JSONC lexer, a basic JSON with comments (
// inline
and/* block */
).The text was updated successfully, but these errors were encountered: