fix(themes): swap Prism syntax-highlighting theme on light/dark switch
The Prism CSS was hardcoded to prism-tomorrow (dark-only), so code blocks stayed dark even when switching to Light or other non-dark themes. - Add id='prism-theme' to the <link> element for runtime lookup - In _applyTheme(), swap href between prism-tomorrow (dark) and prism (light) based on resolved theme - Skips DOM write when the target href is already active Fixes #505
This commit is contained in:
committed by
Hermes Agent
parent
e4688425ab
commit
50d7d1cf88
@@ -584,6 +584,16 @@ function _applyTheme(name){
|
||||
?(window.matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light')
|
||||
:name;
|
||||
document.documentElement.dataset.theme=resolved||'dark';
|
||||
// Swap Prism syntax-highlighting theme to match UI theme
|
||||
(function(){
|
||||
const link=document.getElementById('prism-theme');
|
||||
if(!link) return;
|
||||
const isDark=(resolved!=='light');
|
||||
const want=isDark
|
||||
?'https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-tomorrow.min.css'
|
||||
:'https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism.min.css';
|
||||
if(link.href!==want){ link.href=want; }
|
||||
})();
|
||||
// Re-register OS change listener whenever system theme is active
|
||||
if(name==='system'){
|
||||
const mq=window.matchMedia('(prefers-color-scheme:dark)');
|
||||
|
||||
Reference in New Issue
Block a user