Syntax Highlighting for "JSON with Comments" a.k.a. jsonc
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 22.2k
- Forks
- 1.9k
- PR merge metrics
- PR metrics pending
Description
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
- Support for "JSON with Comments" in highlight.js: highlightjs/highlight.js/issues/2016
- this adds rendering of C-style comments to normal JSON
jsoncalias also available: highlightjs/highlight.js/issues/4018- seemingly not yet contained in a stable release
Notes
If #2313 is considered, Prism seems to also render comments in "normal" JSON, but there is no jsonc alias.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not name an mdBook file or test. Start by locating mdBook's syntax-highlighting integration and reviewing the linked highlight.js issues, then verify that a fenced jsonc block renders comments and JSON syntax as highlighted code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100