Docs: fix Shiki dark mode rendering#42591
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #42566
Description
In dark mode, structural tokens inside certain code blocks were rendered as near-black and therefore invisible against the dark background. This was specifically visible in the
<script type="importmap">example on the Install page, where the JSON structure characters ({,},:) would disappear.The site has two code rendering paths:
<Code>tab components — usehighlight.ts, which already passesdefaultColor: 'light-dark()'to Shiki.astro.config.ts, which was missingdefaultColor: 'light-dark()'.Without it, Shiki defaults to
defaultColor: 'light', generatingcolor: var(--shiki-light)for all uncolored/structural tokens. The Bootstrap VS Code light theme'seditor.foregroundis#0b0c0d(near-black), which is fine on a light background but invisible in dark mode.Explicitly colored tokens (strings, property names, tags) were unaffected because their spans carry both
--shiki-lightand--shiki-darkCSS variables. Only tokens falling back to the default foreground were broken.The fix is rather simple: add
defaultColor: 'light-dark()'to theshikiConfiginastro.config.ts, consistent withhighlight.ts.With this option, Shiki emits
color: light-dark(var(--shiki-light), var(--shiki-dark))for default-colored tokens. The CSSlight-dark()function reads thecolor-schemeproperty, which Bootstrap already sets todarkon[data-bs-theme="dark"], so the correct dark foreground (#f6f7f8) is applied automatically.New rendering:
Live previews