@slidev/parser 0.37.1 → 0.38.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/{chunk-72T7ERBC.js → chunk-C3OTKWGW.js} +12 -11
- package/dist/{chunk-RYLG7SAK.mjs → chunk-RQLJEQ6S.mjs} +12 -11
- package/dist/core.js +2 -2
- package/dist/core.mjs +1 -1
- package/dist/fs.js +8 -9
- package/dist/fs.mjs +2 -3
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
|
@@ -30,7 +30,7 @@ var __privateWrapper = (obj, member, setter, getter) => {
|
|
|
30
30
|
// src/core.ts
|
|
31
31
|
var _jsyaml = require('js-yaml'); var _jsyaml2 = _interopRequireDefault(_jsyaml);
|
|
32
32
|
|
|
33
|
-
// ../../node_modules/.pnpm/@antfu+utils@0.
|
|
33
|
+
// ../../node_modules/.pnpm/@antfu+utils@0.7.2/node_modules/@antfu/utils/dist/index.mjs
|
|
34
34
|
function toArray(array) {
|
|
35
35
|
array = array != null ? array : [];
|
|
36
36
|
return Array.isArray(array) ? array : [array];
|
|
@@ -401,7 +401,7 @@ function parseSlide(raw) {
|
|
|
401
401
|
};
|
|
402
402
|
}
|
|
403
403
|
async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
404
|
-
var _a, _b, _c;
|
|
404
|
+
var _a, _b, _c, _d;
|
|
405
405
|
const lines = markdown.split(/\r?\n/g);
|
|
406
406
|
const slides = [];
|
|
407
407
|
let start = 0;
|
|
@@ -428,14 +428,15 @@ async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
|
428
428
|
start = end + 1;
|
|
429
429
|
}
|
|
430
430
|
{
|
|
431
|
-
let
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
hEnd
|
|
431
|
+
let hm = "";
|
|
432
|
+
if (lines[0].match(/^---([^-].*)?$/) && !((_a = lines[1]) == null ? void 0 : _a.match(/^\s*$/))) {
|
|
433
|
+
let hEnd = 1;
|
|
434
|
+
while (hEnd < lines.length && !lines[hEnd].trimEnd().match(/^---$/))
|
|
435
|
+
hEnd++;
|
|
436
|
+
hm = lines.slice(1, hEnd).join("\n");
|
|
437
|
+
}
|
|
437
438
|
if (onHeadmatter) {
|
|
438
|
-
const o = (
|
|
439
|
+
const o = (_b = _jsyaml2.default.load(hm)) != null ? _b : {};
|
|
439
440
|
extensions = await onHeadmatter(o, extensions != null ? extensions : [], filepath);
|
|
440
441
|
}
|
|
441
442
|
}
|
|
@@ -466,8 +467,8 @@ async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
|
466
467
|
}
|
|
467
468
|
if (start <= lines.length - 1)
|
|
468
469
|
await slice(lines.length);
|
|
469
|
-
const headmatter = ((
|
|
470
|
-
headmatter.title = headmatter.title || ((
|
|
470
|
+
const headmatter = ((_c = slides[0]) == null ? void 0 : _c.frontmatter) || {};
|
|
471
|
+
headmatter.title = headmatter.title || ((_d = slides[0]) == null ? void 0 : _d.title);
|
|
471
472
|
const config = resolveConfig(headmatter, themeMeta, filepath);
|
|
472
473
|
const features = detectFeatures(markdown);
|
|
473
474
|
return {
|
|
@@ -30,7 +30,7 @@ var __privateWrapper = (obj, member, setter, getter) => {
|
|
|
30
30
|
// src/core.ts
|
|
31
31
|
import YAML from "js-yaml";
|
|
32
32
|
|
|
33
|
-
// ../../node_modules/.pnpm/@antfu+utils@0.
|
|
33
|
+
// ../../node_modules/.pnpm/@antfu+utils@0.7.2/node_modules/@antfu/utils/dist/index.mjs
|
|
34
34
|
function toArray(array) {
|
|
35
35
|
array = array != null ? array : [];
|
|
36
36
|
return Array.isArray(array) ? array : [array];
|
|
@@ -401,7 +401,7 @@ function parseSlide(raw) {
|
|
|
401
401
|
};
|
|
402
402
|
}
|
|
403
403
|
async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
404
|
-
var _a, _b, _c;
|
|
404
|
+
var _a, _b, _c, _d;
|
|
405
405
|
const lines = markdown.split(/\r?\n/g);
|
|
406
406
|
const slides = [];
|
|
407
407
|
let start = 0;
|
|
@@ -428,14 +428,15 @@ async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
|
428
428
|
start = end + 1;
|
|
429
429
|
}
|
|
430
430
|
{
|
|
431
|
-
let
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
hEnd
|
|
431
|
+
let hm = "";
|
|
432
|
+
if (lines[0].match(/^---([^-].*)?$/) && !((_a = lines[1]) == null ? void 0 : _a.match(/^\s*$/))) {
|
|
433
|
+
let hEnd = 1;
|
|
434
|
+
while (hEnd < lines.length && !lines[hEnd].trimEnd().match(/^---$/))
|
|
435
|
+
hEnd++;
|
|
436
|
+
hm = lines.slice(1, hEnd).join("\n");
|
|
437
|
+
}
|
|
437
438
|
if (onHeadmatter) {
|
|
438
|
-
const o = (
|
|
439
|
+
const o = (_b = YAML.load(hm)) != null ? _b : {};
|
|
439
440
|
extensions = await onHeadmatter(o, extensions != null ? extensions : [], filepath);
|
|
440
441
|
}
|
|
441
442
|
}
|
|
@@ -466,8 +467,8 @@ async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
|
466
467
|
}
|
|
467
468
|
if (start <= lines.length - 1)
|
|
468
469
|
await slice(lines.length);
|
|
469
|
-
const headmatter = ((
|
|
470
|
-
headmatter.title = headmatter.title || ((
|
|
470
|
+
const headmatter = ((_c = slides[0]) == null ? void 0 : _c.frontmatter) || {};
|
|
471
|
+
headmatter.title = headmatter.title || ((_d = slides[0]) == null ? void 0 : _d.title);
|
|
471
472
|
const config = resolveConfig(headmatter, themeMeta, filepath);
|
|
472
473
|
const features = detectFeatures(markdown);
|
|
473
474
|
return {
|
package/dist/core.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkC3OTKWGWjs = require('./chunk-C3OTKWGW.js');
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
@@ -31,4 +31,4 @@ var _chunk72T7ERBCjs = require('./chunk-72T7ERBC.js');
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
exports.detectFeatures =
|
|
34
|
+
exports.detectFeatures = _chunkC3OTKWGWjs.detectFeatures; exports.filterDisabled = _chunkC3OTKWGWjs.filterDisabled; exports.mergeFeatureFlags = _chunkC3OTKWGWjs.mergeFeatureFlags; exports.parse = _chunkC3OTKWGWjs.parse; exports.parseAspectRatio = _chunkC3OTKWGWjs.parseAspectRatio; exports.parseRangeString = _chunkC3OTKWGWjs.parseRangeString; exports.parseSlide = _chunkC3OTKWGWjs.parseSlide; exports.prettify = _chunkC3OTKWGWjs.prettify; exports.prettifySlide = _chunkC3OTKWGWjs.prettifySlide; exports.resolveConfig = _chunkC3OTKWGWjs.resolveConfig; exports.resolveFonts = _chunkC3OTKWGWjs.resolveFonts; exports.scanMonacoModules = _chunkC3OTKWGWjs.scanMonacoModules; exports.stringify = _chunkC3OTKWGWjs.stringify; exports.stringifySlide = _chunkC3OTKWGWjs.stringifySlide; exports.verifyConfig = _chunkC3OTKWGWjs.verifyConfig;
|
package/dist/core.mjs
CHANGED
package/dist/fs.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkC3OTKWGWjs = require('./chunk-C3OTKWGW.js');
|
|
18
18
|
|
|
19
19
|
// src/fs.ts
|
|
20
20
|
var _fs = require('fs');
|
|
@@ -27,11 +27,10 @@ async function load(filepath, themeMeta, content) {
|
|
|
27
27
|
const dir = _path.dirname.call(void 0, filepath);
|
|
28
28
|
const markdown = content != null ? content : await _fs.promises.readFile(filepath, "utf-8");
|
|
29
29
|
const preparserExtensions = [];
|
|
30
|
-
const data = await
|
|
31
|
-
var _a;
|
|
30
|
+
const data = await _chunkC3OTKWGWjs.parse.call(void 0, markdown, filepath, themeMeta, [], async (headmatter, exts, filepath2) => {
|
|
32
31
|
return [
|
|
33
32
|
...exts,
|
|
34
|
-
...preparserExtensionLoader ? await preparserExtensionLoader(
|
|
33
|
+
...preparserExtensionLoader ? await preparserExtensionLoader(headmatter, filepath2) : []
|
|
35
34
|
];
|
|
36
35
|
});
|
|
37
36
|
const entries = /* @__PURE__ */ new Set([
|
|
@@ -49,7 +48,7 @@ async function load(filepath, themeMeta, content) {
|
|
|
49
48
|
const srcExpression = baseSlide.frontmatter.src;
|
|
50
49
|
const path = _path.resolve.call(void 0, dir, srcExpression);
|
|
51
50
|
const raw = await _fs.promises.readFile(path, "utf-8");
|
|
52
|
-
const subSlides = await
|
|
51
|
+
const subSlides = await _chunkC3OTKWGWjs.parse.call(void 0, raw, path, themeMeta, preparserExtensions);
|
|
53
52
|
for (const [offset, subSlide] of subSlides.slides.entries()) {
|
|
54
53
|
const slide = { ...baseSlide };
|
|
55
54
|
slide.source = {
|
|
@@ -70,7 +69,7 @@ async function load(filepath, themeMeta, content) {
|
|
|
70
69
|
...baseSlideFrontMatterWithoutSrc,
|
|
71
70
|
srcSequence: `${baseSlide.frontmatter.srcSequence ? `${baseSlide.frontmatter.srcSequence},` : ""}${srcExpression}`
|
|
72
71
|
};
|
|
73
|
-
data.features =
|
|
72
|
+
data.features = _chunkC3OTKWGWjs.mergeFeatureFlags.call(void 0, data.features, _chunkC3OTKWGWjs.detectFeatures.call(void 0, raw));
|
|
74
73
|
entries.add(path);
|
|
75
74
|
data.slides.splice(iSlide + offset, 0, slide);
|
|
76
75
|
}
|
|
@@ -82,10 +81,10 @@ async function load(filepath, themeMeta, content) {
|
|
|
82
81
|
}
|
|
83
82
|
async function save(data, filepath) {
|
|
84
83
|
filepath = filepath || data.filepath;
|
|
85
|
-
await _fs.promises.writeFile(filepath,
|
|
84
|
+
await _fs.promises.writeFile(filepath, _chunkC3OTKWGWjs.stringify.call(void 0, data), "utf-8");
|
|
86
85
|
}
|
|
87
86
|
async function saveExternalSlide(slide) {
|
|
88
|
-
await _fs.promises.writeFile(slide.filepath,
|
|
87
|
+
await _fs.promises.writeFile(slide.filepath, _chunkC3OTKWGWjs.stringifySlide.call(void 0, slide), "utf-8");
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
|
|
@@ -107,4 +106,4 @@ async function saveExternalSlide(slide) {
|
|
|
107
106
|
|
|
108
107
|
|
|
109
108
|
|
|
110
|
-
exports.detectFeatures =
|
|
109
|
+
exports.detectFeatures = _chunkC3OTKWGWjs.detectFeatures; exports.filterDisabled = _chunkC3OTKWGWjs.filterDisabled; exports.injectPreparserExtensionLoader = injectPreparserExtensionLoader; exports.load = load; exports.mergeFeatureFlags = _chunkC3OTKWGWjs.mergeFeatureFlags; exports.parse = _chunkC3OTKWGWjs.parse; exports.parseAspectRatio = _chunkC3OTKWGWjs.parseAspectRatio; exports.parseRangeString = _chunkC3OTKWGWjs.parseRangeString; exports.parseSlide = _chunkC3OTKWGWjs.parseSlide; exports.prettify = _chunkC3OTKWGWjs.prettify; exports.prettifySlide = _chunkC3OTKWGWjs.prettifySlide; exports.resolveConfig = _chunkC3OTKWGWjs.resolveConfig; exports.resolveFonts = _chunkC3OTKWGWjs.resolveFonts; exports.save = save; exports.saveExternalSlide = saveExternalSlide; exports.scanMonacoModules = _chunkC3OTKWGWjs.scanMonacoModules; exports.stringify = _chunkC3OTKWGWjs.stringify; exports.stringifySlide = _chunkC3OTKWGWjs.stringifySlide; exports.verifyConfig = _chunkC3OTKWGWjs.verifyConfig;
|
package/dist/fs.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
stringify,
|
|
15
15
|
stringifySlide,
|
|
16
16
|
verifyConfig
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-RQLJEQ6S.mjs";
|
|
18
18
|
|
|
19
19
|
// src/fs.ts
|
|
20
20
|
import { promises as fs } from "fs";
|
|
@@ -28,10 +28,9 @@ async function load(filepath, themeMeta, content) {
|
|
|
28
28
|
const markdown = content != null ? content : await fs.readFile(filepath, "utf-8");
|
|
29
29
|
const preparserExtensions = [];
|
|
30
30
|
const data = await parse(markdown, filepath, themeMeta, [], async (headmatter, exts, filepath2) => {
|
|
31
|
-
var _a;
|
|
32
31
|
return [
|
|
33
32
|
...exts,
|
|
34
|
-
...preparserExtensionLoader ? await preparserExtensionLoader(
|
|
33
|
+
...preparserExtensionLoader ? await preparserExtensionLoader(headmatter, filepath2) : []
|
|
35
34
|
];
|
|
36
35
|
});
|
|
37
36
|
const entries = /* @__PURE__ */ new Set([
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkC3OTKWGWjs = require('./chunk-C3OTKWGW.js');
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
@@ -31,4 +31,4 @@ var _chunk72T7ERBCjs = require('./chunk-72T7ERBC.js');
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
exports.detectFeatures =
|
|
34
|
+
exports.detectFeatures = _chunkC3OTKWGWjs.detectFeatures; exports.filterDisabled = _chunkC3OTKWGWjs.filterDisabled; exports.mergeFeatureFlags = _chunkC3OTKWGWjs.mergeFeatureFlags; exports.parse = _chunkC3OTKWGWjs.parse; exports.parseAspectRatio = _chunkC3OTKWGWjs.parseAspectRatio; exports.parseRangeString = _chunkC3OTKWGWjs.parseRangeString; exports.parseSlide = _chunkC3OTKWGWjs.parseSlide; exports.prettify = _chunkC3OTKWGWjs.prettify; exports.prettifySlide = _chunkC3OTKWGWjs.prettifySlide; exports.resolveConfig = _chunkC3OTKWGWjs.resolveConfig; exports.resolveFonts = _chunkC3OTKWGWjs.resolveFonts; exports.scanMonacoModules = _chunkC3OTKWGWjs.scanMonacoModules; exports.stringify = _chunkC3OTKWGWjs.stringify; exports.stringifySlide = _chunkC3OTKWGWjs.stringifySlide; exports.verifyConfig = _chunkC3OTKWGWjs.verifyConfig;
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
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": ">=14.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
42
|
+
"js-yaml": "^4.1.0",
|
|
43
|
+
"@slidev/types": "0.38.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "rimraf dist && tsup src/index.ts src/core.ts src/fs.ts --format cjs,esm --dts --splitting --no-shims",
|