@slidev/cli 0.49.29 → 0.50.0-beta.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/dist/{build-2WDSCT4J.js → build-EZGSYF7Q.js} +6 -7
- package/dist/{chunk-IVWMFGB5.js → chunk-DB2KJXEE.js} +1 -1
- package/dist/{chunk-YP37OZJY.js → chunk-TEOA76MP.js} +967 -928
- package/dist/cli.js +18 -20
- package/dist/{export-FTRUCBWA.js → export-WMRLKOJP.js} +7 -7
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -4
- package/package.json +27 -28
- package/template.md +0 -2
- package/dist/chunk-6DS3IPOB.js +0 -31
- package/dist/markdown-it-prism-P475G4NP.js +0 -107
- package/dist/{chunk-HOVIRHCR.js → chunk-UNQ5DBLZ.js} +6 -6
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DB2KJXEE.js";
|
|
4
4
|
import {
|
|
5
5
|
getThemeMeta,
|
|
6
6
|
loadSetups,
|
|
@@ -9,27 +9,26 @@ import {
|
|
|
9
9
|
resolveOptions,
|
|
10
10
|
resolveTheme,
|
|
11
11
|
version
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-6DS3IPOB.js";
|
|
12
|
+
} from "./chunk-TEOA76MP.js";
|
|
14
13
|
import {
|
|
15
14
|
getRoots,
|
|
16
15
|
isInstalledGlobally,
|
|
17
16
|
resolveEntry
|
|
18
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UNQ5DBLZ.js";
|
|
19
18
|
|
|
20
19
|
// node/cli.ts
|
|
21
|
-
import path from "node:path";
|
|
22
|
-
import os from "node:os";
|
|
23
20
|
import { exec } from "node:child_process";
|
|
24
|
-
import
|
|
21
|
+
import os from "node:os";
|
|
22
|
+
import path from "node:path";
|
|
25
23
|
import process from "node:process";
|
|
24
|
+
import * as readline from "node:readline";
|
|
25
|
+
import { verifyConfig } from "@slidev/parser";
|
|
26
|
+
import equal from "fast-deep-equal";
|
|
26
27
|
import fs from "fs-extra";
|
|
28
|
+
import { getPort } from "get-port-please";
|
|
29
|
+
import { blue, bold, cyan, dim, gray, green, underline, yellow } from "kolorist";
|
|
27
30
|
import openBrowser from "open";
|
|
28
31
|
import yargs from "yargs";
|
|
29
|
-
import { blue, bold, cyan, dim, gray, green, underline, yellow } from "kolorist";
|
|
30
|
-
import equal from "fast-deep-equal";
|
|
31
|
-
import { verifyConfig } from "@slidev/parser";
|
|
32
|
-
import { getPort } from "get-port-please";
|
|
33
32
|
|
|
34
33
|
// node/setups/preparser.ts
|
|
35
34
|
import { uniq } from "@antfu/utils";
|
|
@@ -51,7 +50,6 @@ async function setupPreparser() {
|
|
|
51
50
|
|
|
52
51
|
// node/cli.ts
|
|
53
52
|
var CONFIG_RESTART_FIELDS = [
|
|
54
|
-
"highlighter",
|
|
55
53
|
"monaco",
|
|
56
54
|
"routerMode",
|
|
57
55
|
"fonts",
|
|
@@ -60,7 +58,7 @@ var CONFIG_RESTART_FIELDS = [
|
|
|
60
58
|
"editor",
|
|
61
59
|
"theme"
|
|
62
60
|
];
|
|
63
|
-
var
|
|
61
|
+
var FILES_CREATE_RESTART = [
|
|
64
62
|
"global-bottom.vue",
|
|
65
63
|
"global-top.vue",
|
|
66
64
|
"uno.config.js",
|
|
@@ -68,7 +66,7 @@ var FILES_CREATE_RESTART_GLOBS = [
|
|
|
68
66
|
"unocss.config.js",
|
|
69
67
|
"unocss.config.ts"
|
|
70
68
|
];
|
|
71
|
-
var
|
|
69
|
+
var FILES_CHANGE_RESTART = [
|
|
72
70
|
"setup/shiki.ts",
|
|
73
71
|
"setup/katex.ts",
|
|
74
72
|
"setup/preparser.ts"
|
|
@@ -284,8 +282,8 @@ ${dim(" Public IP: ")} ${blue(publicIp)}
|
|
|
284
282
|
bindShortcut();
|
|
285
283
|
const { watch } = await import("chokidar");
|
|
286
284
|
const watcher = watch([
|
|
287
|
-
...
|
|
288
|
-
...
|
|
285
|
+
...FILES_CREATE_RESTART,
|
|
286
|
+
...FILES_CHANGE_RESTART
|
|
289
287
|
], {
|
|
290
288
|
ignored: ["node_modules", ".git"],
|
|
291
289
|
ignoreInitial: true
|
|
@@ -303,7 +301,7 @@ ${dim(" Public IP: ")} ${blue(publicIp)}
|
|
|
303
301
|
restartServer();
|
|
304
302
|
});
|
|
305
303
|
watcher.on("change", (file) => {
|
|
306
|
-
if (
|
|
304
|
+
if (FILES_CREATE_RESTART.includes(file))
|
|
307
305
|
return;
|
|
308
306
|
console.log(yellow(`
|
|
309
307
|
file ${file} changed, restarting...
|
|
@@ -334,7 +332,7 @@ cli.command(
|
|
|
334
332
|
}).strict().help(),
|
|
335
333
|
async (args) => {
|
|
336
334
|
const { entry, theme, base, download, out, inspect } = args;
|
|
337
|
-
const { build } = await import("./build-
|
|
335
|
+
const { build } = await import("./build-EZGSYF7Q.js");
|
|
338
336
|
for (const entryFile of entry) {
|
|
339
337
|
const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
|
|
340
338
|
if (download && !options.data.config.download)
|
|
@@ -414,7 +412,7 @@ cli.command(
|
|
|
414
412
|
(args) => exportOptions(commonOptions(args)).strict().help(),
|
|
415
413
|
async (args) => {
|
|
416
414
|
const { entry, theme } = args;
|
|
417
|
-
const { exportSlides, getExportOptions } = await import("./export-
|
|
415
|
+
const { exportSlides, getExportOptions } = await import("./export-WMRLKOJP.js");
|
|
418
416
|
const port = await getPort(12445);
|
|
419
417
|
for (const entryFile of entry) {
|
|
420
418
|
const options = await resolveOptions({ entry: entryFile, theme }, "export");
|
|
@@ -463,7 +461,7 @@ cli.command(
|
|
|
463
461
|
timeout,
|
|
464
462
|
wait
|
|
465
463
|
}) => {
|
|
466
|
-
const { exportNotes } = await import("./export-
|
|
464
|
+
const { exportNotes } = await import("./export-WMRLKOJP.js");
|
|
467
465
|
const port = await getPort(12445);
|
|
468
466
|
for (const entryFile of entry) {
|
|
469
467
|
const options = await resolveOptions({ entry: entryFile }, "export");
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getRoots
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UNQ5DBLZ.js";
|
|
4
4
|
|
|
5
5
|
// node/commands/export.ts
|
|
6
|
-
import path from "node:path";
|
|
7
6
|
import { Buffer } from "node:buffer";
|
|
7
|
+
import path from "node:path";
|
|
8
8
|
import process from "node:process";
|
|
9
|
-
import fs from "fs-extra";
|
|
10
|
-
import { blue, cyan, dim, green, yellow } from "kolorist";
|
|
11
|
-
import { Presets, SingleBar } from "cli-progress";
|
|
12
9
|
import { clearUndefined, slash } from "@antfu/utils";
|
|
13
|
-
import { parseRangeString } from "@slidev/parser/core";
|
|
14
10
|
import { outlinePdfFactory } from "@lillallol/outline-pdf";
|
|
11
|
+
import { parseRangeString } from "@slidev/parser/core";
|
|
12
|
+
import { Presets, SingleBar } from "cli-progress";
|
|
13
|
+
import fs from "fs-extra";
|
|
14
|
+
import { blue, cyan, dim, green, yellow } from "kolorist";
|
|
15
|
+
import { resolve } from "mlly";
|
|
15
16
|
import * as pdfLib from "pdf-lib";
|
|
16
17
|
import { PDFDocument } from "pdf-lib";
|
|
17
|
-
import { resolve } from "mlly";
|
|
18
18
|
function addToTree(tree, info, slideIndexes, level = 1) {
|
|
19
19
|
const titleLevel = info.level;
|
|
20
20
|
if (titleLevel && titleLevel > level && tree.length > 0 && tree[tree.length - 1].titleLevel < titleLevel) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ResolvedSlidevOptions, SlidevPluginOptions, SlidevServerOptions, SlidevEntryOptions, ResolvedSlidevUtils } from '@slidev/types';
|
|
2
1
|
import * as vite from 'vite';
|
|
3
|
-
import {
|
|
2
|
+
import { InlineConfig, PluginOption } from 'vite';
|
|
3
|
+
import { ResolvedSlidevOptions, SlidevServerOptions, SlidevEntryOptions, ResolvedSlidevUtils, SlidevPluginOptions } from '@slidev/types';
|
|
4
4
|
import * as fs from '@slidev/parser/fs';
|
|
5
5
|
export { fs as parser };
|
|
6
6
|
|
|
7
|
-
declare function ViteSlidevPlugin(options: ResolvedSlidevOptions, pluginOptions?: SlidevPluginOptions, serverOptions?: SlidevServerOptions): Promise<PluginOption[]>;
|
|
8
|
-
|
|
9
7
|
declare function createServer(options: ResolvedSlidevOptions, viteConfig?: InlineConfig, serverOptions?: SlidevServerOptions): Promise<vite.ViteDevServer>;
|
|
10
8
|
|
|
11
9
|
declare function resolveOptions(entryOptions: SlidevEntryOptions, mode: ResolvedSlidevOptions['mode']): Promise<ResolvedSlidevOptions>;
|
|
12
10
|
declare function createDataUtils(resolved: Omit<ResolvedSlidevOptions, 'utils'>): Promise<ResolvedSlidevUtils>;
|
|
13
11
|
|
|
12
|
+
declare function ViteSlidevPlugin(options: ResolvedSlidevOptions, pluginOptions?: SlidevPluginOptions, serverOptions?: SlidevServerOptions): Promise<PluginOption[]>;
|
|
13
|
+
|
|
14
14
|
export { ViteSlidevPlugin, createDataUtils, createServer, resolveOptions };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DB2KJXEE.js";
|
|
4
4
|
import {
|
|
5
5
|
ViteSlidevPlugin,
|
|
6
6
|
createDataUtils,
|
|
7
7
|
parser,
|
|
8
8
|
resolveOptions
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-HOVIRHCR.js";
|
|
9
|
+
} from "./chunk-TEOA76MP.js";
|
|
10
|
+
import "./chunk-UNQ5DBLZ.js";
|
|
12
11
|
export {
|
|
13
12
|
ViteSlidevPlugin,
|
|
14
13
|
createDataUtils,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.50.0-beta.2",
|
|
5
5
|
"description": "Presentation slides for developers",
|
|
6
6
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -42,23 +42,23 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@antfu/ni": "^0.
|
|
45
|
+
"@antfu/ni": "^0.23.0",
|
|
46
46
|
"@antfu/utils": "^0.7.10",
|
|
47
|
-
"@iconify-json/carbon": "^1.1
|
|
48
|
-
"@iconify-json/ph": "^1.
|
|
49
|
-
"@iconify-json/svg-spinners": "^1.
|
|
47
|
+
"@iconify-json/carbon": "^1.2.1",
|
|
48
|
+
"@iconify-json/ph": "^1.2.0",
|
|
49
|
+
"@iconify-json/svg-spinners": "^1.2.0",
|
|
50
50
|
"@lillallol/outline-pdf": "^4.0.0",
|
|
51
|
-
"@shikijs/markdown-it": "^1.
|
|
52
|
-
"@shikijs/twoslash": "^1.
|
|
53
|
-
"@shikijs/vitepress-twoslash": "^1.
|
|
54
|
-
"@unocss/extractor-mdc": "^0.
|
|
55
|
-
"@unocss/reset": "^0.
|
|
56
|
-
"@vitejs/plugin-vue": "^5.1.
|
|
51
|
+
"@shikijs/markdown-it": "^1.21.0",
|
|
52
|
+
"@shikijs/twoslash": "^1.21.0",
|
|
53
|
+
"@shikijs/vitepress-twoslash": "^1.21.0",
|
|
54
|
+
"@unocss/extractor-mdc": "^0.63.1",
|
|
55
|
+
"@unocss/reset": "^0.63.1",
|
|
56
|
+
"@vitejs/plugin-vue": "^5.1.4",
|
|
57
57
|
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
|
58
|
-
"chokidar": "^
|
|
58
|
+
"chokidar": "^4.0.1",
|
|
59
59
|
"cli-progress": "^3.12.0",
|
|
60
60
|
"connect": "^3.7.0",
|
|
61
|
-
"debug": "^4.3.
|
|
61
|
+
"debug": "^4.3.7",
|
|
62
62
|
"fast-deep-equal": "^3.1.3",
|
|
63
63
|
"fast-glob": "^3.3.2",
|
|
64
64
|
"fs-extra": "^11.2.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"global-directory": "^4.0.1",
|
|
67
67
|
"htmlparser2": "^9.1.0",
|
|
68
68
|
"is-installed-globally": "^1.0.0",
|
|
69
|
-
"jiti": "^
|
|
69
|
+
"jiti": "^2.0.0",
|
|
70
70
|
"katex": "^0.16.11",
|
|
71
71
|
"kolorist": "^1.8.0",
|
|
72
72
|
"local-pkg": "^0.5.0",
|
|
@@ -78,41 +78,40 @@
|
|
|
78
78
|
"markdown-it-mdc": "^0.2.5",
|
|
79
79
|
"micromatch": "^4.0.8",
|
|
80
80
|
"mlly": "^1.7.1",
|
|
81
|
-
"monaco-editor": "^0.
|
|
81
|
+
"monaco-editor": "^0.52.0",
|
|
82
82
|
"open": "^10.1.0",
|
|
83
83
|
"pdf-lib": "^1.17.1",
|
|
84
84
|
"plantuml-encoder": "^1.4.0",
|
|
85
85
|
"postcss-nested": "^6.2.0",
|
|
86
86
|
"pptxgenjs": "^3.12.0",
|
|
87
|
-
"prismjs": "^1.29.0",
|
|
88
87
|
"prompts": "^2.4.2",
|
|
89
88
|
"public-ip": "^7.0.1",
|
|
90
89
|
"resolve-from": "^5.0.0",
|
|
91
90
|
"resolve-global": "^2.0.0",
|
|
92
91
|
"semver": "^7.6.3",
|
|
93
|
-
"shiki": "^1.
|
|
92
|
+
"shiki": "^1.21.0",
|
|
94
93
|
"shiki-magic-move": "^0.4.4",
|
|
95
94
|
"sirv": "^2.0.4",
|
|
96
|
-
"source-map-js": "^1.2.
|
|
97
|
-
"typescript": "^5.
|
|
98
|
-
"unocss": "^0.
|
|
99
|
-
"unplugin-icons": "^0.19.
|
|
95
|
+
"source-map-js": "^1.2.1",
|
|
96
|
+
"typescript": "^5.6.2",
|
|
97
|
+
"unocss": "^0.63.1",
|
|
98
|
+
"unplugin-icons": "^0.19.3",
|
|
100
99
|
"unplugin-vue-components": "^0.27.4",
|
|
101
100
|
"unplugin-vue-markdown": "^0.26.2",
|
|
102
101
|
"untun": "^0.1.3",
|
|
103
102
|
"uqr": "^0.1.2",
|
|
104
|
-
"vite": "^5.4.
|
|
103
|
+
"vite": "^5.4.8",
|
|
105
104
|
"vite-plugin-inspect": "^0.8.7",
|
|
106
105
|
"vite-plugin-remote-assets": "^0.5.0",
|
|
107
106
|
"vite-plugin-static-copy": "^1.0.6",
|
|
108
107
|
"vite-plugin-vue-server-ref": "^0.4.2",
|
|
109
|
-
"vitefu": "^1.0.
|
|
110
|
-
"vue": "^3.
|
|
111
|
-
"yaml": "^2.5.
|
|
108
|
+
"vitefu": "^1.0.2",
|
|
109
|
+
"vue": "^3.5.10",
|
|
110
|
+
"yaml": "^2.5.1",
|
|
112
111
|
"yargs": "^17.7.2",
|
|
113
|
-
"@slidev/client": "0.
|
|
114
|
-
"@slidev/
|
|
115
|
-
"@slidev/
|
|
112
|
+
"@slidev/client": "0.50.0-beta.2",
|
|
113
|
+
"@slidev/types": "0.50.0-beta.2",
|
|
114
|
+
"@slidev/parser": "0.50.0-beta.2"
|
|
116
115
|
},
|
|
117
116
|
"devDependencies": {
|
|
118
117
|
"@hedgedoc/markdown-it-plugins": "^2.1.4",
|
package/template.md
CHANGED
|
@@ -6,8 +6,6 @@ theme: seriph
|
|
|
6
6
|
background: https://cover.sli.dev
|
|
7
7
|
# apply any unocss classes to the current slide
|
|
8
8
|
class: 'text-center'
|
|
9
|
-
# https://sli.dev/custom/config-highlighter.html
|
|
10
|
-
highlighter: shiki
|
|
11
9
|
# some information about the slides, markdown enabled
|
|
12
10
|
info: |
|
|
13
11
|
## Slidev Starter Template
|
package/dist/chunk-6DS3IPOB.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// node/syntax/transform/utils.ts
|
|
2
|
-
function normalizeRangeStr(rangeStr = "") {
|
|
3
|
-
return !rangeStr.trim() ? [] : rangeStr.trim().split(/\|/g).map((i) => i.trim());
|
|
4
|
-
}
|
|
5
|
-
function getCodeBlocks(md) {
|
|
6
|
-
const codeblocks = Array.from(md.matchAll(/^```[\s\S]*?^```/gm)).map((m) => {
|
|
7
|
-
const start = m.index;
|
|
8
|
-
const end = m.index + m[0].length;
|
|
9
|
-
const startLine = md.slice(0, start).match(/\n/g)?.length || 0;
|
|
10
|
-
const endLine = md.slice(0, end).match(/\n/g)?.length || 0;
|
|
11
|
-
return [start, end, startLine, endLine];
|
|
12
|
-
});
|
|
13
|
-
return {
|
|
14
|
-
codeblocks,
|
|
15
|
-
isInsideCodeblocks(idx) {
|
|
16
|
-
return codeblocks.some(([s, e]) => s <= idx && idx <= e);
|
|
17
|
-
},
|
|
18
|
-
isLineInsideCodeblocks(line) {
|
|
19
|
-
return codeblocks.some(([, , s, e]) => s <= line && line <= e);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function escapeVueInCode(md) {
|
|
24
|
-
return md.replace(/\{\{/g, "{{");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
normalizeRangeStr,
|
|
29
|
-
getCodeBlocks,
|
|
30
|
-
escapeVueInCode
|
|
31
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
escapeVueInCode
|
|
3
|
-
} from "./chunk-6DS3IPOB.js";
|
|
4
|
-
|
|
5
|
-
// node/syntax/markdown-it/markdown-it-prism.ts
|
|
6
|
-
import { createRequire } from "node:module";
|
|
7
|
-
import Prism from "prismjs";
|
|
8
|
-
import loadLanguages from "prismjs/components/index.js";
|
|
9
|
-
import * as htmlparser2 from "htmlparser2";
|
|
10
|
-
var require2 = createRequire(import.meta.url);
|
|
11
|
-
var Tag = class {
|
|
12
|
-
tagname;
|
|
13
|
-
attributes;
|
|
14
|
-
constructor(tagname, attributes) {
|
|
15
|
-
this.tagname = tagname;
|
|
16
|
-
this.attributes = attributes;
|
|
17
|
-
}
|
|
18
|
-
asOpen() {
|
|
19
|
-
return `<${this.tagname} ${Object.entries(this.attributes).map(([key, value]) => `${key}="${value}"`).join(" ")}>`;
|
|
20
|
-
}
|
|
21
|
-
asClosed() {
|
|
22
|
-
return `</${this.tagname}>`;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
var DEFAULTS = {
|
|
26
|
-
plugins: [],
|
|
27
|
-
init: () => {
|
|
28
|
-
},
|
|
29
|
-
defaultLanguageForUnknown: void 0,
|
|
30
|
-
defaultLanguageForUnspecified: void 0,
|
|
31
|
-
defaultLanguage: void 0
|
|
32
|
-
};
|
|
33
|
-
function loadPrismLang(lang) {
|
|
34
|
-
if (!lang)
|
|
35
|
-
return void 0;
|
|
36
|
-
let langObject = Prism.languages[lang];
|
|
37
|
-
if (langObject === void 0) {
|
|
38
|
-
loadLanguages([lang]);
|
|
39
|
-
langObject = Prism.languages[lang];
|
|
40
|
-
}
|
|
41
|
-
return langObject;
|
|
42
|
-
}
|
|
43
|
-
function loadPrismPlugin(name) {
|
|
44
|
-
try {
|
|
45
|
-
require2(`prismjs/plugins/${name}/prism-${name}`);
|
|
46
|
-
} catch (e) {
|
|
47
|
-
throw new Error(`Cannot load Prism plugin "${name}". Please check the spelling.`, { cause: e });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function selectLanguage(options, lang) {
|
|
51
|
-
let langToUse = lang;
|
|
52
|
-
if (langToUse === "" && options.defaultLanguageForUnspecified !== void 0)
|
|
53
|
-
langToUse = options.defaultLanguageForUnspecified;
|
|
54
|
-
let prismLang = loadPrismLang(langToUse);
|
|
55
|
-
if (prismLang === void 0 && options.defaultLanguageForUnknown !== void 0) {
|
|
56
|
-
langToUse = options.defaultLanguageForUnknown;
|
|
57
|
-
prismLang = loadPrismLang(langToUse);
|
|
58
|
-
}
|
|
59
|
-
return [langToUse, prismLang];
|
|
60
|
-
}
|
|
61
|
-
function highlight(markdownit, options, text, lang) {
|
|
62
|
-
const [langToUse, prismLang] = selectLanguage(options, lang);
|
|
63
|
-
let code = text.trimEnd();
|
|
64
|
-
code = prismLang ? highlightPrism(code, prismLang, langToUse) : markdownit.utils.escapeHtml(code);
|
|
65
|
-
code = code.split(/\r?\n/g).map((line) => `<span class="line">${line}</span>`).join("\n");
|
|
66
|
-
const classAttribute = langToUse ? ` class="slidev-code ${markdownit.options.langPrefix}${markdownit.utils.escapeHtml(langToUse)}"` : "";
|
|
67
|
-
return escapeVueInCode(`<pre${classAttribute}><code>${code}</code></pre>`);
|
|
68
|
-
}
|
|
69
|
-
function highlightPrism(code, prismLang, langToUse) {
|
|
70
|
-
const openTags = [];
|
|
71
|
-
const parser = new htmlparser2.Parser({
|
|
72
|
-
onopentag(tagname, attributes) {
|
|
73
|
-
openTags.push(new Tag(tagname, attributes));
|
|
74
|
-
},
|
|
75
|
-
onclosetag() {
|
|
76
|
-
openTags.pop();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
code = Prism.highlight(code, prismLang, langToUse);
|
|
80
|
-
code = code.split(/\r?\n/g).map((line) => {
|
|
81
|
-
const prefix = openTags.map((tag) => tag.asOpen()).join("");
|
|
82
|
-
parser.write(line);
|
|
83
|
-
const postfix = openTags.reverse().map((tag) => tag.asClosed()).join("");
|
|
84
|
-
return prefix + line + postfix;
|
|
85
|
-
}).join("\n");
|
|
86
|
-
parser.end();
|
|
87
|
-
return code;
|
|
88
|
-
}
|
|
89
|
-
function checkLanguageOption(options, optionName) {
|
|
90
|
-
const language = options[optionName];
|
|
91
|
-
if (language !== void 0 && loadPrismLang(language) === void 0)
|
|
92
|
-
throw new Error(`Bad option ${optionName}: There is no Prism language '${language}'.`);
|
|
93
|
-
}
|
|
94
|
-
function MarkdownItPrism(markdownit, useroptions) {
|
|
95
|
-
const options = Object.assign({}, DEFAULTS, useroptions);
|
|
96
|
-
checkLanguageOption(options, "defaultLanguage");
|
|
97
|
-
checkLanguageOption(options, "defaultLanguageForUnknown");
|
|
98
|
-
checkLanguageOption(options, "defaultLanguageForUnspecified");
|
|
99
|
-
options.defaultLanguageForUnknown = options.defaultLanguageForUnknown || options.defaultLanguage;
|
|
100
|
-
options.defaultLanguageForUnspecified = options.defaultLanguageForUnspecified || options.defaultLanguage;
|
|
101
|
-
options.plugins.forEach(loadPrismPlugin);
|
|
102
|
-
options.init(Prism);
|
|
103
|
-
markdownit.options.highlight = (text, lang) => highlight(markdownit, options, text, lang);
|
|
104
|
-
}
|
|
105
|
-
export {
|
|
106
|
-
MarkdownItPrism as default
|
|
107
|
-
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// node/resolver.ts
|
|
2
|
-
import { dirname, join, relative, resolve } from "node:path";
|
|
3
2
|
import * as fs from "node:fs";
|
|
3
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { parseNi, run } from "@antfu/ni";
|
|
6
7
|
import { ensurePrefix, slash } from "@antfu/utils";
|
|
7
|
-
import { resolveGlobal } from "resolve-global";
|
|
8
|
-
import { findClosestPkgJsonPath, findDepPkgJsonPath } from "vitefu";
|
|
9
|
-
import { resolvePath } from "mlly";
|
|
10
8
|
import globalDirs from "global-directory";
|
|
11
|
-
import prompts from "prompts";
|
|
12
|
-
import { parseNi, run } from "@antfu/ni";
|
|
13
9
|
import { underline, yellow } from "kolorist";
|
|
10
|
+
import { resolvePath } from "mlly";
|
|
11
|
+
import prompts from "prompts";
|
|
12
|
+
import { resolveGlobal } from "resolve-global";
|
|
13
|
+
import { findClosestPkgJsonPath, findDepPkgJsonPath } from "vitefu";
|
|
14
14
|
var cliRoot = fileURLToPath(new URL("..", import.meta.url));
|
|
15
15
|
var isInstalledGlobally = {};
|
|
16
16
|
async function resolveImportUrl(id) {
|