@alauda/doom 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/index.js +1 -0
- package/lib/cli/load-config.js +15 -12
- package/lib/plugins/auto-sidebar/walk.d.ts +2 -2
- package/lib/plugins/auto-sidebar/walk.js +6 -23
- package/lib/plugins/index.d.ts +2 -1
- package/lib/plugins/index.js +2 -1
- package/lib/plugins/shiki/highlighter.d.ts +5 -0
- package/lib/plugins/shiki/highlighter.js +15 -0
- package/lib/plugins/shiki/index.d.ts +22 -0
- package/lib/plugins/shiki/index.js +56 -0
- package/lib/plugins/shiki/rehypePlugin.d.ts +9 -0
- package/lib/plugins/shiki/rehypePlugin.js +47 -0
- package/lib/plugins/shiki/transformers/callouts.d.ts +6 -0
- package/lib/plugins/shiki/transformers/callouts.js +10 -0
- package/lib/plugins/shiki/transformers/index.d.ts +2 -0
- package/lib/plugins/shiki/transformers/index.js +2 -0
- package/lib/plugins/shiki/transformers/line-number.d.ts +7 -0
- package/lib/plugins/shiki/transformers/line-number.js +13 -0
- package/package.json +8 -7
- package/styles/global.scss +2 -0
- package/styles/shiki.css +117 -0
package/lib/cli/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import path from 'node:path';
|
|
|
6
6
|
import { logger } from '@rsbuild/core';
|
|
7
7
|
import { build, dev, serve } from '@rspress/core';
|
|
8
8
|
import { watch } from 'chokidar';
|
|
9
|
+
// import type { EventName } from 'chokidar/handler.js'
|
|
9
10
|
import { program } from 'commander';
|
|
10
11
|
import { green } from 'yoctocolors';
|
|
11
12
|
import module from 'node:module';
|
package/lib/cli/load-config.js
CHANGED
|
@@ -3,15 +3,14 @@ import path from 'node:path';
|
|
|
3
3
|
import { nodeTypes } from '@mdx-js/mdx';
|
|
4
4
|
import { addLeadingSlash, addTrailingSlash, removeLeadingSlash, } from '@rspress/core';
|
|
5
5
|
import { pluginPreview } from '@rspress/plugin-preview';
|
|
6
|
-
import { createTransformerDiff, createTransformerErrorLevel, createTransformerFocus, createTransformerHighlight, pluginShiki, } from '@rspress/plugin-shiki';
|
|
7
6
|
import { logger } from '@rspress/shared/logger';
|
|
7
|
+
import { transformerMetaHighlight, transformerMetaWordHighlight, transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight, transformerRemoveNotationEscape, } from '@shikijs/transformers';
|
|
8
8
|
import getPort from 'get-port';
|
|
9
9
|
import rehypeRaw from 'rehype-raw';
|
|
10
10
|
import { parse } from 'yaml';
|
|
11
|
-
import { apiPlugin, autoSidebarPlugin, globalPlugin } from '../plugins/index.js';
|
|
11
|
+
import { apiPlugin, autoSidebarPlugin, createTransformerCallouts, globalPlugin, shikiPlugin, } from '../plugins/index.js';
|
|
12
12
|
import { pkgResolve } from '../utils/helpers.js';
|
|
13
13
|
import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, YAML_EXTENSIONS, } from './constants.js';
|
|
14
|
-
import { createTransformerCallouts } from './shiki/index.js';
|
|
15
14
|
const DEFAULT_LOGO = '/logo.svg';
|
|
16
15
|
const getCommonConfig = async (config) => {
|
|
17
16
|
return {
|
|
@@ -28,7 +27,6 @@ const getCommonConfig = async (config) => {
|
|
|
28
27
|
},
|
|
29
28
|
markdown: {
|
|
30
29
|
checkDeadLinks: true,
|
|
31
|
-
defaultWrapCode: true,
|
|
32
30
|
highlightLanguages: [['jsonc', 'json']],
|
|
33
31
|
mdxRs: false,
|
|
34
32
|
rehypePlugins: [[rehypeRaw, { passThrough: nodeTypes }]],
|
|
@@ -64,20 +62,25 @@ const getCommonConfig = async (config) => {
|
|
|
64
62
|
},
|
|
65
63
|
defaultRenderMode: 'pure',
|
|
66
64
|
}),
|
|
67
|
-
|
|
65
|
+
apiPlugin(),
|
|
66
|
+
autoSidebarPlugin(),
|
|
67
|
+
globalPlugin(),
|
|
68
|
+
shikiPlugin({
|
|
69
|
+
langs: ['dockerfile', 'go', 'jsonc'],
|
|
68
70
|
transformers: [
|
|
69
71
|
// builtin transformers
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
transformerMetaHighlight(),
|
|
73
|
+
transformerMetaWordHighlight(),
|
|
74
|
+
transformerNotationDiff(),
|
|
75
|
+
transformerNotationErrorLevel(),
|
|
76
|
+
transformerNotationFocus(),
|
|
77
|
+
transformerNotationHighlight(),
|
|
78
|
+
transformerNotationWordHighlight(),
|
|
79
|
+
transformerRemoveNotationEscape(),
|
|
74
80
|
// custom transformers
|
|
75
81
|
createTransformerCallouts(),
|
|
76
82
|
],
|
|
77
83
|
}),
|
|
78
|
-
autoSidebarPlugin(),
|
|
79
|
-
globalPlugin(),
|
|
80
|
-
apiPlugin(),
|
|
81
84
|
],
|
|
82
85
|
builderConfig: {
|
|
83
86
|
server: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type SidebarDivider, type SidebarGroup, type SidebarItem, type SidebarSectionHeader } from '@rspress/shared';
|
|
2
2
|
export interface DoomSidebarItem extends SidebarItem {
|
|
3
3
|
weight?: number;
|
|
4
4
|
}
|
|
@@ -12,7 +12,7 @@ export declare function scanSideMeta(workDir: string, rootDir: string, docsDir:
|
|
|
12
12
|
others: DoomSidebar[];
|
|
13
13
|
}>;
|
|
14
14
|
export declare function walk(workDir: string, routePrefix: string | undefined, docsDir: string, extensions: string[]): Promise<{
|
|
15
|
-
nav:
|
|
15
|
+
nav: never[];
|
|
16
16
|
sidebar: {
|
|
17
17
|
[x: string]: DoomSidebar[];
|
|
18
18
|
};
|
|
@@ -163,30 +163,13 @@ export async function scanSideMeta(workDir, rootDir, docsDir, routePrefix, exten
|
|
|
163
163
|
// Start walking from the doc directory, scan the `_meta.json` file in each subdirectory
|
|
164
164
|
// and generate the nav and sidebar config
|
|
165
165
|
export async function walk(workDir, routePrefix = '/', docsDir, extensions) {
|
|
166
|
-
// find the `_meta.json` file
|
|
167
|
-
const rootMetaFile = path.resolve(workDir, '_meta.json');
|
|
168
|
-
let navConfig;
|
|
169
|
-
// Get the nav config from the `_meta.json` file
|
|
170
|
-
try {
|
|
171
|
-
navConfig = (await fs.readJSON(rootMetaFile, 'utf8'));
|
|
172
|
-
}
|
|
173
|
-
catch {
|
|
174
|
-
navConfig = [];
|
|
175
|
-
}
|
|
176
|
-
navConfig.forEach((navItem) => {
|
|
177
|
-
if ('items' in navItem) {
|
|
178
|
-
navItem.items.forEach((item) => {
|
|
179
|
-
if ('link' in item && !isExternalUrl(item.link)) {
|
|
180
|
-
item.link = withBase(item.link, routePrefix);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
if ('link' in navItem && !isExternalUrl(navItem.link)) {
|
|
185
|
-
navItem.link = withBase(navItem.link, routePrefix);
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
166
|
const { index, others } = await scanSideMeta(workDir, workDir, docsDir, routePrefix, extensions, ['assets', 'public', 'shared']);
|
|
189
167
|
const sidebars = index ? [index, ...others] : others;
|
|
168
|
+
for (const sidebarItem of sidebars) {
|
|
169
|
+
if ('items' in sidebarItem && sidebarItem.items.length) {
|
|
170
|
+
sidebarItem.collapsed = false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
190
173
|
// Every sub dir will represent a group of sidebar
|
|
191
174
|
const sidebarConfig = {
|
|
192
175
|
[routePrefix]: sidebars,
|
|
@@ -195,7 +178,7 @@ export async function walk(workDir, routePrefix = '/', docsDir, extensions) {
|
|
|
195
178
|
sidebarConfig[removeTrailingSlash(routePrefix)] = sidebars;
|
|
196
179
|
}
|
|
197
180
|
return {
|
|
198
|
-
nav:
|
|
181
|
+
nav: [],
|
|
199
182
|
sidebar: sidebarConfig,
|
|
200
183
|
};
|
|
201
184
|
}
|
package/lib/plugins/index.d.ts
CHANGED
package/lib/plugins/index.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type BuiltinLanguage, type BuiltinTheme, type Highlighter, type BundledHighlighterOptions as ShikiHighlighterOptions, type ShikiTransformer } from 'shiki';
|
|
2
|
+
export interface HighlighterOptions extends ShikiHighlighterOptions<BuiltinLanguage, BuiltinTheme> {
|
|
3
|
+
transformers?: ShikiTransformer[];
|
|
4
|
+
}
|
|
5
|
+
export declare function getHighlighter(options: HighlighterOptions): Promise<Highlighter>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createHighlighter as createShikiHighlighter, } from 'shiki';
|
|
2
|
+
export async function getHighlighter(options) {
|
|
3
|
+
const highlighter = await createShikiHighlighter(options);
|
|
4
|
+
const baseTransformers = options.transformers ?? [];
|
|
5
|
+
return {
|
|
6
|
+
...highlighter,
|
|
7
|
+
codeToHtml: (code, htmlOptions) => {
|
|
8
|
+
const transformers = htmlOptions.transformers ?? [];
|
|
9
|
+
return highlighter.codeToHtml(code, {
|
|
10
|
+
...htmlOptions,
|
|
11
|
+
transformers: [...baseTransformers, ...transformers],
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RspressPlugin } from '@rspress/shared';
|
|
2
|
+
import { type BuiltinLanguage, type BuiltinTheme, type ShikiTransformer, type SpecialLanguage } from 'shiki';
|
|
3
|
+
export interface PluginShikiOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Code highlighting theme, @see https://shiki.style/themes
|
|
6
|
+
*/
|
|
7
|
+
theme?: BuiltinTheme | 'css-variables';
|
|
8
|
+
/**
|
|
9
|
+
* Code highlighting language, @see https://shiki.style/languages
|
|
10
|
+
*/
|
|
11
|
+
langs?: Array<BuiltinLanguage | SpecialLanguage>;
|
|
12
|
+
/**
|
|
13
|
+
* Custom shiki transformer, @see https://shiki.style/guide/transformers
|
|
14
|
+
*/
|
|
15
|
+
transformers?: ShikiTransformer[];
|
|
16
|
+
}
|
|
17
|
+
export declare const SHIKI_DEFAULT_HIGHLIGHT_LANGUAGES: BuiltinLanguage[];
|
|
18
|
+
/**
|
|
19
|
+
* The plugin is used to add the last updated time to the page.
|
|
20
|
+
*/
|
|
21
|
+
export declare function shikiPlugin({ theme, langs, transformers, }?: PluginShikiOptions): RspressPlugin;
|
|
22
|
+
export * from './transformers/index.js';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createCssVariablesTheme, } from 'shiki';
|
|
2
|
+
import { getHighlighter } from './highlighter.js';
|
|
3
|
+
import { rehypePluginShiki } from './rehypePlugin.js';
|
|
4
|
+
import { SHIKI_TRANSFORMER_LINE_NUMBER, createTransformerLineNumber, } from './transformers/line-number.js';
|
|
5
|
+
export const SHIKI_DEFAULT_HIGHLIGHT_LANGUAGES = [
|
|
6
|
+
'js',
|
|
7
|
+
'ts',
|
|
8
|
+
'jsx',
|
|
9
|
+
'tsx',
|
|
10
|
+
'json',
|
|
11
|
+
'css',
|
|
12
|
+
'scss',
|
|
13
|
+
'less',
|
|
14
|
+
'xml',
|
|
15
|
+
'diff',
|
|
16
|
+
'yaml',
|
|
17
|
+
'md',
|
|
18
|
+
'mdx',
|
|
19
|
+
'bash',
|
|
20
|
+
];
|
|
21
|
+
const cssVariablesTheme = createCssVariablesTheme({
|
|
22
|
+
name: 'css-variables',
|
|
23
|
+
variablePrefix: '--shiki-',
|
|
24
|
+
variableDefaults: {},
|
|
25
|
+
fontStyle: true,
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* The plugin is used to add the last updated time to the page.
|
|
29
|
+
*/
|
|
30
|
+
export function shikiPlugin({ theme = 'css-variables', langs = [], transformers = [], } = {}) {
|
|
31
|
+
return {
|
|
32
|
+
name: 'doom-shiki',
|
|
33
|
+
async config(config) {
|
|
34
|
+
config.markdown = config.markdown || {};
|
|
35
|
+
// Shiki will be integrated by rehype plugin, so we should use the javascript version markdown compiler.
|
|
36
|
+
config.markdown.mdxRs = false;
|
|
37
|
+
config.markdown.codeHighlighter = 'shiki';
|
|
38
|
+
config.markdown.rehypePlugins = config.markdown.rehypePlugins || [];
|
|
39
|
+
if (config.markdown.showLineNumbers &&
|
|
40
|
+
!transformers.some((transformerItem) => transformerItem.name === SHIKI_TRANSFORMER_LINE_NUMBER)) {
|
|
41
|
+
transformers.push(createTransformerLineNumber());
|
|
42
|
+
}
|
|
43
|
+
const highlighter = await getHighlighter({
|
|
44
|
+
themes: [cssVariablesTheme],
|
|
45
|
+
langs: [...SHIKI_DEFAULT_HIGHLIGHT_LANGUAGES, ...langs],
|
|
46
|
+
transformers,
|
|
47
|
+
});
|
|
48
|
+
config.markdown.rehypePlugins.push([
|
|
49
|
+
rehypePluginShiki,
|
|
50
|
+
{ highlighter, theme },
|
|
51
|
+
]);
|
|
52
|
+
return config;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export * from './transformers/index.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from 'unified';
|
|
2
|
+
import type { Root } from 'hast';
|
|
3
|
+
import type { BuiltinTheme, Highlighter } from 'shiki';
|
|
4
|
+
interface Options {
|
|
5
|
+
highlighter: Highlighter;
|
|
6
|
+
theme: BuiltinTheme;
|
|
7
|
+
}
|
|
8
|
+
export declare const rehypePluginShiki: Plugin<[Options], Root>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
import { fromHtml } from 'hast-util-from-html';
|
|
3
|
+
// TODO: migrate to official @shikijs/rehype plugin after upgrading unified/remark/rehype packages
|
|
4
|
+
export const rehypePluginShiki = ({ highlighter, theme }) => (tree) => {
|
|
5
|
+
visit(tree, 'element', (node, index, parent) => {
|
|
6
|
+
// <pre><code>...</code></pre>
|
|
7
|
+
if (node.tagName === 'pre' &&
|
|
8
|
+
node.children[0]?.type === 'element' &&
|
|
9
|
+
node.children[0].tagName === 'code') {
|
|
10
|
+
const codeNode = node.children[0];
|
|
11
|
+
const codeContent = codeNode.children[0].value;
|
|
12
|
+
const codeClassName = codeNode.properties?.className?.toString() || '';
|
|
13
|
+
const codeMeta = codeNode.properties?.meta?.toString() || '';
|
|
14
|
+
// for example: language-js {1,2,3-5}
|
|
15
|
+
const lang = codeClassName.split(' ')[0].split('-')[1];
|
|
16
|
+
if (!lang) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const highlightedCode = highlighter.codeToHtml(codeContent, {
|
|
20
|
+
lang,
|
|
21
|
+
theme,
|
|
22
|
+
meta: {
|
|
23
|
+
__raw: codeMeta,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const fragmentAst = fromHtml(highlightedCode, { fragment: true });
|
|
27
|
+
const preElement = fragmentAst.children[0];
|
|
28
|
+
const codeElement = preElement.children[0];
|
|
29
|
+
codeElement.properties.className = `language-${lang}`;
|
|
30
|
+
codeElement.properties.meta = codeMeta;
|
|
31
|
+
const codeLines = codeElement.children;
|
|
32
|
+
// Strip the final empty span
|
|
33
|
+
const lastLine = codeLines[codeLines.length - 1];
|
|
34
|
+
if (lastLine.children.length === 0) {
|
|
35
|
+
codeLines.pop();
|
|
36
|
+
}
|
|
37
|
+
parent?.children.splice(index, 1, {
|
|
38
|
+
type: 'element',
|
|
39
|
+
tagName: 'pre',
|
|
40
|
+
properties: {
|
|
41
|
+
className: 'code',
|
|
42
|
+
},
|
|
43
|
+
children: fragmentAst.children,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { transformerNotationMap } from '@shikijs/transformers';
|
|
2
|
+
export const createTransformerCallouts = (options = {}) => {
|
|
3
|
+
const { classActiveLine = 'callout', classActivePre = 'has-callouts' } = options;
|
|
4
|
+
return transformerNotationMap({
|
|
5
|
+
classMap: {
|
|
6
|
+
callout: classActiveLine,
|
|
7
|
+
},
|
|
8
|
+
classActivePre,
|
|
9
|
+
}, 'shiki-transformer:callouts');
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ShikiTransformer } from 'shiki';
|
|
2
|
+
export interface ITransformerLineNumberOptions {
|
|
3
|
+
classActivePre?: string;
|
|
4
|
+
classActiveLine?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const SHIKI_TRANSFORMER_LINE_NUMBER = "shiki-transformer:line-number";
|
|
7
|
+
export declare function createTransformerLineNumber(options?: ITransformerLineNumberOptions): ShikiTransformer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const SHIKI_TRANSFORMER_LINE_NUMBER = 'shiki-transformer:line-number';
|
|
2
|
+
export function createTransformerLineNumber(options = {}) {
|
|
3
|
+
const { classActiveLine = 'line-number', classActivePre = 'has-line-number', } = options;
|
|
4
|
+
return {
|
|
5
|
+
name: SHIKI_TRANSFORMER_LINE_NUMBER,
|
|
6
|
+
pre(pre) {
|
|
7
|
+
return this.addClassToHast(pre, classActivePre);
|
|
8
|
+
},
|
|
9
|
+
line(node) {
|
|
10
|
+
this.addClassToHast(node, classActiveLine);
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"fixture": "yarn doom fixture-docs",
|
|
32
32
|
"lint": "run-p 'lint:*'",
|
|
33
33
|
"lint:es": "eslint .",
|
|
34
|
-
"lint:tsc": "tsc -b
|
|
34
|
+
"lint:tsc": "tsc -b",
|
|
35
35
|
"prepare": "simple-git-hooks",
|
|
36
36
|
"prepublishOnly": "yarn build",
|
|
37
37
|
"swc-node": "node --enable-source-maps --import @swc-node/register/esm-register"
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
41
41
|
"@rspress/core": "^1.38.0",
|
|
42
42
|
"@rspress/plugin-preview": "^1.38.0",
|
|
43
|
-
"@
|
|
44
|
-
"chokidar": "^4.0.
|
|
43
|
+
"@shikijs/transformers": "^1.24.3",
|
|
44
|
+
"chokidar": "^4.0.3",
|
|
45
45
|
"clsx": "^2.1.1",
|
|
46
46
|
"commander": "^12.1.0",
|
|
47
47
|
"es-toolkit": "^1.30.1",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"react-markdown": "^8.0.7",
|
|
50
50
|
"rehype-raw": "^6.1.1",
|
|
51
51
|
"remark-gfm": "^3.0.1",
|
|
52
|
+
"shiki": "^1.24.3",
|
|
52
53
|
"swagger2openapi": "^7.0.8",
|
|
53
54
|
"tinyglobby": "^0.2.10",
|
|
54
55
|
"yaml": "^2.6.1",
|
|
@@ -60,17 +61,17 @@
|
|
|
60
61
|
"@swc/core": "1.10.1",
|
|
61
62
|
"@types/eslint__js": "^8.42.3",
|
|
62
63
|
"@types/fs-extra": "^11.0.4",
|
|
63
|
-
"@types/node": "
|
|
64
|
+
"@types/node": "^18.19.68",
|
|
64
65
|
"@types/swagger2openapi": "^7.0.4",
|
|
65
66
|
"eslint": "^9.17.0",
|
|
66
67
|
"lint-staged": "^15.2.11",
|
|
67
|
-
"npm-run-all2": "^7.0.
|
|
68
|
+
"npm-run-all2": "^7.0.2",
|
|
68
69
|
"openapi-types": "^12.1.3",
|
|
69
70
|
"prettier": "^3.4.2",
|
|
70
71
|
"prettier-plugin-pkg": "^0.18.1",
|
|
71
72
|
"simple-git-hooks": "^2.11.1",
|
|
72
73
|
"typescript": "^5.7.2",
|
|
73
|
-
"typescript-eslint": "^8.18.
|
|
74
|
+
"typescript-eslint": "^8.18.1"
|
|
74
75
|
},
|
|
75
76
|
"publishConfig": {
|
|
76
77
|
"access": "public"
|
package/styles/global.scss
CHANGED
package/styles/shiki.css
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom shiki code block theme
|
|
3
|
+
* reference: https://github.com/shikijs/shiki/blob/main/docs/themes.md
|
|
4
|
+
* -------------------------------------------------------------------------- */
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
--shiki-foreground: #414141;
|
|
8
|
+
--shiki-background: transparent;
|
|
9
|
+
--shiki-token-constant: #1976d2;
|
|
10
|
+
--shiki-token-string: #31a94d;
|
|
11
|
+
--shiki-token-comment: rgb(182, 180, 180);
|
|
12
|
+
--shiki-token-keyword: #cf2727;
|
|
13
|
+
--shiki-token-parameter: #f59403;
|
|
14
|
+
--shiki-token-function: #7041c8;
|
|
15
|
+
--shiki-token-string-expression: #218438;
|
|
16
|
+
--shiki-token-punctuation: #242323;
|
|
17
|
+
--shiki-token-link: #22863a;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.dark {
|
|
21
|
+
--shiki-foreground: #cac7c7;
|
|
22
|
+
--shiki-token-constant: #6fb0fa;
|
|
23
|
+
--shiki-token-string: #f9a86e;
|
|
24
|
+
--shiki-token-comment: #6a727b;
|
|
25
|
+
--shiki-token-keyword: #f47481;
|
|
26
|
+
--shiki-token-parameter: #ff9800;
|
|
27
|
+
--shiki-token-function: #ae8eeb;
|
|
28
|
+
--shiki-token-string-expression: #4fb74d;
|
|
29
|
+
--shiki-token-punctuation: #bbbbbb;
|
|
30
|
+
--shiki-token-link: #f9a76d;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.rspress-doc span.line {
|
|
34
|
+
padding: 0 1.25rem;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.diff,
|
|
38
|
+
.code-line-highlighted {
|
|
39
|
+
transition: background-color 0.5s;
|
|
40
|
+
padding: 0 20px;
|
|
41
|
+
width: 100%;
|
|
42
|
+
display: inline-block;
|
|
43
|
+
position: relative;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.diff.add::after {
|
|
47
|
+
content: '+';
|
|
48
|
+
position: absolute;
|
|
49
|
+
left: 10px;
|
|
50
|
+
color: #3dd68c;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.diff.remove::after {
|
|
54
|
+
content: '-';
|
|
55
|
+
position: absolute;
|
|
56
|
+
left: 10px;
|
|
57
|
+
color: #cb7676;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.has-diff div[class*='language-'] .diff.add {
|
|
61
|
+
background-color: rgba(16, 185, 129, 0.16);
|
|
62
|
+
border-left: 1px solid #10b981;
|
|
63
|
+
padding: 0 20px 0 19px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
div[class*='language-'] code .diff.remove {
|
|
67
|
+
background-color: rgba(244, 63, 94, 0.16);
|
|
68
|
+
border-left: 1px solid #f43f5e;
|
|
69
|
+
padding: 0 20px 0 19px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.has-highlight div[class*='language-'] .line.highlighted {
|
|
73
|
+
background-color: rgba(101, 117, 133, 0.16);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.has-highlight div[class*='language-'] .line.highlighted.error {
|
|
77
|
+
background-color: rgba(244, 63, 94, 0.16);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.has-highlight div[class*='language-'] .line.highlighted.warning {
|
|
81
|
+
background-color: rgba(234, 179, 8, 0.16);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.has-focused div[class*='language-'] .line:not(.focused) {
|
|
85
|
+
filter: blur(0.095rem);
|
|
86
|
+
opacity: 0.4;
|
|
87
|
+
transition: filter 0.35s, opacity 0.35s;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.has-focused:hover div[class*='language-'] .line:not(.focused) {
|
|
91
|
+
filter: blur(0);
|
|
92
|
+
opacity: 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.has-line-number code {
|
|
96
|
+
counter-reset: step;
|
|
97
|
+
counter-increment: step 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.has-line-number code .line-number::before {
|
|
101
|
+
content: counter(step);
|
|
102
|
+
counter-increment: step;
|
|
103
|
+
width: 15px;
|
|
104
|
+
margin-right: 15px;
|
|
105
|
+
display: inline-block;
|
|
106
|
+
text-align: right;
|
|
107
|
+
color: rgba(115, 138, 148, 0.4);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.line .highlighted-word {
|
|
111
|
+
background-color: var(--rp-c-text-code-bg);
|
|
112
|
+
border: 1px solid var(--rp-c-divider);
|
|
113
|
+
color: var(--rp-c-text-code);
|
|
114
|
+
padding: 1px 3px;
|
|
115
|
+
margin: -1px -3px;
|
|
116
|
+
border-radius: 4px;
|
|
117
|
+
}
|