Skip to content
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

Syntax Highlighting for "JSON with Comments" a.k.a. jsonc #2360

Open
harmathy opened this issue Apr 10, 2024 · 1 comment
Open

Syntax Highlighting for "JSON with Comments" a.k.a. jsonc #2360

harmathy opened this issue Apr 10, 2024 · 1 comment
Labels
A-Highlighting Area: Code colored syntax highlighting C-enhancement Category: Enhancement or feature request

Comments

@harmathy
Copy link

Problem

In JSON there are no comments allowed. This is also honored by Github syntax
highlighting in fenced code blocks:

{
    // Note: there might be additional sizes available
    "sizes": [ "S", "M", "L", "XL", "XXL" ]
}

There is also "JSON with Comments" or jsonc (see Github language list)
which allows C-style comments

{
    // Note: there might be additional sizes available
    "sizes": [ "S", "M", "L", "XL", "XXL" ]
}

This is prominently used in tsconfig.json, jsconfig.json and
vscode configuration files.

It would be nice to have syntax highlighting support for such code blocks.

A code fence with jsonc should be highlighted:

```jsonc
{
    // Note: there might be additional sizes available
    "sizes": [ "S", "M", "L", "XL", "XXL" ]
}
```

Proposed Solution

Notes

If #2313 is considered, Prism seems to render also render comments in normal JSON, but there is no jsonc alias.

@harmathy harmathy added the C-enhancement Category: Enhancement or feature request label Apr 10, 2024
@ehuss ehuss added the A-Highlighting Area: Code colored syntax highlighting label Apr 12, 2024
@ehuss
Copy link
Contributor

ehuss commented Apr 12, 2024

As a workaround, I'd recommend using the javascript language tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Highlighting Area: Code colored syntax highlighting C-enhancement Category: Enhancement or feature request
Projects
None yet
Development

No branches or pull requests

2 participants