Fixed by replacing the Prism.js default theme with an accessible variant of it (prism-accessible.css), see https://github.com/xwiki-contrib/prismjs/pull/2 (commit https://github.com/xwiki-contrib/prismjs/commit/9fdb3aa857f041caab5cdf752730f0956e087fa2). It keeps the hues of the default theme but darkens the token colors (and the line numbers) so that all highlighted text reaches at least 4.5:1 against the #f5f2f0 code background. PrismMacroIT now runs the axe-core color-contrast rule on the highlighted code and checks the line numbers contrast.
What we analyzed on the Prism.js side before deciding to ship our own theme:
Upgrading Prism.js: 1.30.0 (the version we use) is the latest stable release. 2.0.0-alpha.1 (Sept 2026) and the HEAD of the v2 branch on https://github.com/PrismJS/prism (Oct 2026) still have the same default theme colors; the only theme commits since 2025 are moves/renames/doc. v2 is also ESM-only, which doesn't fit our requirejs loading.
Prism.js themes: all 8 themes shipped with Prism.js (1.30.0 and v2) fail WCAG AA contrast. The default theme fails for 7 of its 9 token colors (down to 2.05:1 for regex/variable/important and 2.56:1 for punctuation and line numbers).
prism-themes (https://github.com/PrismJS/prism-themes, 1.9.0, last release in 2021, available as a WebJar): Coldark Cold is the only light theme passing for tokens (verified in the browser with our functional test), but its line numbers fail (4.46:1), it changes the look of the code boxes, and it would add a dependency on a dormant project while still requiring a CSS override. The passing themes (a11y-dark, Coldark Dark, Gruvbox Dark) are dark ones.
WCAG validation of the test framework (@UITest(wcag = true)): not usable to catch this, since color-contrast violations are only reported as warnings (still the case on xwiki-platform master), the validation can run before Prism's asynchronous highlighting, and it covers the whole page. Hence the direct axe-core call in the test.
Note: the new CSS is derived from the MIT-licensed Prism.js default theme and keeps its MIT notice next to the LGPL header.
This message was sent by Atlassian Jira (v9.3.0#930000-sha1:287aeb6)
If image attachments aren't displayed, see this article.