docs: style code blocks accordingly

Entire-Checkpoint: 9214af96e44d
This commit is contained in:
Jan De Dobbeleer
2026-07-30 19:44:41 +02:00
committed by Jan De Dobbeleer
parent f6793cbedc
commit 55e97cc3b1
3 changed files with 11 additions and 213 deletions
+8 -1
View File
@@ -1,3 +1,5 @@
import {themes as prismThemes} from 'prism-react-renderer';
export default {
title: 'Oh My Posh',
tagline: 'The most customizable and fastest prompt engine for any shell.',
@@ -49,6 +51,12 @@ export default {
respectPrefersColorScheme: false,
},
prism: {
// Matches ConfigEditor's own DARK_CODE_THEME/LIGHT_CODE_THEME pair (see
// src/components/ConfigEditor/index.js) so every fenced code block in the docs follows
// the site's light/dark switch the same way the config editor does, instead of staying on
// one theme regardless of colour mode.
theme: prismThemes.github,
darkTheme: prismThemes.palenight,
additionalLanguages: ['powershell', 'lua', 'jsstacktrace', 'toml'],
},
docs: {
@@ -207,7 +215,6 @@ export default {
},
theme: {
customCss: [
'./src/css/prism-rose-pine-moon.css',
'./src/css/custom.css'
],
},
+3 -11
View File
@@ -8,17 +8,9 @@ import { CONFIG_FORMATS } from '../Studio/config';
import styles from './styles.module.css';
// The docs' own code fences (@theme/CodeBlock) run on prism-react-renderer too, through
// @docusaurus/theme-common's usePrismTheme() - which today resolves to the *same* palenight
// theme in light and dark mode alike, because docusaurus.config.js's themeConfig.prism never
// sets a `theme`/`darkTheme` pair (confirmed by inspecting a rendered docs code block: its
// computed background is #292d3e and its punctuation #c792ea, palenight's colors - not the
// #232136/#3e8fb0 that website/src/css/prism-rose-pine-moon.css would produce, which turns out
// to be dead CSS for these React-rendered blocks, overridden by prism-react-renderer's own
// inline per-token styling). Reusing palenight for dark mode keeps the editor pixel-identical to
// a real doc's code fence; github stands in as the light counterpart so the editor - unlike the
// docs' code blocks, which stay dark either way - actually adapts with the site's light/dark
// switch, which is the more useful behaviour for something people type into for minutes at a
// time rather than glance at.
// @docusaurus/theme-common's usePrismTheme() - which now resolves to this exact pair via
// docusaurus.config.js's themeConfig.prism.theme/darkTheme, so a doc's fenced code and the
// editor stay visually identical in both colour modes.
const DARK_CODE_THEME = themes.palenight;
const LIGHT_CODE_THEME = themes.github;
-201
View File
@@ -1,201 +0,0 @@
/**
* MIT License
* Rosé Pine Theme
* https://github.com/rose-pine
* Ported for PrismJS by fvrests [@fvrests]
*/
code[class*="language-"],
pre[class*="language-"] {
color: #e0def4;
background: #232136;
font-family: "Cartograph CF", ui-monospace, SFMono-Regular, Menlo, Monaco,
Consolas, "Liberation Mono", "Courier New", monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
@media print {
text-shadow: none;
}
}
/* Selection */
code[class*="language-"]::-moz-selection,
pre[class*="language-"]::-moz-selection,
code[class*="language-"] ::-moz-selection,
pre[class*="language-"] ::-moz-selection {
background: #44415a;
}
code[class*="language-"]::selection,
pre[class*="language-"]::selection,
code[class*="language-"] ::selection,
pre[class*="language-"] ::selection {
background: #44415a;
}
/* Code (block & inline) */
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
color: #e0def4;
background: #232136;
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: 0.5em 0;
overflow: auto;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: 0.1em;
border-radius: 0.3em;
white-space: normal;
color: #e0def4;
background: #232136;
}
/* Text style & opacity */
.token.entity {
cursor: help;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic,
.token.selector,
.token.doctype,
.token.attr-name,
.token.inserted,
.token.deleted,
.token.comment,
.token.prolog,
.token.cdata,
.token.constant,
.token.parameter,
.token.url {
font-style: italic;
}
.token.url {
text-decoration: underline;
}
.namespace {
opacity: 0.7;
}
/* Syntax highlighting */
.token.constant {
color: #e0def4;
}
.token.comment,
.token.prolog,
.token.cdata,
.token.punctuation {
color: #908caa;
}
.token.delimiter,
.token.important,
.token.atrule,
.token.operator,
.token.keyword {
color: #3e8fb0;
}
.token.tag,
.token.tag .punctuation,
.token.doctype,
.token.variable,
.token.regex,
.token.class-name,
.token.selector,
.token.inserted {
color: #9ccfd8;
}
.token.boolean,
.token.entity,
.token.number,
.token.symbol,
.token.function {
color: #ea9a97;
}
.token.string,
.token.char,
.token.property,
.token.attr-value,
.token.attr-value .punctuation {
color: #f6c177;
}
.token.parameter,
.token.url,
.token.name,
.token.attr-name,
.token.builtin {
color: #c4a7e7;
}
.token.deleted {
color: #eb6f92;
}
/* Insertions & deletions */
.token.inserted {
background: rgba(156 207 216 0.12);
}
.token.deleted {
background: rgba(235 111 146 0.12);
}
/* Line highlighting */
pre[data-line] {
position: relative;
}
pre[class*="language-"] > code[class*="language-"] {
position: relative;
z-index: 1;
}
.line-highlight,
.highlight-lines .highlighted {
position: absolute;
left: 0;
right: 0;
padding: inherit 0;
margin-top: 1em;
background: #44415a;
box-shadow: inset 5px 0 0 #e0def4;
z-index: 0;
pointer-events: none;
line-height: inherit;
white-space: pre;
}