Skip to content

feat: support rootStyle: false option#1184

Merged
antfu merged 4 commits intoshikijs:mainfrom
khushthecoder:fix/issue-1175
Dec 3, 2025
Merged

feat: support rootStyle: false option#1184
antfu merged 4 commits intoshikijs:mainfrom
khushthecoder:fix/issue-1175

Conversation

@khushthecoder
Copy link
Copy Markdown
Contributor

Description

This PR fixes an issue where the rootStyle option was being ignored when using codeToHtml with a single theme (e.g. github-light).

Previously, codeToTokens returned rootStyle: undefined for single-theme usage, which unintentionally overwrote the rootStyle passed in options when calling tokensToHast inside codeToHast. This resulted in the default background color (often white for light themes) being forced, even when the user tried to disable it with rootStyle: false or rootStyle: ''.

The fix involves updating codeToHast to only use the rootStyle from codeToTokens if it is defined, otherwise falling back to options.rootStyle.

Linked Issues

Fixes #1175

Additional context

Verified using the reproduction script provided in the issue.

  • Before: style="background-color:#fff;color:#24292e" (forced background)
  • After: style="" (when rootStyle: '' is passed)

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 3, 2025

Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit 93d0cbf
🔍 Latest deploy log https://app.netlify.com/projects/shiki-next/deploys/692fc4b99014060008a13dde
😎 Deploy Preview https://deploy-preview-1184--shiki-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 3, 2025

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit 93d0cbf
🔍 Latest deploy log https://app.netlify.com/projects/shiki-matsu/deploys/692fc4b9e35d8a000817bd74
😎 Deploy Preview https://deploy-preview-1184--shiki-matsu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.08%. Comparing base (5ddea95) to head (93d0cbf).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1184   +/-   ##
=======================================
  Coverage   95.08%   95.08%           
=======================================
  Files          91       91           
  Lines        7866     7868    +2     
  Branches     1662     1666    +4     
=======================================
+ Hits         7479     7481    +2     
  Misses        381      381           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@antfu antfu changed the title fix: respect rootStyle option in codeToHtml with single theme feat: support rootStyle: false option Dec 3, 2025
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.

Light theme code blocks render with forced white background

2 participants