fix: unreadable text in markdown code blocks (light mode)#234
Conversation
highlight.js's markdown grammar tokenizes underscores, asterisks, and backticks as emphasis/strong/code spans. The github-dark theme assigns these tokens colors (#c9d1d9, #8b949e) that are nearly invisible against light backgrounds, making large sections of markdown code blocks appear "washed out." The existing light-mode overrides in index.css cover keywords, strings, comments, and numbers — but not .hljs-emphasis, .hljs-strong, or .hljs-code. This patch forces those three token types to inherit the base code color, which is already correctly overridden for light mode. Tokens fixed: - .hljs-emphasis: underscores in variable names (e.g. data_quality_good) were parsed as italic emphasis — now inherits color, removes italic - .hljs-strong: **bold** markers used #c9d1d9 — now inherits color - .hljs-code: `backtick` inline code markers used #8b949e — now inherits Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adjusts highlight.js token styling so markdown code blocks remain readable in light mode when the github-dark theme is used.
Changes:
- Add overrides for
.hljs-emphasis,.hljs-strong, and.hljs-codeinsidepre code.hljsto inherit the base code color (and disable italics for emphasis).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /* Fix: hljs markdown grammar applies github-dark token colors that are unreadable | ||
| in light mode. Emphasis/strong/code tokens use #c9d1d9 or #8b949e which wash out | ||
| against light backgrounds. Force them to inherit the base code color. */ | ||
| pre code.hljs .hljs-emphasis { | ||
| color: inherit !important; | ||
| font-style: normal !important; | ||
| } | ||
| pre code.hljs .hljs-strong { | ||
| color: inherit !important; | ||
| } | ||
| pre code.hljs .hljs-code { | ||
| color: inherit !important; | ||
| } |
There was a problem hiding this comment.
These overrides are not scoped to light mode (no .light prefix), so they will also apply in dark mode and globally remove .hljs-emphasis italics via font-style: normal !important. This conflicts with the stated scope (“light mode”, “dark mode unaffected”) and may affect any highlighted language that emits .hljs-emphasis/.hljs-strong/.hljs-code tokens. Consider scoping the selectors to light mode (and optionally to markdown only, e.g. code.hljs.language-markdown / language-md) so the fix is limited to the intended case.
There was a problem hiding this comment.
I think the dark/light mode is a bit of red herring. I built this with claude (naturally) and was using light mode at the time. I tested with both light and dark and it worked fine. I uploaded a test file to the branch that you can see as well: test-markdown-highlighting.md.
Contains a ```markdown code block with underscores in variable names, **bold** markers, and `backtick` code — all patterns that trigger the washed-out text rendering this PR fixes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Problem
Text in
```markdown ```code blocks appears "washed out" in light mode. Large sections become nearly invisible — italic, faded, and hard to read.Root cause: highlight.js's markdown grammar tokenizes underscores, asterisks, and backticks as formatting spans (
.hljs-emphasis,.hljs-strong,.hljs-code). The github-dark theme assigns these tokens colors designed for dark backgrounds:.hljs-emphasis#c9d1d9+ italicdata_quality_goodget parsed as emphasis, wrapping entire paragraphs.hljs-strong#c9d1d9+ bold**QUANT.**etc.).hljs-code#8b949e`backtick`inline code markersThe existing light-mode overrides in
index.csscorrectly handle keywords, strings, comments, and numbers — but these three tokens were missed.Fix
Added CSS overrides (14 lines in
packages/editor/index.css) that force the three affected tokens to inherit the base code color, which is already correctly set for light mode by.light pre code.hljs:!importantis needed because Tailwind v4's CSS cascade layers give the unlayered github-dark theme higher priority than the layered user styles.hljs-emphasisalso removesfont-style: italicsince underscores in variable names are not actual emphasis.hljs-strongkeepsfont-weight: 700(only color is overridden).light .hljs-keyword,.light .hljs-string, etc.Scope
packages/editor/index.cssinheritresolves to the same#c9d1d9base color)Testing
Tested locally by loading a markdown file containing dense variable names with underscores, bold markers, and backtick code spans in a
```markdown ```code block. Verified in Chrome DevTools thatgetComputedStylereturns inherited colors andfont-style: normalfor affected elements.Before:
Text between underscores rendered as faded italic,
**bold**markers nearly invisible, backtick code gray on light background.After:
All code block text renders at uniform readable weight and color in both light and dark modes.