From 6d11b43d1714dcd3d31be334b1b336a9e3dd24ad Mon Sep 17 00:00:00 2001 From: "j.foucher" Date: Sun, 3 May 2026 10:25:37 +0200 Subject: [PATCH] Markdown : restyle inline `code` for the dark theme Markdig.Wpf's default inline-code style applies a light Background + "fancy" Foreground that becomes a near-illegible mustard-on-charcoal mess in our dark theme. Detect inline code by its FontFamily (Consolas / Courier / Typewriter, applied by Markdig's default style) and rebrand: Background = #1A1F2A (dark, blends with card) Foreground = #CDD6E4 (soft off-white, easy contrast) FontFamily = Cascadia Code, Consolas, monospace Affects both the UpdateAvailableDialog and the ReleaseNotesViewerDialog since they share BuildThemedDocument. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/PSLauncher.App/Views/MarkdownTheming.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/PSLauncher.App/Views/MarkdownTheming.cs b/src/PSLauncher.App/Views/MarkdownTheming.cs index 6b5e613..6ab09b8 100644 --- a/src/PSLauncher.App/Views/MarkdownTheming.cs +++ b/src/PSLauncher.App/Views/MarkdownTheming.cs @@ -102,6 +102,24 @@ internal static class MarkdownTheming foreach (var i in h.Inlines.ToList()) ApplyToInline(i, accent, fgSecondary, accent); break; + + case Run r: + // Markdig.Wpf rend `inline code` en tant que avec un Style + // par défaut qui pose un Background clair + Foreground "fancy" — illisible + // sur notre thème sombre. On détecte le code inline par sa FontFamily + // (monospace appliquée par le style Markdig) et on rebadge avec des couleurs + // qui matchent le reste de la UI : fond noir foncé + texte primaire. + var fontFamilyName = r.FontFamily?.Source ?? string.Empty; + if (fontFamilyName.Contains("Consolas", StringComparison.OrdinalIgnoreCase) + || fontFamilyName.Contains("Courier", StringComparison.OrdinalIgnoreCase) + || fontFamilyName.Contains("Typewriter", StringComparison.OrdinalIgnoreCase)) + { + r.Background = new SolidColorBrush(Color.FromRgb(0x1A, 0x1F, 0x2A)); + r.Foreground = new SolidColorBrush(Color.FromRgb(0xCD, 0xD6, 0xE4)); + r.FontFamily = new FontFamily("Cascadia Code, Consolas, monospace"); + } + break; + case Span s: foreach (var i in s.Inlines.ToList()) ApplyToInline(i, fg, fgSecondary, accent);