Skip to content

Commit e6659dd

Browse files
docs: add possibility to color lines in docs code
1 parent 270986b commit e6659dd

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

docs/docusaurus.config.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,25 @@ const config: Config = {
110110
prism: {
111111
theme: prismThemes.github,
112112
darkTheme: prismThemes.dracula,
113-
additionalLanguages: ['bash'],
113+
additionalLanguages: ['bash', 'ruby', 'json', 'ejs', 'diff', 'markup-templating'],
114+
magicComments: [
115+
// Remember to extend the default highlight class name as well!
116+
{
117+
className: 'theme-code-block-highlighted-line',
118+
line: 'highlight-next-line',
119+
block: { start: 'highlight-start', end: 'highlight-end' },
120+
},
121+
{
122+
className: 'code-block-error-line',
123+
line: 'error-line',
124+
block: { start: 'error-line-start', end: 'error-line-end' },
125+
},
126+
{
127+
className: 'code-block-success-line',
128+
line: 'success-line',
129+
block: { start: 'success-line-start', end: 'success-line-end' },
130+
},
131+
],
114132
},
115133
} satisfies Preset.ThemeConfig,
116134
}

docs/src/css/custom.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,19 @@
3030
--ifm-background-color: #272934;
3131
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
3232
}
33+
34+
.code-block-error-line {
35+
background-color: #ff000020;
36+
display: block;
37+
margin: 0 calc(-1 * var(--ifm-pre-padding));
38+
padding: 0 var(--ifm-pre-padding);
39+
border-left: 3px solid #ff000080;
40+
}
41+
42+
.code-block-success-line {
43+
background-color: #00ff0020;
44+
display: block;
45+
margin: 0 calc(-1 * var(--ifm-pre-padding));
46+
padding: 0 var(--ifm-pre-padding);
47+
border-left: 3px solid #00ff0080;
48+
}

0 commit comments

Comments
 (0)