@slidev/parser 0.42.11 → 0.43.0-beta.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-SV3LMBB2.mjs → chunk-KXG3JC7K.mjs} +31 -69
- package/dist/{chunk-GA7DXWKM.js → chunk-V6OICC7O.js} +32 -70
- package/dist/core.js +2 -2
- package/dist/core.mjs +1 -1
- package/dist/fs.js +9 -10
- package/dist/fs.mjs +4 -5
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
var __accessCheck = (obj, member, msg) => {
|
|
2
|
-
if (!member.has(obj))
|
|
3
|
-
throw TypeError("Cannot " + msg);
|
|
4
|
-
};
|
|
5
|
-
var __privateGet = (obj, member, getter) => {
|
|
6
|
-
__accessCheck(obj, member, "read from private field");
|
|
7
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
-
};
|
|
9
|
-
var __privateAdd = (obj, member, value) => {
|
|
10
|
-
if (member.has(obj))
|
|
11
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
-
};
|
|
14
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
-
__accessCheck(obj, member, "write to private field");
|
|
16
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
-
return value;
|
|
18
|
-
};
|
|
19
|
-
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
20
|
-
set _(value) {
|
|
21
|
-
__privateSet(obj, member, value, setter);
|
|
22
|
-
},
|
|
23
|
-
get _() {
|
|
24
|
-
return __privateGet(obj, member, getter);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
1
|
// src/core.ts
|
|
29
2
|
import YAML from "js-yaml";
|
|
30
3
|
|
|
@@ -74,53 +47,49 @@ var Node = class {
|
|
|
74
47
|
this.value = value;
|
|
75
48
|
}
|
|
76
49
|
};
|
|
77
|
-
var _head, _tail, _size;
|
|
78
50
|
var Queue = class {
|
|
51
|
+
#head;
|
|
52
|
+
#tail;
|
|
53
|
+
#size;
|
|
79
54
|
constructor() {
|
|
80
|
-
__privateAdd(this, _head, void 0);
|
|
81
|
-
__privateAdd(this, _tail, void 0);
|
|
82
|
-
__privateAdd(this, _size, void 0);
|
|
83
55
|
this.clear();
|
|
84
56
|
}
|
|
85
57
|
enqueue(value) {
|
|
86
58
|
const node = new Node(value);
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
59
|
+
if (this.#head) {
|
|
60
|
+
this.#tail.next = node;
|
|
61
|
+
this.#tail = node;
|
|
90
62
|
} else {
|
|
91
|
-
|
|
92
|
-
|
|
63
|
+
this.#head = node;
|
|
64
|
+
this.#tail = node;
|
|
93
65
|
}
|
|
94
|
-
|
|
66
|
+
this.#size++;
|
|
95
67
|
}
|
|
96
68
|
dequeue() {
|
|
97
|
-
const current =
|
|
69
|
+
const current = this.#head;
|
|
98
70
|
if (!current) {
|
|
99
71
|
return;
|
|
100
72
|
}
|
|
101
|
-
|
|
102
|
-
|
|
73
|
+
this.#head = this.#head.next;
|
|
74
|
+
this.#size--;
|
|
103
75
|
return current.value;
|
|
104
76
|
}
|
|
105
77
|
clear() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
78
|
+
this.#head = void 0;
|
|
79
|
+
this.#tail = void 0;
|
|
80
|
+
this.#size = 0;
|
|
109
81
|
}
|
|
110
82
|
get size() {
|
|
111
|
-
return
|
|
83
|
+
return this.#size;
|
|
112
84
|
}
|
|
113
85
|
*[Symbol.iterator]() {
|
|
114
|
-
let current =
|
|
86
|
+
let current = this.#head;
|
|
115
87
|
while (current) {
|
|
116
88
|
yield current.value;
|
|
117
89
|
current = current.next;
|
|
118
90
|
}
|
|
119
91
|
}
|
|
120
92
|
};
|
|
121
|
-
_head = new WeakMap();
|
|
122
|
-
_tail = new WeakMap();
|
|
123
|
-
_size = new WeakMap();
|
|
124
93
|
var VOID = Symbol("p-void");
|
|
125
94
|
|
|
126
95
|
// src/utils.ts
|
|
@@ -187,7 +156,6 @@ function getDefaultConfig() {
|
|
|
187
156
|
};
|
|
188
157
|
}
|
|
189
158
|
function resolveConfig(headmatter, themeMeta = {}, filepath, verify = false) {
|
|
190
|
-
var _a, _b, _c, _d;
|
|
191
159
|
const themeHightlighter = ["prism", "shiki"].includes(themeMeta.highlighter || "") ? themeMeta.highlighter : void 0;
|
|
192
160
|
const themeColorSchema = ["light", "dark"].includes(themeMeta.colorSchema || "") ? themeMeta.colorSchema : void 0;
|
|
193
161
|
const defaultConfig = getDefaultConfig();
|
|
@@ -199,15 +167,15 @@ function resolveConfig(headmatter, themeMeta = {}, filepath, verify = false) {
|
|
|
199
167
|
...headmatter.config,
|
|
200
168
|
...headmatter,
|
|
201
169
|
fonts: resolveFonts({
|
|
202
|
-
...
|
|
203
|
-
...
|
|
204
|
-
...headmatter
|
|
170
|
+
...themeMeta.defaults?.fonts,
|
|
171
|
+
...headmatter.config?.fonts,
|
|
172
|
+
...headmatter?.fonts
|
|
205
173
|
}),
|
|
206
174
|
drawings: resolveDrawings(headmatter.drawings, filepath),
|
|
207
175
|
htmlAttrs: {
|
|
208
|
-
...
|
|
209
|
-
...
|
|
210
|
-
...headmatter
|
|
176
|
+
...themeMeta.defaults?.htmlAttrs,
|
|
177
|
+
...headmatter.config?.htmlAttrs,
|
|
178
|
+
...headmatter?.htmlAttrs
|
|
211
179
|
}
|
|
212
180
|
};
|
|
213
181
|
if (config.colorSchema !== "dark" && config.colorSchema !== "light")
|
|
@@ -301,14 +269,13 @@ function resolveFonts(fonts = {}) {
|
|
|
301
269
|
};
|
|
302
270
|
}
|
|
303
271
|
function resolveDrawings(options = {}, filepath) {
|
|
304
|
-
var _a;
|
|
305
272
|
const {
|
|
306
273
|
enabled = true,
|
|
307
274
|
persist = false,
|
|
308
275
|
presenterOnly = false,
|
|
309
276
|
syncAll = true
|
|
310
277
|
} = options;
|
|
311
|
-
const persistPath = typeof persist === "string" ? persist : persist ? `.slidev/drawings${filepath ? `/${
|
|
278
|
+
const persistPath = typeof persist === "string" ? persist : persist ? `.slidev/drawings${filepath ? `/${filepath.match(/([^\\\/]+?)(\.\w+)?$/)?.[1]}` : ""}` : false;
|
|
312
279
|
return {
|
|
313
280
|
enabled,
|
|
314
281
|
persist: persistPath,
|
|
@@ -323,10 +290,7 @@ function stringify(data) {
|
|
|
323
290
|
`;
|
|
324
291
|
}
|
|
325
292
|
function filterDisabled(data) {
|
|
326
|
-
data.slides = data.slides.filter((i) =>
|
|
327
|
-
var _a;
|
|
328
|
-
return !((_a = i.frontmatter) == null ? void 0 : _a.disabled);
|
|
329
|
-
});
|
|
293
|
+
data.slides = data.slides.filter((i) => !i.frontmatter?.disabled);
|
|
330
294
|
return data;
|
|
331
295
|
}
|
|
332
296
|
function stringifySlide(data, idx = 0) {
|
|
@@ -380,7 +344,6 @@ function detectFeatures(code) {
|
|
|
380
344
|
};
|
|
381
345
|
}
|
|
382
346
|
function parseSlide(raw) {
|
|
383
|
-
var _a, _b;
|
|
384
347
|
const result = matter(raw);
|
|
385
348
|
let note;
|
|
386
349
|
const frontmatter = result.data || {};
|
|
@@ -399,8 +362,8 @@ function parseSlide(raw) {
|
|
|
399
362
|
title = frontmatter.title || frontmatter.name;
|
|
400
363
|
} else {
|
|
401
364
|
const match = content.match(/^(#+) (.*)$/m);
|
|
402
|
-
title =
|
|
403
|
-
level =
|
|
365
|
+
title = match?.[2]?.trim();
|
|
366
|
+
level = match?.[1]?.length;
|
|
404
367
|
}
|
|
405
368
|
if (frontmatter.level)
|
|
406
369
|
level = frontmatter.level || 1;
|
|
@@ -414,7 +377,6 @@ function parseSlide(raw) {
|
|
|
414
377
|
};
|
|
415
378
|
}
|
|
416
379
|
async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
417
|
-
var _a, _b, _c;
|
|
418
380
|
const lines = markdown.split(/\r?\n/g);
|
|
419
381
|
const slides = [];
|
|
420
382
|
let start = 0;
|
|
@@ -442,7 +404,7 @@ async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
|
442
404
|
}
|
|
443
405
|
{
|
|
444
406
|
let hm = "";
|
|
445
|
-
if (lines[0].match(/^---([^-].*)?$/) && !
|
|
407
|
+
if (lines[0].match(/^---([^-].*)?$/) && !lines[1]?.match(/^\s*$/)) {
|
|
446
408
|
let hEnd = 1;
|
|
447
409
|
while (hEnd < lines.length && !lines[hEnd].trimEnd().match(/^---$/))
|
|
448
410
|
hEnd++;
|
|
@@ -464,7 +426,7 @@ async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
|
464
426
|
if (line.match(/^---+/)) {
|
|
465
427
|
await slice(i);
|
|
466
428
|
const next = lines[i + 1];
|
|
467
|
-
if (line.match(/^---([^-].*)?$/) && !
|
|
429
|
+
if (line.match(/^---([^-].*)?$/) && !next?.match(/^\s*$/)) {
|
|
468
430
|
start = i;
|
|
469
431
|
for (i += 1; i < lines.length; i++) {
|
|
470
432
|
if (lines[i].trimEnd().match(/^---$/))
|
|
@@ -480,8 +442,8 @@ async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
|
480
442
|
}
|
|
481
443
|
if (start <= lines.length - 1)
|
|
482
444
|
await slice(lines.length);
|
|
483
|
-
const headmatter =
|
|
484
|
-
headmatter.title = headmatter.title ||
|
|
445
|
+
const headmatter = slides[0]?.frontmatter || {};
|
|
446
|
+
headmatter.title = headmatter.title || slides[0]?.title;
|
|
485
447
|
const config = resolveConfig(headmatter, themeMeta, filepath);
|
|
486
448
|
const features = detectFeatures(markdown);
|
|
487
449
|
return {
|
|
@@ -1,31 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
-
if (!member.has(obj))
|
|
3
|
-
throw TypeError("Cannot " + msg);
|
|
4
|
-
};
|
|
5
|
-
var __privateGet = (obj, member, getter) => {
|
|
6
|
-
__accessCheck(obj, member, "read from private field");
|
|
7
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
-
};
|
|
9
|
-
var __privateAdd = (obj, member, value) => {
|
|
10
|
-
if (member.has(obj))
|
|
11
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
-
};
|
|
14
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
-
__accessCheck(obj, member, "write to private field");
|
|
16
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
-
return value;
|
|
18
|
-
};
|
|
19
|
-
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
20
|
-
set _(value) {
|
|
21
|
-
__privateSet(obj, member, value, setter);
|
|
22
|
-
},
|
|
23
|
-
get _() {
|
|
24
|
-
return __privateGet(obj, member, getter);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// src/core.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/core.ts
|
|
29
2
|
var _jsyaml = require('js-yaml'); var _jsyaml2 = _interopRequireDefault(_jsyaml);
|
|
30
3
|
|
|
31
4
|
// ../../node_modules/.pnpm/@antfu+utils@0.7.6/node_modules/@antfu/utils/dist/index.mjs
|
|
@@ -74,53 +47,49 @@ var Node = class {
|
|
|
74
47
|
this.value = value;
|
|
75
48
|
}
|
|
76
49
|
};
|
|
77
|
-
var _head, _tail, _size;
|
|
78
50
|
var Queue = class {
|
|
51
|
+
#head;
|
|
52
|
+
#tail;
|
|
53
|
+
#size;
|
|
79
54
|
constructor() {
|
|
80
|
-
__privateAdd(this, _head, void 0);
|
|
81
|
-
__privateAdd(this, _tail, void 0);
|
|
82
|
-
__privateAdd(this, _size, void 0);
|
|
83
55
|
this.clear();
|
|
84
56
|
}
|
|
85
57
|
enqueue(value) {
|
|
86
58
|
const node = new Node(value);
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
59
|
+
if (this.#head) {
|
|
60
|
+
this.#tail.next = node;
|
|
61
|
+
this.#tail = node;
|
|
90
62
|
} else {
|
|
91
|
-
|
|
92
|
-
|
|
63
|
+
this.#head = node;
|
|
64
|
+
this.#tail = node;
|
|
93
65
|
}
|
|
94
|
-
|
|
66
|
+
this.#size++;
|
|
95
67
|
}
|
|
96
68
|
dequeue() {
|
|
97
|
-
const current =
|
|
69
|
+
const current = this.#head;
|
|
98
70
|
if (!current) {
|
|
99
71
|
return;
|
|
100
72
|
}
|
|
101
|
-
|
|
102
|
-
|
|
73
|
+
this.#head = this.#head.next;
|
|
74
|
+
this.#size--;
|
|
103
75
|
return current.value;
|
|
104
76
|
}
|
|
105
77
|
clear() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
78
|
+
this.#head = void 0;
|
|
79
|
+
this.#tail = void 0;
|
|
80
|
+
this.#size = 0;
|
|
109
81
|
}
|
|
110
82
|
get size() {
|
|
111
|
-
return
|
|
83
|
+
return this.#size;
|
|
112
84
|
}
|
|
113
85
|
*[Symbol.iterator]() {
|
|
114
|
-
let current =
|
|
86
|
+
let current = this.#head;
|
|
115
87
|
while (current) {
|
|
116
88
|
yield current.value;
|
|
117
89
|
current = current.next;
|
|
118
90
|
}
|
|
119
91
|
}
|
|
120
92
|
};
|
|
121
|
-
_head = new WeakMap();
|
|
122
|
-
_tail = new WeakMap();
|
|
123
|
-
_size = new WeakMap();
|
|
124
93
|
var VOID = Symbol("p-void");
|
|
125
94
|
|
|
126
95
|
// src/utils.ts
|
|
@@ -187,7 +156,6 @@ function getDefaultConfig() {
|
|
|
187
156
|
};
|
|
188
157
|
}
|
|
189
158
|
function resolveConfig(headmatter, themeMeta = {}, filepath, verify = false) {
|
|
190
|
-
var _a, _b, _c, _d;
|
|
191
159
|
const themeHightlighter = ["prism", "shiki"].includes(themeMeta.highlighter || "") ? themeMeta.highlighter : void 0;
|
|
192
160
|
const themeColorSchema = ["light", "dark"].includes(themeMeta.colorSchema || "") ? themeMeta.colorSchema : void 0;
|
|
193
161
|
const defaultConfig = getDefaultConfig();
|
|
@@ -199,15 +167,15 @@ function resolveConfig(headmatter, themeMeta = {}, filepath, verify = false) {
|
|
|
199
167
|
...headmatter.config,
|
|
200
168
|
...headmatter,
|
|
201
169
|
fonts: resolveFonts({
|
|
202
|
-
...(
|
|
203
|
-
...(
|
|
204
|
-
...headmatter
|
|
170
|
+
..._optionalChain([themeMeta, 'access', _2 => _2.defaults, 'optionalAccess', _3 => _3.fonts]),
|
|
171
|
+
..._optionalChain([headmatter, 'access', _4 => _4.config, 'optionalAccess', _5 => _5.fonts]),
|
|
172
|
+
..._optionalChain([headmatter, 'optionalAccess', _6 => _6.fonts])
|
|
205
173
|
}),
|
|
206
174
|
drawings: resolveDrawings(headmatter.drawings, filepath),
|
|
207
175
|
htmlAttrs: {
|
|
208
|
-
...(
|
|
209
|
-
...(
|
|
210
|
-
...headmatter
|
|
176
|
+
..._optionalChain([themeMeta, 'access', _7 => _7.defaults, 'optionalAccess', _8 => _8.htmlAttrs]),
|
|
177
|
+
..._optionalChain([headmatter, 'access', _9 => _9.config, 'optionalAccess', _10 => _10.htmlAttrs]),
|
|
178
|
+
..._optionalChain([headmatter, 'optionalAccess', _11 => _11.htmlAttrs])
|
|
211
179
|
}
|
|
212
180
|
};
|
|
213
181
|
if (config.colorSchema !== "dark" && config.colorSchema !== "light")
|
|
@@ -301,14 +269,13 @@ function resolveFonts(fonts = {}) {
|
|
|
301
269
|
};
|
|
302
270
|
}
|
|
303
271
|
function resolveDrawings(options = {}, filepath) {
|
|
304
|
-
var _a;
|
|
305
272
|
const {
|
|
306
273
|
enabled = true,
|
|
307
274
|
persist = false,
|
|
308
275
|
presenterOnly = false,
|
|
309
276
|
syncAll = true
|
|
310
277
|
} = options;
|
|
311
|
-
const persistPath = typeof persist === "string" ? persist : persist ? `.slidev/drawings${filepath ? `/${(
|
|
278
|
+
const persistPath = typeof persist === "string" ? persist : persist ? `.slidev/drawings${filepath ? `/${_optionalChain([filepath, 'access', _12 => _12.match, 'call', _13 => _13(/([^\\\/]+?)(\.\w+)?$/), 'optionalAccess', _14 => _14[1]])}` : ""}` : false;
|
|
312
279
|
return {
|
|
313
280
|
enabled,
|
|
314
281
|
persist: persistPath,
|
|
@@ -323,10 +290,7 @@ function stringify(data) {
|
|
|
323
290
|
`;
|
|
324
291
|
}
|
|
325
292
|
function filterDisabled(data) {
|
|
326
|
-
data.slides = data.slides.filter((i) =>
|
|
327
|
-
var _a;
|
|
328
|
-
return !((_a = i.frontmatter) == null ? void 0 : _a.disabled);
|
|
329
|
-
});
|
|
293
|
+
data.slides = data.slides.filter((i) => !_optionalChain([i, 'access', _15 => _15.frontmatter, 'optionalAccess', _16 => _16.disabled]));
|
|
330
294
|
return data;
|
|
331
295
|
}
|
|
332
296
|
function stringifySlide(data, idx = 0) {
|
|
@@ -380,7 +344,6 @@ function detectFeatures(code) {
|
|
|
380
344
|
};
|
|
381
345
|
}
|
|
382
346
|
function parseSlide(raw) {
|
|
383
|
-
var _a, _b;
|
|
384
347
|
const result = matter(raw);
|
|
385
348
|
let note;
|
|
386
349
|
const frontmatter = result.data || {};
|
|
@@ -399,8 +362,8 @@ function parseSlide(raw) {
|
|
|
399
362
|
title = frontmatter.title || frontmatter.name;
|
|
400
363
|
} else {
|
|
401
364
|
const match = content.match(/^(#+) (.*)$/m);
|
|
402
|
-
title = (
|
|
403
|
-
level = (
|
|
365
|
+
title = _optionalChain([match, 'optionalAccess', _17 => _17[2], 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]);
|
|
366
|
+
level = _optionalChain([match, 'optionalAccess', _20 => _20[1], 'optionalAccess', _21 => _21.length]);
|
|
404
367
|
}
|
|
405
368
|
if (frontmatter.level)
|
|
406
369
|
level = frontmatter.level || 1;
|
|
@@ -414,7 +377,6 @@ function parseSlide(raw) {
|
|
|
414
377
|
};
|
|
415
378
|
}
|
|
416
379
|
async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
417
|
-
var _a, _b, _c;
|
|
418
380
|
const lines = markdown.split(/\r?\n/g);
|
|
419
381
|
const slides = [];
|
|
420
382
|
let start = 0;
|
|
@@ -442,7 +404,7 @@ async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
|
442
404
|
}
|
|
443
405
|
{
|
|
444
406
|
let hm = "";
|
|
445
|
-
if (lines[0].match(/^---([^-].*)?$/) && !(
|
|
407
|
+
if (lines[0].match(/^---([^-].*)?$/) && !_optionalChain([lines, 'access', _22 => _22[1], 'optionalAccess', _23 => _23.match, 'call', _24 => _24(/^\s*$/)])) {
|
|
446
408
|
let hEnd = 1;
|
|
447
409
|
while (hEnd < lines.length && !lines[hEnd].trimEnd().match(/^---$/))
|
|
448
410
|
hEnd++;
|
|
@@ -464,7 +426,7 @@ async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
|
464
426
|
if (line.match(/^---+/)) {
|
|
465
427
|
await slice(i);
|
|
466
428
|
const next = lines[i + 1];
|
|
467
|
-
if (line.match(/^---([^-].*)?$/) && !(next
|
|
429
|
+
if (line.match(/^---([^-].*)?$/) && !_optionalChain([next, 'optionalAccess', _25 => _25.match, 'call', _26 => _26(/^\s*$/)])) {
|
|
468
430
|
start = i;
|
|
469
431
|
for (i += 1; i < lines.length; i++) {
|
|
470
432
|
if (lines[i].trimEnd().match(/^---$/))
|
|
@@ -480,8 +442,8 @@ async function parse(markdown, filepath, themeMeta, extensions, onHeadmatter) {
|
|
|
480
442
|
}
|
|
481
443
|
if (start <= lines.length - 1)
|
|
482
444
|
await slice(lines.length);
|
|
483
|
-
const headmatter = (
|
|
484
|
-
headmatter.title = headmatter.title || (
|
|
445
|
+
const headmatter = _optionalChain([slides, 'access', _27 => _27[0], 'optionalAccess', _28 => _28.frontmatter]) || {};
|
|
446
|
+
headmatter.title = headmatter.title || _optionalChain([slides, 'access', _29 => _29[0], 'optionalAccess', _30 => _30.title]);
|
|
485
447
|
const config = resolveConfig(headmatter, themeMeta, filepath);
|
|
486
448
|
const features = detectFeatures(markdown);
|
|
487
449
|
return {
|
package/dist/core.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkV6OICC7Ojs = require('./chunk-V6OICC7O.js');
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
@@ -33,4 +33,4 @@ var _chunkGA7DXWKMjs = require('./chunk-GA7DXWKM.js');
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
exports.detectFeatures =
|
|
36
|
+
exports.detectFeatures = _chunkV6OICC7Ojs.detectFeatures; exports.filterDisabled = _chunkV6OICC7Ojs.filterDisabled; exports.getDefaultConfig = _chunkV6OICC7Ojs.getDefaultConfig; exports.mergeFeatureFlags = _chunkV6OICC7Ojs.mergeFeatureFlags; exports.parse = _chunkV6OICC7Ojs.parse; exports.parseAspectRatio = _chunkV6OICC7Ojs.parseAspectRatio; exports.parseRangeString = _chunkV6OICC7Ojs.parseRangeString; exports.parseSlide = _chunkV6OICC7Ojs.parseSlide; exports.prettify = _chunkV6OICC7Ojs.prettify; exports.prettifySlide = _chunkV6OICC7Ojs.prettifySlide; exports.resolveConfig = _chunkV6OICC7Ojs.resolveConfig; exports.resolveFonts = _chunkV6OICC7Ojs.resolveFonts; exports.scanMonacoModules = _chunkV6OICC7Ojs.scanMonacoModules; exports.stringify = _chunkV6OICC7Ojs.stringify; exports.stringifySlide = _chunkV6OICC7Ojs.stringifySlide; exports.verifyConfig = _chunkV6OICC7Ojs.verifyConfig;
|
package/dist/core.mjs
CHANGED
package/dist/fs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkV6OICC7Ojs = require('./chunk-V6OICC7O.js');
|
|
19
19
|
|
|
20
20
|
// src/fs.ts
|
|
21
21
|
var _fs = require('fs');
|
|
@@ -25,11 +25,10 @@ function injectPreparserExtensionLoader(fn) {
|
|
|
25
25
|
preparserExtensionLoader = fn;
|
|
26
26
|
}
|
|
27
27
|
async function load(filepath, themeMeta, content) {
|
|
28
|
-
var _a;
|
|
29
28
|
const dir = _path.dirname.call(void 0, filepath);
|
|
30
29
|
const markdown = await _asyncNullishCoalesce(content, async () => ( await _fs.promises.readFile(filepath, "utf-8")));
|
|
31
30
|
const preparserExtensions = [];
|
|
32
|
-
const data = await
|
|
31
|
+
const data = await _chunkV6OICC7Ojs.parse.call(void 0, markdown, filepath, themeMeta, [], async (headmatter, exts, filepath2) => {
|
|
33
32
|
preparserExtensions.splice(
|
|
34
33
|
0,
|
|
35
34
|
preparserExtensions.length,
|
|
@@ -54,12 +53,12 @@ async function load(filepath, themeMeta, content) {
|
|
|
54
53
|
let path;
|
|
55
54
|
if (srcExpression.startsWith("/"))
|
|
56
55
|
path = _path.resolve.call(void 0, dir, srcExpression.substring(1));
|
|
57
|
-
else if ((
|
|
56
|
+
else if (_optionalChain([baseSlide, 'access', _ => _.source, 'optionalAccess', _2 => _2.filepath]))
|
|
58
57
|
path = _path.resolve.call(void 0, _path.dirname.call(void 0, baseSlide.source.filepath), srcExpression);
|
|
59
58
|
else
|
|
60
59
|
path = _path.resolve.call(void 0, dir, srcExpression);
|
|
61
60
|
const raw = await _fs.promises.readFile(path, "utf-8");
|
|
62
|
-
const subSlides = await
|
|
61
|
+
const subSlides = await _chunkV6OICC7Ojs.parse.call(void 0, raw, path, themeMeta, preparserExtensions);
|
|
63
62
|
for (const [offset, subSlide] of subSlides.slides.entries()) {
|
|
64
63
|
const slide = { ...baseSlide };
|
|
65
64
|
slide.source = {
|
|
@@ -80,7 +79,7 @@ async function load(filepath, themeMeta, content) {
|
|
|
80
79
|
...baseSlideFrontMatterWithoutSrc,
|
|
81
80
|
srcSequence: `${baseSlide.frontmatter.srcSequence ? `${baseSlide.frontmatter.srcSequence},` : ""}${srcExpression}`
|
|
82
81
|
};
|
|
83
|
-
data.features =
|
|
82
|
+
data.features = _chunkV6OICC7Ojs.mergeFeatureFlags.call(void 0, data.features, _chunkV6OICC7Ojs.detectFeatures.call(void 0, raw));
|
|
84
83
|
entries.add(path);
|
|
85
84
|
data.slides.splice(iSlide + offset, 0, slide);
|
|
86
85
|
}
|
|
@@ -92,10 +91,10 @@ async function load(filepath, themeMeta, content) {
|
|
|
92
91
|
}
|
|
93
92
|
async function save(data, filepath) {
|
|
94
93
|
filepath = filepath || data.filepath;
|
|
95
|
-
await _fs.promises.writeFile(filepath,
|
|
94
|
+
await _fs.promises.writeFile(filepath, _chunkV6OICC7Ojs.stringify.call(void 0, data), "utf-8");
|
|
96
95
|
}
|
|
97
96
|
async function saveExternalSlide(slide) {
|
|
98
|
-
await _fs.promises.writeFile(slide.filepath,
|
|
97
|
+
await _fs.promises.writeFile(slide.filepath, _chunkV6OICC7Ojs.stringifySlide.call(void 0, slide), "utf-8");
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
|
|
@@ -118,4 +117,4 @@ async function saveExternalSlide(slide) {
|
|
|
118
117
|
|
|
119
118
|
|
|
120
119
|
|
|
121
|
-
exports.detectFeatures =
|
|
120
|
+
exports.detectFeatures = _chunkV6OICC7Ojs.detectFeatures; exports.filterDisabled = _chunkV6OICC7Ojs.filterDisabled; exports.getDefaultConfig = _chunkV6OICC7Ojs.getDefaultConfig; exports.injectPreparserExtensionLoader = injectPreparserExtensionLoader; exports.load = load; exports.mergeFeatureFlags = _chunkV6OICC7Ojs.mergeFeatureFlags; exports.parse = _chunkV6OICC7Ojs.parse; exports.parseAspectRatio = _chunkV6OICC7Ojs.parseAspectRatio; exports.parseRangeString = _chunkV6OICC7Ojs.parseRangeString; exports.parseSlide = _chunkV6OICC7Ojs.parseSlide; exports.prettify = _chunkV6OICC7Ojs.prettify; exports.prettifySlide = _chunkV6OICC7Ojs.prettifySlide; exports.resolveConfig = _chunkV6OICC7Ojs.resolveConfig; exports.resolveFonts = _chunkV6OICC7Ojs.resolveFonts; exports.save = save; exports.saveExternalSlide = saveExternalSlide; exports.scanMonacoModules = _chunkV6OICC7Ojs.scanMonacoModules; exports.stringify = _chunkV6OICC7Ojs.stringify; exports.stringifySlide = _chunkV6OICC7Ojs.stringifySlide; exports.verifyConfig = _chunkV6OICC7Ojs.verifyConfig;
|
package/dist/fs.mjs
CHANGED
|
@@ -15,17 +15,16 @@ import {
|
|
|
15
15
|
stringify,
|
|
16
16
|
stringifySlide,
|
|
17
17
|
verifyConfig
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-KXG3JC7K.mjs";
|
|
19
19
|
|
|
20
20
|
// src/fs.ts
|
|
21
|
-
import { promises as fs } from "fs";
|
|
22
|
-
import { dirname, resolve } from "path";
|
|
21
|
+
import { promises as fs } from "node:fs";
|
|
22
|
+
import { dirname, resolve } from "node:path";
|
|
23
23
|
var preparserExtensionLoader = null;
|
|
24
24
|
function injectPreparserExtensionLoader(fn) {
|
|
25
25
|
preparserExtensionLoader = fn;
|
|
26
26
|
}
|
|
27
27
|
async function load(filepath, themeMeta, content) {
|
|
28
|
-
var _a;
|
|
29
28
|
const dir = dirname(filepath);
|
|
30
29
|
const markdown = content ?? await fs.readFile(filepath, "utf-8");
|
|
31
30
|
const preparserExtensions = [];
|
|
@@ -54,7 +53,7 @@ async function load(filepath, themeMeta, content) {
|
|
|
54
53
|
let path;
|
|
55
54
|
if (srcExpression.startsWith("/"))
|
|
56
55
|
path = resolve(dir, srcExpression.substring(1));
|
|
57
|
-
else if (
|
|
56
|
+
else if (baseSlide.source?.filepath)
|
|
58
57
|
path = resolve(dirname(baseSlide.source.filepath), srcExpression);
|
|
59
58
|
else
|
|
60
59
|
path = resolve(dir, srcExpression);
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkV6OICC7Ojs = require('./chunk-V6OICC7O.js');
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
@@ -33,4 +33,4 @@ var _chunkGA7DXWKMjs = require('./chunk-GA7DXWKM.js');
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
exports.detectFeatures =
|
|
36
|
+
exports.detectFeatures = _chunkV6OICC7Ojs.detectFeatures; exports.filterDisabled = _chunkV6OICC7Ojs.filterDisabled; exports.getDefaultConfig = _chunkV6OICC7Ojs.getDefaultConfig; exports.mergeFeatureFlags = _chunkV6OICC7Ojs.mergeFeatureFlags; exports.parse = _chunkV6OICC7Ojs.parse; exports.parseAspectRatio = _chunkV6OICC7Ojs.parseAspectRatio; exports.parseRangeString = _chunkV6OICC7Ojs.parseRangeString; exports.parseSlide = _chunkV6OICC7Ojs.parseSlide; exports.prettify = _chunkV6OICC7Ojs.prettify; exports.prettifySlide = _chunkV6OICC7Ojs.prettifySlide; exports.resolveConfig = _chunkV6OICC7Ojs.resolveConfig; exports.resolveFonts = _chunkV6OICC7Ojs.resolveFonts; exports.scanMonacoModules = _chunkV6OICC7Ojs.scanMonacoModules; exports.stringify = _chunkV6OICC7Ojs.stringify; exports.stringifySlide = _chunkV6OICC7Ojs.stringifySlide; exports.verifyConfig = _chunkV6OICC7Ojs.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.43.0-beta.0",
|
|
4
4
|
"description": "Markdown parser for Slidev",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"*.d.ts"
|
|
37
37
|
],
|
|
38
38
|
"engines": {
|
|
39
|
-
"node": ">=
|
|
39
|
+
"node": ">=18.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"js-yaml": "^4.1.0",
|
|
43
|
-
"@slidev/types": "0.
|
|
43
|
+
"@slidev/types": "0.43.0-beta.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "rimraf dist && tsup src/index.ts src/core.ts src/fs.ts",
|