mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 14:29:48 +08:00
fix(web): ensure readable text in dark code blocks on light theme
The hard-coded dark code block background (#1f2937 / #292524) combined with `.prose` rules was producing near-black text in the light theme: `.prose pre` forced color #D6D3D1 and `.prose code:not(.md-code-block__code):not(.md-inline-code)` pulled the code element back to var(--foreground), overriding the Tailwind classes on the fallback <pre>/<code>. Add a higher-specificity rule on .md-renderer .md-code-block {,pre,code} that pins the text color to #e5e7eb regardless of theme, and tag the <code> elements in the Rich/Simple markdown fallbacks with the existing md-code-block__code class so the :not() guard kicks in and inheritance resolves to the light color.
This commit is contained in:
@@ -226,6 +226,17 @@
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
/* Force light text on dark code blocks regardless of theme. The wrapper
|
||||
.md-code-block always uses a fixed dark background (#1f2937 / #292524),
|
||||
so we need to override .prose pre (color: #D6D3D1) and any inherited
|
||||
--foreground from the prose wrapper that would otherwise render as
|
||||
near-black in the light theme. Specificity (0,2,1) beats .prose pre. */
|
||||
.md-renderer .md-code-block,
|
||||
.md-renderer .md-code-block pre,
|
||||
.md-renderer .md-code-block code {
|
||||
color: #e5e7eb;
|
||||
}
|
||||
|
||||
.md-renderer .md-code-block pre,
|
||||
.md-renderer .md-code-block code {
|
||||
background: transparent !important;
|
||||
|
||||
@@ -400,7 +400,7 @@ export default function RichMarkdownRenderer({
|
||||
{...lineProps}
|
||||
>
|
||||
<pre className="overflow-x-auto p-4 text-sm leading-relaxed text-[#e5e7eb]">
|
||||
<code {...props}>{raw}</code>
|
||||
<code className="md-code-block__code" {...props}>{raw}</code>
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -262,7 +262,7 @@ export default function SimpleMarkdownRenderer({
|
||||
className={`md-code-block ${gap} overflow-hidden rounded-xl border border-[var(--border)] bg-[#292524]`}
|
||||
>
|
||||
<pre className="overflow-x-auto p-4 text-sm leading-relaxed text-[#D6D3D1]">
|
||||
<code {...props}>{raw}</code>
|
||||
<code className="md-code-block__code" {...props}>{raw}</code>
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user