[fix] Made dark syntax highlighting follow the theme toggle#285
Conversation
📝 WalkthroughWalkthroughThe Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@conf.py`:
- Around line 527-533: The code on line 527 calls pygments_css.read_text()
without first checking if the file exists, which will raise FileNotFoundError if
Sphinx hasn't generated _static/pygments.css. Add an existence guard before
attempting to read the pygments_css file, using the early return pattern already
established in lines 519-523 to skip this block if the file is not found.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 840f86cd-3fcc-4ed0-a0b5-e4a87500e98d
📒 Files selected for processing (1)
conf.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{py,html}
📄 CodeRabbit inference engine (Custom checks)
For Django pull requests: ensure all user-facing strings are marked as translatable using the Django i18n framework
Files:
conf.py
🔇 Additional comments (1)
conf.py (1)
511-517: LGTM!
850d9d7 to
c744820
Compare
Sphinx 9 and sphinxawesome-theme 6 gate the dark Pygments palette on `@media (prefers-color-scheme: dark)`, both in the block appended to pygments.css and in the separately media-linked pygments_dark.css. The theme, however, toggles dark mode with a `.dark` class on <html> that is persisted in localStorage and can diverge from the OS preference (for example the site is kept dark while the OS turns light at dawn). The code blocks therefore switched palette independently of the rest of the page, producing low-contrast, unreadable syntax highlighting. Re-scope the dark palette under `.dark` so the syntax colors track the same toggle as the rest of the theme.
c744820 to
2befc94
Compare
Sphinx 9 and sphinxawesome-theme 6 gate the dark Pygments palette on
@media (prefers-color-scheme: dark), both in the block appended to pygments.css and in the separately media-linked pygments_dark.css.The theme, however, toggles dark mode with a
.darkclass on that is persisted in localStorage and can diverge from the OS preference (for example the site is kept dark while the OS turns light at dawn). The code blocks therefore switched palette independently of the rest of the page, producing low-contrast, unreadable syntax highlighting.Re-scope the dark palette under
.darkso the syntax colors track the same toggle as the rest of the theme.