@slidev/parser 0.49.0-beta.3 → 0.49.0-beta.4
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/{chunk-S3IBVRFG.mjs → chunk-VLJJ245M.mjs} +28 -13
- package/dist/core.d.mts +3 -4
- package/dist/core.mjs +1 -3
- package/dist/fs.d.mts +1 -1
- package/dist/fs.mjs +1 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -3
- package/package.json +2 -2
|
@@ -26,9 +26,6 @@ function range(...args) {
|
|
|
26
26
|
}
|
|
27
27
|
return arr;
|
|
28
28
|
}
|
|
29
|
-
function notNullish(v) {
|
|
30
|
-
return v != null;
|
|
31
|
-
}
|
|
32
29
|
var isNumber = (val) => typeof val === "number";
|
|
33
30
|
function slash(str) {
|
|
34
31
|
return str.replace(/\\/g, "/");
|
|
@@ -38,11 +35,6 @@ function ensurePrefix(prefix, str) {
|
|
|
38
35
|
return prefix + str;
|
|
39
36
|
return str;
|
|
40
37
|
}
|
|
41
|
-
function objectMap(obj, fn) {
|
|
42
|
-
return Object.fromEntries(
|
|
43
|
-
Object.entries(obj).map(([k, v]) => fn(k, v)).filter(notNullish)
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
38
|
var VOID = Symbol("p-void");
|
|
47
39
|
|
|
48
40
|
// src/utils.ts
|
|
@@ -88,6 +80,7 @@ function getDefaultConfig() {
|
|
|
88
80
|
monaco: true,
|
|
89
81
|
monacoTypesSource: "local",
|
|
90
82
|
monacoTypesAdditionalPackages: [],
|
|
83
|
+
monacoRunAdditionalDeps: [],
|
|
91
84
|
download: false,
|
|
92
85
|
export: {},
|
|
93
86
|
info: false,
|
|
@@ -308,7 +301,7 @@ function matter(code) {
|
|
|
308
301
|
function detectFeatures(code) {
|
|
309
302
|
return {
|
|
310
303
|
katex: !!code.match(/\$.*?\$/) || !!code.match(/\$\$/),
|
|
311
|
-
monaco:
|
|
304
|
+
monaco: code.match(/{monaco.*}/) ? scanMonacoReferencedMods(code) : false,
|
|
312
305
|
tweet: !!code.match(/<Tweet\b/),
|
|
313
306
|
mermaid: !!code.match(/^```mermaid/m)
|
|
314
307
|
};
|
|
@@ -409,8 +402,31 @@ async function parse(markdown, filepath, extensions) {
|
|
|
409
402
|
slides
|
|
410
403
|
};
|
|
411
404
|
}
|
|
412
|
-
function
|
|
413
|
-
|
|
405
|
+
function scanMonacoReferencedMods(md) {
|
|
406
|
+
const types = /* @__PURE__ */ new Set();
|
|
407
|
+
const deps = /* @__PURE__ */ new Set();
|
|
408
|
+
md.replace(
|
|
409
|
+
/^```(\w+?)\s*{monaco(.*?)}[\s\n]*([\s\S]+?)^```/mg,
|
|
410
|
+
(full, lang = "ts", kind, code) => {
|
|
411
|
+
lang = lang.trim();
|
|
412
|
+
const isDep = kind === "-run";
|
|
413
|
+
if (["js", "javascript", "ts", "typescript"].includes(lang)) {
|
|
414
|
+
for (const [, , specifier] of code.matchAll(/\s+from\s+(["'])([\/\.\w@-]+)\1/g)) {
|
|
415
|
+
if (specifier) {
|
|
416
|
+
if (!"./".includes(specifier))
|
|
417
|
+
types.add(specifier);
|
|
418
|
+
if (isDep)
|
|
419
|
+
deps.add(specifier);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return "";
|
|
424
|
+
}
|
|
425
|
+
);
|
|
426
|
+
return {
|
|
427
|
+
types: Array.from(types),
|
|
428
|
+
deps: Array.from(deps)
|
|
429
|
+
};
|
|
414
430
|
}
|
|
415
431
|
|
|
416
432
|
export {
|
|
@@ -427,6 +443,5 @@ export {
|
|
|
427
443
|
prettify,
|
|
428
444
|
detectFeatures,
|
|
429
445
|
parseSlide,
|
|
430
|
-
parse
|
|
431
|
-
mergeFeatureFlags
|
|
446
|
+
parse
|
|
432
447
|
};
|
package/dist/core.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SlidevConfig, SlidevThemeMeta, FontOptions, ResolvedFontOptions, SlidevMarkdown, SourceSlideInfo,
|
|
1
|
+
import { SlidevConfig, SlidevThemeMeta, FontOptions, ResolvedFontOptions, SlidevMarkdown, SourceSlideInfo, SlidevDetectedFeatures, SlidevPreparserExtension } from '@slidev/types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 1,3-5,8 => [1, 3, 4, 5, 8]
|
|
@@ -18,9 +18,8 @@ declare function stringify(data: SlidevMarkdown): string;
|
|
|
18
18
|
declare function stringifySlide(data: SourceSlideInfo, idx?: number): string;
|
|
19
19
|
declare function prettifySlide(data: SourceSlideInfo): SourceSlideInfo;
|
|
20
20
|
declare function prettify(data: SlidevMarkdown): SlidevMarkdown;
|
|
21
|
-
declare function detectFeatures(code: string):
|
|
21
|
+
declare function detectFeatures(code: string): SlidevDetectedFeatures;
|
|
22
22
|
declare function parseSlide(raw: string): Omit<SourceSlideInfo, 'filepath' | 'index' | 'start' | 'end'>;
|
|
23
23
|
declare function parse(markdown: string, filepath: string, extensions?: SlidevPreparserExtension[]): Promise<SlidevMarkdown>;
|
|
24
|
-
declare function mergeFeatureFlags(a: SlidevFeatureFlags, b: SlidevFeatureFlags): SlidevFeatureFlags;
|
|
25
24
|
|
|
26
|
-
export { detectFeatures, getDefaultConfig,
|
|
25
|
+
export { detectFeatures, getDefaultConfig, parse, parseAspectRatio, parseRangeString, parseSlide, prettify, prettifySlide, resolveConfig, resolveFonts, stringify, stringifySlide, verifyConfig };
|
package/dist/core.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
detectFeatures,
|
|
3
3
|
getDefaultConfig,
|
|
4
|
-
mergeFeatureFlags,
|
|
5
4
|
parse,
|
|
6
5
|
parseAspectRatio,
|
|
7
6
|
parseRangeString,
|
|
@@ -13,11 +12,10 @@ import {
|
|
|
13
12
|
stringify,
|
|
14
13
|
stringifySlide,
|
|
15
14
|
verifyConfig
|
|
16
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VLJJ245M.mjs";
|
|
17
16
|
export {
|
|
18
17
|
detectFeatures,
|
|
19
18
|
getDefaultConfig,
|
|
20
|
-
mergeFeatureFlags,
|
|
21
19
|
parse,
|
|
22
20
|
parseAspectRatio,
|
|
23
21
|
parseRangeString,
|
package/dist/fs.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PreparserExtensionLoader, SlidevData, SlidevMarkdown } from '@slidev/types';
|
|
2
|
-
export { detectFeatures, getDefaultConfig,
|
|
2
|
+
export { detectFeatures, getDefaultConfig, parse, parseAspectRatio, parseRangeString, parseSlide, prettify, prettifySlide, resolveConfig, resolveFonts, stringify, stringifySlide, verifyConfig } from './core.mjs';
|
|
3
3
|
|
|
4
4
|
declare function injectPreparserExtensionLoader(fn: PreparserExtensionLoader): void;
|
|
5
5
|
/**
|
package/dist/fs.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
detectFeatures,
|
|
3
3
|
getDefaultConfig,
|
|
4
|
-
mergeFeatureFlags,
|
|
5
4
|
parse,
|
|
6
5
|
parseAspectRatio,
|
|
7
6
|
parseRangeString,
|
|
@@ -14,7 +13,7 @@ import {
|
|
|
14
13
|
stringify,
|
|
15
14
|
stringifySlide,
|
|
16
15
|
verifyConfig
|
|
17
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-VLJJ245M.mjs";
|
|
18
17
|
|
|
19
18
|
// src/fs.ts
|
|
20
19
|
import { promises as fs } from "node:fs";
|
|
@@ -100,7 +99,6 @@ export {
|
|
|
100
99
|
getDefaultConfig,
|
|
101
100
|
injectPreparserExtensionLoader,
|
|
102
101
|
load,
|
|
103
|
-
mergeFeatureFlags,
|
|
104
102
|
parse,
|
|
105
103
|
parseAspectRatio,
|
|
106
104
|
parseRangeString,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { detectFeatures, getDefaultConfig,
|
|
1
|
+
export { detectFeatures, getDefaultConfig, parse, parseAspectRatio, parseRangeString, parseSlide, prettify, prettifySlide, resolveConfig, resolveFonts, stringify, stringifySlide, verifyConfig } from './core.mjs';
|
|
2
2
|
import '@slidev/types';
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
detectFeatures,
|
|
3
3
|
getDefaultConfig,
|
|
4
|
-
mergeFeatureFlags,
|
|
5
4
|
parse,
|
|
6
5
|
parseAspectRatio,
|
|
7
6
|
parseRangeString,
|
|
@@ -13,11 +12,10 @@ import {
|
|
|
13
12
|
stringify,
|
|
14
13
|
stringifySlide,
|
|
15
14
|
verifyConfig
|
|
16
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VLJJ245M.mjs";
|
|
17
16
|
export {
|
|
18
17
|
detectFeatures,
|
|
19
18
|
getDefaultConfig,
|
|
20
|
-
mergeFeatureFlags,
|
|
21
19
|
parse,
|
|
22
20
|
parseAspectRatio,
|
|
23
21
|
parseRangeString,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/parser",
|
|
3
|
-
"version": "0.49.0-beta.
|
|
3
|
+
"version": "0.49.0-beta.4",
|
|
4
4
|
"description": "Markdown parser for Slidev",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"yaml": "^2.4.1",
|
|
43
|
-
"@slidev/types": "0.49.0-beta.
|
|
43
|
+
"@slidev/types": "0.49.0-beta.4"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "rimraf dist && tsup src/index.ts src/core.ts src/fs.ts",
|