@vuepress/plugin-shiki 2.0.0-rc.43 → 2.0.0-rc.45
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/client/styles/shiki.css +1 -18
- package/lib/client/styles/shiki.css.map +1 -0
- package/lib/node/options.d.ts +13 -2
- package/lib/node/prepareConfigFile.d.ts +1 -1
- package/lib/node/prepareConfigFile.js +20 -3
- package/lib/node/shikiPlugin.d.ts +1 -1
- package/lib/node/shikiPlugin.js +31 -19
- package/lib/node/transformers/getTransformers.js +1 -1
- package/package.json +6 -6
|
@@ -1,18 +1 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--code-c-text: #9e9e9e;
|
|
3
|
-
--code-c-highlight-bg: rgba(142 150 170 / 14%);
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.shiki span {
|
|
7
|
-
color: var(--shiki-light, inherit);
|
|
8
|
-
}
|
|
9
|
-
[data-theme=dark] .shiki span {
|
|
10
|
-
color: var(--shiki-dark, inherit);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
div[data-highlighter=shiki] {
|
|
14
|
-
background-color: var(--code-c-bg, var(--shiki-light-bg));
|
|
15
|
-
}
|
|
16
|
-
[data-theme=dark] div[data-highlighter=shiki] {
|
|
17
|
-
background-color: var(--code-c-bg, var(--shiki-dark-bg));
|
|
18
|
-
}
|
|
1
|
+
:root{--code-c-text: #9e9e9e;--code-c-highlight-bg: rgba(142 150 170 / 14%)}.shiki span{color:var(--shiki-light, inherit)}[data-theme=dark] .shiki span{color:var(--shiki-dark, inherit)}div[data-highlighter=shiki]{background-color:var(--code-c-bg, var(--shiki-light-bg))}[data-theme=dark] div[data-highlighter=shiki]{background-color:var(--code-c-bg, var(--shiki-dark-bg))}/*# sourceMappingURL=shiki.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../../../src/client/styles/shiki.scss"],"names":[],"mappings":"AAAA,MAEE,uBAGA,+CAGF,YACE,kCAEA,8BACE,iCAIJ,4BACE,yDAEA,8CACE","file":"shiki.css","sourcesContent":[":root {\n // base color\n --code-c-text: #9e9e9e;\n\n // highlight\n --code-c-highlight-bg: rgba(142 150 170 / 14%);\n}\n\n.shiki span {\n color: var(--shiki-light, inherit);\n\n [data-theme='dark'] & {\n color: var(--shiki-dark, inherit);\n }\n}\n\ndiv[data-highlighter='shiki'] {\n background-color: var(--code-c-bg, var(--shiki-light-bg));\n\n [data-theme='dark'] & {\n background-color: var(--code-c-bg, var(--shiki-dark-bg));\n }\n}\n"]}
|
package/lib/node/options.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MarkdownItCollapsedLinesOptions } from '@vuepress/highlighter-helper';
|
|
2
2
|
import type { PreWrapperOptions, ShikiHighlightOptions } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Options of @vuepress/plugin-shiki
|
|
5
5
|
*/
|
|
6
|
-
export type ShikiPluginOptions = Pick<
|
|
6
|
+
export type ShikiPluginOptions = Pick<MarkdownItCollapsedLinesOptions, 'collapsedLines'> & PreWrapperOptions & ShikiHighlightOptions & {
|
|
7
|
+
/**
|
|
8
|
+
* Line number options
|
|
9
|
+
*
|
|
10
|
+
* - A `boolean` value is to enable line numbers or not globally.
|
|
11
|
+
* - A `number` value is the minimum number of lines to enable line numbers
|
|
12
|
+
* - `disable` means completely disable the feature
|
|
13
|
+
*
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
lineNumbers?: boolean | number | 'disable';
|
|
17
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { App } from 'vuepress';
|
|
2
2
|
import type { ShikiPluginOptions } from './options.js';
|
|
3
|
-
export declare const prepareConfigFile: (app: App, { lineNumbers, notationDiff, notationErrorLevel, notationFocus, notationHighlight, notationWordHighlight, whitespace, }: ShikiPluginOptions) => Promise<string>;
|
|
3
|
+
export declare const prepareConfigFile: (app: App, { lineNumbers, highlightLines, collapsedLines, notationDiff, notationErrorLevel, notationFocus, notationHighlight, notationWordHighlight, whitespace, }: ShikiPluginOptions) => Promise<string>;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { getRealPath } from '@vuepress/helper';
|
|
2
2
|
import { PLUGIN_NAME } from './utils.js';
|
|
3
3
|
const { url } = import.meta;
|
|
4
|
-
export const prepareConfigFile = (app, { lineNumbers = true, notationDiff, notationErrorLevel, notationFocus, notationHighlight, notationWordHighlight, whitespace, }) => {
|
|
4
|
+
export const prepareConfigFile = (app, { lineNumbers = true, highlightLines = true, collapsedLines = 'disable', notationDiff, notationErrorLevel, notationFocus, notationHighlight, notationWordHighlight, whitespace, }) => {
|
|
5
5
|
const imports = [
|
|
6
6
|
`import "${getRealPath('@vuepress/highlighter-helper/styles/base.css', url)}"`,
|
|
7
7
|
`import "${getRealPath(`${PLUGIN_NAME}/styles/shiki.css`, import.meta.url)}"`,
|
|
8
8
|
];
|
|
9
|
-
|
|
9
|
+
const setups = [];
|
|
10
|
+
if (lineNumbers !== 'disable') {
|
|
10
11
|
imports.push(`import "${getRealPath('@vuepress/highlighter-helper/styles/line-numbers.css', url)}"`);
|
|
11
12
|
}
|
|
13
|
+
if (highlightLines || notationHighlight) {
|
|
14
|
+
imports.push(`import "${getRealPath('@vuepress/highlighter-helper/styles/notation-highlight.css', url)}"`);
|
|
15
|
+
}
|
|
12
16
|
if (notationDiff) {
|
|
13
17
|
imports.push(`import "${getRealPath('@vuepress/highlighter-helper/styles/notation-diff.css', url)}"`);
|
|
14
18
|
}
|
|
@@ -27,5 +31,18 @@ export const prepareConfigFile = (app, { lineNumbers = true, notationDiff, notat
|
|
|
27
31
|
if (whitespace) {
|
|
28
32
|
imports.push(`import "${getRealPath('@vuepress/highlighter-helper/styles/whitespace.css', url)}"`);
|
|
29
33
|
}
|
|
30
|
-
|
|
34
|
+
if (collapsedLines !== 'disable') {
|
|
35
|
+
imports.push(`import "${getRealPath('@vuepress/highlighter-helper/styles/collapsed-lines.css', url)}"`, `import { setupCollapsedLines } from "${getRealPath('@vuepress/highlighter-helper/composables/collapsedLines.js', url)}"`);
|
|
36
|
+
setups.push('setupCollapsedLines()');
|
|
37
|
+
}
|
|
38
|
+
let code = imports.join('\n');
|
|
39
|
+
if (setups.length) {
|
|
40
|
+
code += `\n
|
|
41
|
+
export default {
|
|
42
|
+
setup() {
|
|
43
|
+
${setups.join('\n ')}
|
|
44
|
+
}
|
|
45
|
+
}\n`;
|
|
46
|
+
}
|
|
47
|
+
return app.writeTemp('shiki/config.js', code);
|
|
31
48
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Plugin } from 'vuepress/core';
|
|
2
2
|
import type { ShikiPluginOptions } from './options.js';
|
|
3
|
-
export declare const shikiPlugin: (
|
|
3
|
+
export declare const shikiPlugin: (options?: ShikiPluginOptions) => Plugin;
|
package/lib/node/shikiPlugin.js
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
|
-
import { lineNumbers as lineNumbersPlugin } from '@vuepress/highlighter-helper';
|
|
1
|
+
import { collapsedLines as collapsedLinesPlugin, lineNumbers as lineNumbersPlugin, } from '@vuepress/highlighter-helper';
|
|
2
2
|
import { isPlainObject } from 'vuepress/shared';
|
|
3
3
|
import { applyHighlighter, highlightLinesPlugin, preWrapperPlugin, } from './markdown/index.js';
|
|
4
4
|
import { prepareConfigFile } from './prepareConfigFile.js';
|
|
5
|
-
export const shikiPlugin = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
md
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
5
|
+
export const shikiPlugin = (options = {}) => {
|
|
6
|
+
const opt = {
|
|
7
|
+
preWrapper: true,
|
|
8
|
+
lineNumbers: true,
|
|
9
|
+
collapsedLines: 'disable',
|
|
10
|
+
...options,
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
name: '@vuepress/plugin-shiki',
|
|
14
|
+
extendsMarkdown: async (md, app) => {
|
|
15
|
+
// FIXME: Remove in stable version
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
17
|
+
const { code } = app.options.markdown;
|
|
18
|
+
await applyHighlighter(md, app, {
|
|
19
|
+
...(isPlainObject(code) ? code : {}),
|
|
20
|
+
...options,
|
|
21
|
+
});
|
|
22
|
+
const { preWrapper, lineNumbers, collapsedLines } = opt;
|
|
23
|
+
md.use(highlightLinesPlugin);
|
|
24
|
+
md.use(preWrapperPlugin, { preWrapper });
|
|
25
|
+
if (preWrapper) {
|
|
26
|
+
if (lineNumbers !== 'disable')
|
|
27
|
+
md.use(lineNumbersPlugin, { lineNumbers });
|
|
28
|
+
if (collapsedLines !== 'disable')
|
|
29
|
+
md.use(collapsedLinesPlugin, { collapsedLines });
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
clientConfigFile: (app) => prepareConfigFile(app, opt),
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -27,7 +27,7 @@ export const getTransformers = (options) => {
|
|
|
27
27
|
};
|
|
28
28
|
export const whitespaceTransformer = (meta, defaultPosition = false) => {
|
|
29
29
|
const position = resolveWhitespacePosition(meta, defaultPosition);
|
|
30
|
-
//
|
|
30
|
+
// disable current code block
|
|
31
31
|
if (position === false)
|
|
32
32
|
return [];
|
|
33
33
|
return [transformerRenderWhitespace({ position })];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/plugin-shiki",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.45",
|
|
4
4
|
"description": "VuePress plugin - shiki",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-plugin",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"lib"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@shikijs/transformers": "^1.
|
|
36
|
-
"@vuepress/helper": "2.0.0-rc.
|
|
37
|
-
"@vuepress/highlighter-helper": "2.0.0-rc.
|
|
35
|
+
"@shikijs/transformers": "^1.18.0",
|
|
36
|
+
"@vuepress/helper": "2.0.0-rc.45",
|
|
37
|
+
"@vuepress/highlighter-helper": "2.0.0-rc.45",
|
|
38
38
|
"nanoid": "^5.0.7",
|
|
39
|
-
"shiki": "^1.
|
|
39
|
+
"shiki": "^1.18.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"vuepress": "2.0.0-rc.15"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "a59c8252483e4549f1d78e12d23e867651303e93"
|
|
48
48
|
}
|