Skip to content

feat: add json5 to Prism additional languages - #1223

Merged
erickzhao merged 1 commit into
mainfrom
feat/prism-json5-language
Sep 19, 2026
Merged

erickzhao merged 1 commit into
mainfrom
feat/prism-json5-language

Conversation

@claude

@claude claude Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Requested by David Sanders · Slack thread

Description of Change

Before: The site's Prism configuration only registers diff and json as additional languages, so a code block tagged ```json5 falls back to plain, unhighlighted text.

After: json5 is registered alongside diff and json, so ```json5 blocks 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 js to json5, because js does not play nicely with @electron/lint-roller, and the website needs the grammar to highlight them.

How: Appends 'json5' to themeConfig.prism.additionalLanguages in docusaurus.config.ts, keeping the list alphabetical. Prism's json5 component extends json, and the swizzled src/theme/prism-include-languages.js requires each language in list order, so the existing json entry ahead of it satisfies the dependency; no other change was needed. Verified locally that prism-react-renderer's Prism instance loads the grammar this way and tokenizes a JSON5 sample correctly, and yarn lint (tsc, oxfmt, oxlint, markdownlint) passes.

Checklist

🤖 Generated with Claude Code

https://claude.ai/code/session_01NBwKFgaRoEHjxoyGFpU6Ck


Generated by Claude Code

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
@claude
claude Bot requested a review from a team as a code owner September 19, 2026 00:18
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying electron-website with  Cloudflare Pages  Cloudflare Pages

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

View logs

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@erickzhao
erickzhao merged commit e96f4d0 into main Sep 19, 2026
9 checks passed
@erickzhao
erickzhao deleted the feat/prism-json5-language branch September 19, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants