nushell / nushell/nushell.github.io
Color scheme toolbar button does not apply to code samples
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 258
- Fork
- 561
- Merge medio
- 3h 20m
- PR unite (30g)
- 15
Descrizione
There's a color scheme switcher button in the toolbar that I found, but it doesn't do anything to the code samples. I'll use custom CSS to work around it, so not urgent for my use.
Picture - the text in the black box is not legible for me due to black background:
User script to work around
// ==UserScript==
// @name Nushell.sh readable code blocks (LLM-generated)
// @namespace Violentmonkey Scripts
// @version 1.0.0
// @description Force Nushell docs code blocks to use black text on white background
// @match https://www.nushell.sh/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
const STYLE_ID = 'vm-nushell-readable-code-blocks';
function addStyle() {
if (document.getElementById(STYLE_ID)) return;
const style = document.createElement('style');
style.id = STYLE_ID;
style.textContent = `
/* Target Shiki blocks on nushell.sh */
div[data-highlighter="shiki"],
div[data-highlighter="shiki"] pre.shiki,
div[data-highlighter="shiki"] code,
div[data-highlighter="shiki"] span {
color: #000 !important;
background: #fff !important;
}
/* Override Shiki CSS variables used by theme switchers */
div[data-highlighter="shiki"] {
--shiki-light: #000 !important;
--shiki-dark: #000 !important;
--shiki-onedarkpro: #000 !important;
--shiki-light-bg: #fff !important;
--shiki-dark-bg: #fff !important;
--shiki-onedarkpro-bg: #fff !important;
}
div[data-highlighter="shiki"] pre.shiki {
border: 1px solid #ddd !important;
border-radius: 6px !important;
}
`;
document.head.appendChild(style);
}
function fixInlineStyles(root = document) {
const blocks = root.querySelectorAll('div[data-highlighter="shiki"]');
for (const block of blocks) {
block.style.setProperty('--shiki-light', '#000', 'important');
block.style.setProperty('--shiki-dark', '#000', 'important');
block.style.setProperty('--shiki-onedarkpro', '#000', 'important');
block.style.setProperty('--shiki-light-bg', '#fff', 'important');
block.style.setProperty('--shiki-dark-bg', '#fff', 'important');
block.style.setProperty('--shiki-onedarkpro-bg', '#fff', 'important');
const pre = block.querySelector('pre.shiki');
if (pre) {
pre.style.setProperty('color', '#000', 'important');
pre.style.setProperty('background', '#fff', 'important');
}
const nodes = block.querySelectorAll('code, span');
for (const node of nodes) {
node.style.setProperty('color', '#000', 'important');
node.style.setProperty('background', '#fff', 'important');
}
}
}
function init() {
addStyle();
fixInlineStyles();
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (node.nodeType === 1) {
fixInlineStyles(node);
}
}
}
});
observer.observe(document.documentElement, {
childList: true,
subtree: true,
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init, { once: true });
} else {
init();
}
})();
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Non sono indicati file di progetto né test. Inizia individuando il selettore dello schema di colori nella toolbar e i blocchi di codice Shiki identificati da data-highlighter="shiki"; traccia il modo in cui vengono applicate le relative variabili del tema. Il lavoro è completato quando il cambio di schema modifica il testo e gli sfondi degli esempi di codice in modo che rimangano leggibili, incluso il caso mostrato con sfondo scuro.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- css, typescript
- Ambito
- documentation, frontend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 58/100