feat: add json5 to Prism additional languages - #1223
Conversation
A companion electron/electron docs PR retags bare object-literal code blocks from `js` to `json5`, since `js` does not play nicely with @electron/lint-roller. Register the `json5` Prism grammar so the site can highlight those blocks. `json5` extends `json`, which is already in the list ahead of it; the swizzled `prism-include-languages.js` requires each language in list order, so the dependency is satisfied. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBwKFgaRoEHjxoyGFpU6Ck
Deploying electron-website with
|
| Latest commit: |
1dbe2fd
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ba485f91.electron-website.pages.dev |
| Branch Preview URL: | https://feat-prism-json5-language.electron-website.pages.dev |
There was a problem hiding this comment.
Looks good, straightforward config change. Reviewed the single-line diff adding json5 to themeConfig.prism.additionalLanguages in docusaurus.config.ts — checked that it follows the existing array pattern (diff, json) and that the swizzled src/theme/prism-include-languages.js simply iterates the array to require each Prism component, so no other code changes are needed for this to work.
Extended reasoning...
Overview
The diff touches exactly one file, docusaurus.config.ts, and changes exactly one line: additionalLanguages: ['diff', 'json'] becomes ['diff', 'json', 'json5'] in the Prism theme configuration. This is a pure, additive configuration change with no logic changes elsewhere.
Security risks
None. This is a static array of language identifiers consumed by Prism's syntax highlighter at build/runtime for documentation code-block rendering. There is no user input, no auth/permissions path, and no data exposure surface touched.
Level of scrutiny
Low. This is a one-line, mechanical config addition following an existing, well-established pattern in the same array. I confirmed the consuming code (src/theme/prism-include-languages.js) iterates additionalLanguages and requires each prismjs/components/prism-<lang> module in order, so simply appending 'json5' is sufficient and consistent with how diff and json were already registered — no special wiring is required. I was unable to install node_modules in this sandbox to execute a live Prism tokenization check, but json5 is a standard, long-published Prism component that extends the json grammar, and the change is trivial enough that this doesn't warrant blocking approval.
Other factors
No CLAUDE.md applies to this path, no CODEOWNERS concerns were found, and the bug-hunting system reported zero findings. The PR author's description (build verification, lint passing) is consistent with the small, low-risk nature of the change itself.
Requested by David Sanders · Slack thread
Description of Change
Before: The site's Prism configuration only registers
diffandjsonas additional languages, so a code block tagged```json5falls back to plain, unhighlighted text.After:
json5is registered alongsidediffandjson, so```json5blocks are syntax-highlighted (comments, unquoted keys, hex numbers, trailing commas and the rest of the JSON5 grammar).A companion electron/electron PR retags roughly ten bare object-literal code blocks in the docs from
jstojson5, becausejsdoes not play nicely with @electron/lint-roller, and the website needs the grammar to highlight them.How: Appends
'json5'tothemeConfig.prism.additionalLanguagesindocusaurus.config.ts, keeping the list alphabetical. Prism'sjson5component extendsjson, and the swizzledsrc/theme/prism-include-languages.jsrequires each language in list order, so the existingjsonentry ahead of it satisfies the dependency; no other change was needed. Verified locally thatprism-react-renderer's Prism instance loads the grammar this way and tokenizes a JSON5 sample correctly, andyarn lint(tsc, oxfmt, oxlint, markdownlint) passes.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01NBwKFgaRoEHjxoyGFpU6Ck
Generated by Claude Code