@slidev/parser 0.49.0-beta.1 → 0.49.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/{chunk-RGJSOXI6.mjs → chunk-S3IBVRFG.mjs} +12 -17
- package/dist/core.mjs +1 -1
- package/dist/fs.mjs +3 -3
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/core.ts
|
|
2
|
-
import YAML from "
|
|
2
|
+
import YAML from "yaml";
|
|
3
3
|
|
|
4
4
|
// ../../node_modules/.pnpm/@antfu+utils@0.7.7/node_modules/@antfu/utils/dist/index.mjs
|
|
5
5
|
function toArray(array) {
|
|
@@ -26,12 +26,10 @@ function range(...args) {
|
|
|
26
26
|
}
|
|
27
27
|
return arr;
|
|
28
28
|
}
|
|
29
|
-
var toString = (v) => Object.prototype.toString.call(v);
|
|
30
29
|
function notNullish(v) {
|
|
31
30
|
return v != null;
|
|
32
31
|
}
|
|
33
32
|
var isNumber = (val) => typeof val === "number";
|
|
34
|
-
var isObject = (val) => toString(val) === "[object Object]";
|
|
35
33
|
function slash(str) {
|
|
36
34
|
return str.replace(/\\/g, "/");
|
|
37
35
|
}
|
|
@@ -113,7 +111,8 @@ function getDefaultConfig() {
|
|
|
113
111
|
presenter: true,
|
|
114
112
|
htmlAttrs: {},
|
|
115
113
|
transition: void 0,
|
|
116
|
-
editor: true
|
|
114
|
+
editor: true,
|
|
115
|
+
contextMenu: void 0
|
|
117
116
|
};
|
|
118
117
|
}
|
|
119
118
|
function resolveConfig(headmatter, themeMeta = {}, filepath, verify = false) {
|
|
@@ -263,11 +262,11 @@ function prettifySlide(data) {
|
|
|
263
262
|
data.content = trimed ? `
|
|
264
263
|
${data.content.trim()}
|
|
265
264
|
` : "";
|
|
266
|
-
data.raw = data.
|
|
267
|
-
${data.
|
|
265
|
+
data.raw = data.frontmatterDoc?.contents ? data.frontmatterStyle === "yaml" ? `\`\`\`yaml
|
|
266
|
+
${data.frontmatterDoc.toString().trim()}
|
|
268
267
|
\`\`\`
|
|
269
268
|
${data.content}` : `---
|
|
270
|
-
${data.
|
|
269
|
+
${data.frontmatterDoc.toString().trim()}
|
|
271
270
|
---
|
|
272
271
|
${data.content}` : data.content;
|
|
273
272
|
if (data.note)
|
|
@@ -282,32 +281,27 @@ function prettify(data) {
|
|
|
282
281
|
data.slides.forEach(prettifySlide);
|
|
283
282
|
return data;
|
|
284
283
|
}
|
|
285
|
-
function safeParseYAML(str) {
|
|
286
|
-
const res = YAML.load(str);
|
|
287
|
-
return isObject(res) ? res : {};
|
|
288
|
-
}
|
|
289
284
|
function matter(code) {
|
|
290
285
|
let type;
|
|
291
286
|
let raw;
|
|
292
|
-
const data = {};
|
|
293
287
|
let content = code.replace(/^---.*\r?\n([\s\S]*?)---/, (_, f) => {
|
|
294
288
|
type = "frontmatter";
|
|
295
289
|
raw = f;
|
|
296
|
-
Object.assign(data, safeParseYAML(f));
|
|
297
290
|
return "";
|
|
298
291
|
});
|
|
299
292
|
if (type !== "frontmatter") {
|
|
300
|
-
content = content.replace(/^\s*```ya?ml([\s\S]*?)```/, (_,
|
|
293
|
+
content = content.replace(/^\s*```ya?ml([\s\S]*?)```/, (_, f) => {
|
|
301
294
|
type = "yaml";
|
|
302
|
-
raw =
|
|
303
|
-
Object.assign(data, safeParseYAML(d));
|
|
295
|
+
raw = f;
|
|
304
296
|
return "";
|
|
305
297
|
});
|
|
306
298
|
}
|
|
299
|
+
const doc = YAML.parseDocument(raw || "");
|
|
307
300
|
return {
|
|
308
301
|
type,
|
|
309
302
|
raw,
|
|
310
|
-
|
|
303
|
+
doc,
|
|
304
|
+
data: doc.toJSON(),
|
|
311
305
|
content
|
|
312
306
|
};
|
|
313
307
|
}
|
|
@@ -350,6 +344,7 @@ function parseSlide(raw) {
|
|
|
350
344
|
content,
|
|
351
345
|
frontmatter,
|
|
352
346
|
frontmatterStyle: matterResult.type,
|
|
347
|
+
frontmatterDoc: matterResult.doc,
|
|
353
348
|
frontmatterRaw: matterResult.raw,
|
|
354
349
|
note
|
|
355
350
|
};
|
package/dist/core.mjs
CHANGED
package/dist/fs.mjs
CHANGED
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
stringify,
|
|
15
15
|
stringifySlide,
|
|
16
16
|
verifyConfig
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-S3IBVRFG.mjs";
|
|
18
18
|
|
|
19
19
|
// src/fs.ts
|
|
20
20
|
import { promises as fs } from "node:fs";
|
|
21
21
|
import { dirname, resolve } from "node:path";
|
|
22
|
-
import YAML from "
|
|
22
|
+
import YAML from "yaml";
|
|
23
23
|
var preparserExtensionLoader = null;
|
|
24
24
|
function injectPreparserExtensionLoader(fn) {
|
|
25
25
|
preparserExtensionLoader = fn;
|
|
@@ -36,7 +36,7 @@ async function load(userRoot, filepath, content, mode) {
|
|
|
36
36
|
hEnd++;
|
|
37
37
|
hm = lines.slice(1, hEnd).join("\n");
|
|
38
38
|
}
|
|
39
|
-
const o = YAML.
|
|
39
|
+
const o = YAML.parse(hm) ?? {};
|
|
40
40
|
extensions = await preparserExtensionLoader(o, filepath, mode);
|
|
41
41
|
}
|
|
42
42
|
const markdownFiles = {};
|
package/dist/index.mjs
CHANGED
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.2",
|
|
4
4
|
"description": "Markdown parser for Slidev",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"node": ">=18.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"
|
|
43
|
-
"@slidev/types": "0.49.0-beta.
|
|
42
|
+
"yaml": "^2.4.1",
|
|
43
|
+
"@slidev/types": "0.49.0-beta.2"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "rimraf dist && tsup src/index.ts src/core.ts src/fs.ts",
|