@slidev/parser 0.49.12 → 0.49.14
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-HHQTU4EH.mjs → chunk-ZR4UYCRF.mjs} +1 -1
- package/dist/core.mjs +1 -1
- package/dist/fs.mjs +25 -8
- package/dist/index.mjs +1 -1
- package/package.json +11 -14
- package/fs.d.ts +0 -1
|
@@ -120,7 +120,7 @@ function verifyConfig(config, themeMeta = {}, warn = (v) => console.warn(`[slide
|
|
|
120
120
|
warn(`Color schema "${config.colorSchema}" does not supported by the theme`);
|
|
121
121
|
if (themeHightlighter && config.highlighter !== themeHightlighter)
|
|
122
122
|
warn(`Syntax highlighter "${config.highlighter}" does not supported by the theme`);
|
|
123
|
-
if (
|
|
123
|
+
if (config.css !== "unocss") {
|
|
124
124
|
warn(`Unsupported Atomic CSS engine "${config.css}", fallback to UnoCSS`);
|
|
125
125
|
config.css = "unocss";
|
|
126
126
|
}
|
package/dist/core.mjs
CHANGED
package/dist/fs.mjs
CHANGED
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
stringify,
|
|
13
13
|
stringifySlide,
|
|
14
14
|
verifyConfig
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ZR4UYCRF.mjs";
|
|
16
16
|
|
|
17
17
|
// src/fs.ts
|
|
18
|
-
import
|
|
18
|
+
import fs from "node:fs";
|
|
19
19
|
import { dirname, resolve } from "node:path";
|
|
20
20
|
import YAML from "yaml";
|
|
21
21
|
import { slash } from "@antfu/utils";
|
|
@@ -24,7 +24,7 @@ function injectPreparserExtensionLoader(fn) {
|
|
|
24
24
|
preparserExtensionLoader = fn;
|
|
25
25
|
}
|
|
26
26
|
async function load(userRoot, filepath, content, mode) {
|
|
27
|
-
const markdown = content ??
|
|
27
|
+
const markdown = content ?? fs.readFileSync(filepath, "utf-8");
|
|
28
28
|
let extensions;
|
|
29
29
|
if (preparserExtensionLoader) {
|
|
30
30
|
const lines = markdown.split(/\r?\n/g);
|
|
@@ -43,20 +43,29 @@ async function load(userRoot, filepath, content, mode) {
|
|
|
43
43
|
async function loadMarkdown(path, range, frontmatterOverride, importers) {
|
|
44
44
|
let md = markdownFiles[path];
|
|
45
45
|
if (!md) {
|
|
46
|
-
const raw =
|
|
46
|
+
const raw = fs.readFileSync(path, "utf-8");
|
|
47
47
|
md = await parse(raw, path, extensions);
|
|
48
48
|
markdownFiles[path] = md;
|
|
49
49
|
}
|
|
50
50
|
const directImporter = importers?.at(-1);
|
|
51
51
|
for (const index of parseRangeString(md.slides.length, range)) {
|
|
52
52
|
const subSlide = md.slides[index - 1];
|
|
53
|
-
|
|
53
|
+
try {
|
|
54
|
+
await loadSlide(md, subSlide, frontmatterOverride, importers);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
md.errors ??= [];
|
|
57
|
+
md.errors.push({
|
|
58
|
+
row: subSlide.start,
|
|
59
|
+
message: `Error when loading slide: ${e}`
|
|
60
|
+
});
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
54
63
|
if (directImporter)
|
|
55
64
|
(directImporter.imports ??= []).push(subSlide);
|
|
56
65
|
}
|
|
57
66
|
return md;
|
|
58
67
|
}
|
|
59
|
-
async function loadSlide(slide, frontmatterOverride, importChain) {
|
|
68
|
+
async function loadSlide(md, slide, frontmatterOverride, importChain) {
|
|
60
69
|
if (slide.frontmatter.disabled || slide.frontmatter.hide)
|
|
61
70
|
return;
|
|
62
71
|
if (slide.frontmatter.src) {
|
|
@@ -69,7 +78,15 @@ async function load(userRoot, filepath, content, mode) {
|
|
|
69
78
|
...frontmatterOverride
|
|
70
79
|
};
|
|
71
80
|
delete frontmatterOverride.src;
|
|
72
|
-
|
|
81
|
+
if (!fs.existsSync(path)) {
|
|
82
|
+
md.errors ??= [];
|
|
83
|
+
md.errors.push({
|
|
84
|
+
row: slide.start,
|
|
85
|
+
message: `Imported markdown file not found: ${path}`
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
await loadMarkdown(path, rangeRaw, frontmatterOverride, importChain ? [...importChain, slide] : [slide]);
|
|
89
|
+
}
|
|
73
90
|
} else {
|
|
74
91
|
slides.push({
|
|
75
92
|
index: slides.length,
|
|
@@ -98,7 +115,7 @@ async function load(userRoot, filepath, content, mode) {
|
|
|
98
115
|
}
|
|
99
116
|
async function save(markdown) {
|
|
100
117
|
const fileContent = stringify(markdown);
|
|
101
|
-
|
|
118
|
+
fs.writeFileSync(markdown.filepath, fileContent, "utf-8");
|
|
102
119
|
return fileContent;
|
|
103
120
|
}
|
|
104
121
|
export {
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/parser",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.14",
|
|
4
4
|
"description": "Markdown parser for Slidev",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,24 +13,21 @@
|
|
|
13
13
|
"bugs": "https://github.com/slidevjs/slidev/issues",
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
|
-
"types": "./dist/index.d.
|
|
17
|
-
"import": "./dist/index.mjs"
|
|
18
|
-
"require": "./dist/index.js"
|
|
16
|
+
"types": "./dist/index.d.mts",
|
|
17
|
+
"import": "./dist/index.mjs"
|
|
19
18
|
},
|
|
20
19
|
"./core": {
|
|
21
|
-
"types": "./dist/core.d.
|
|
22
|
-
"import": "./dist/core.mjs"
|
|
23
|
-
"require": "./dist/core.js"
|
|
20
|
+
"types": "./dist/core.d.mts",
|
|
21
|
+
"import": "./dist/core.mjs"
|
|
24
22
|
},
|
|
25
23
|
"./fs": {
|
|
26
|
-
"types": "./fs.d.
|
|
27
|
-
"import": "./dist/fs.mjs"
|
|
28
|
-
"require": "./dist/fs.js"
|
|
24
|
+
"types": "./dist/fs.d.mts",
|
|
25
|
+
"import": "./dist/fs.mjs"
|
|
29
26
|
}
|
|
30
27
|
},
|
|
31
|
-
"main": "dist/index.
|
|
28
|
+
"main": "dist/index.mjs",
|
|
32
29
|
"module": "dist/index.mjs",
|
|
33
|
-
"types": "dist/index.d.
|
|
30
|
+
"types": "dist/index.d.mts",
|
|
34
31
|
"files": [
|
|
35
32
|
"*.d.ts",
|
|
36
33
|
"dist"
|
|
@@ -39,9 +36,9 @@
|
|
|
39
36
|
"node": ">=18.0.0"
|
|
40
37
|
},
|
|
41
38
|
"dependencies": {
|
|
42
|
-
"@antfu/utils": "^0.7.
|
|
39
|
+
"@antfu/utils": "^0.7.10",
|
|
43
40
|
"yaml": "^2.4.5",
|
|
44
|
-
"@slidev/types": "0.49.
|
|
41
|
+
"@slidev/types": "0.49.14"
|
|
45
42
|
},
|
|
46
43
|
"scripts": {
|
|
47
44
|
"build": "rimraf dist && tsup src/index.ts src/core.ts src/fs.ts",
|
package/fs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/fs.mjs'
|