@shikijs/cli 3.19.0 → 3.21.0
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/dist/cli.mjs +11 -3
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import '@shikijs/vscode-textmate';
|
|
|
7
7
|
import 'ansis';
|
|
8
8
|
import 'shiki';
|
|
9
9
|
|
|
10
|
-
const version = "3.
|
|
10
|
+
const version = "3.21.0";
|
|
11
11
|
|
|
12
12
|
function isUrl(path) {
|
|
13
13
|
return path.startsWith("http://") || path.startsWith("https://");
|
|
@@ -37,13 +37,21 @@ async function readSource(path) {
|
|
|
37
37
|
}
|
|
38
38
|
async function run(argv = process.argv, log = console.log) {
|
|
39
39
|
const cli = cac("shiki");
|
|
40
|
-
cli.option("--theme <theme>", "Color theme to use", { default: "vitesse-dark" }).option("--lang <lang>", "Programming language").help().version(version);
|
|
40
|
+
cli.option("--theme <theme>", "Color theme to use", { default: "vitesse-dark" }).option("--lang <lang>", "Programming language").option("--format <format>", "Output format (ansi, html)", { default: "ansi" }).help().version(version);
|
|
41
41
|
const { options, args } = cli.parse(argv);
|
|
42
42
|
const files = args;
|
|
43
43
|
const codes = await Promise.all(files.map(async (path) => {
|
|
44
44
|
const { content, ext } = await readSource(path);
|
|
45
45
|
const lang = options.lang || ext;
|
|
46
|
-
|
|
46
|
+
if (options.format === "html") {
|
|
47
|
+
const { codeToHtml } = await import('shiki');
|
|
48
|
+
return await codeToHtml(content, {
|
|
49
|
+
lang,
|
|
50
|
+
theme: options.theme
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
return await codeToANSI(content, lang, options.theme);
|
|
54
|
+
}
|
|
47
55
|
}));
|
|
48
56
|
for (const code of codes)
|
|
49
57
|
log(code);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.21.0",
|
|
5
5
|
"description": "Shiki in the command line",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@shikijs/vscode-textmate": "^10.0.2",
|
|
40
40
|
"ansis": "^4.2.0",
|
|
41
41
|
"cac": "^6.7.14",
|
|
42
|
-
"shiki": "3.
|
|
42
|
+
"shiki": "3.21.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "unbuild",
|