@slidev/parser 0.27.19 → 0.28.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-4LEQMYU6.mjs → chunk-HINA34KW.mjs} +16 -5
- package/dist/{chunk-VFP6MEJG.js → chunk-WBX4FRCI.js} +16 -5
- package/dist/core.js +2 -2
- package/dist/core.mjs +1 -1
- package/dist/fs.js +10 -10
- package/dist/fs.mjs +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/fs.d.ts +1 -0
- package/package.json +11 -7
|
@@ -21,7 +21,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21
21
|
// src/core.ts
|
|
22
22
|
import YAML from "js-yaml";
|
|
23
23
|
|
|
24
|
-
// ../../node_modules/.pnpm/@antfu+utils@0.
|
|
24
|
+
// ../../node_modules/.pnpm/@antfu+utils@0.4.0/node_modules/@antfu/utils/dist/index.mjs
|
|
25
25
|
function toArray(array) {
|
|
26
26
|
array = array || [];
|
|
27
27
|
if (Array.isArray(array))
|
|
@@ -48,6 +48,7 @@ function range(...args) {
|
|
|
48
48
|
}
|
|
49
49
|
return arr;
|
|
50
50
|
}
|
|
51
|
+
var toString = (v) => Object.prototype.toString.call(v);
|
|
51
52
|
function notNullish(v) {
|
|
52
53
|
return v != null;
|
|
53
54
|
}
|
|
@@ -55,7 +56,7 @@ function isTruthy(v) {
|
|
|
55
56
|
return Boolean(v);
|
|
56
57
|
}
|
|
57
58
|
var isNumber = (val) => typeof val === "number";
|
|
58
|
-
var isObject = (val) => toString
|
|
59
|
+
var isObject = (val) => toString(val) === "[object Object]";
|
|
59
60
|
function objectMap(obj, fn) {
|
|
60
61
|
return Object.fromEntries(Object.entries(obj).map(([k, v]) => fn(k, v)).filter(notNullish));
|
|
61
62
|
}
|
|
@@ -287,10 +288,20 @@ function parseSlide(raw) {
|
|
|
287
288
|
content = content.slice(0, last.index).trim();
|
|
288
289
|
}
|
|
289
290
|
}
|
|
290
|
-
|
|
291
|
+
let title;
|
|
292
|
+
let level;
|
|
293
|
+
if (frontmatter.title || frontmatter.name) {
|
|
294
|
+
title = frontmatter.title || frontmatter.name;
|
|
295
|
+
level = frontmatter.level || 1;
|
|
296
|
+
} else {
|
|
297
|
+
const match = content.match(/^(#+) (.*)$/m);
|
|
298
|
+
title = (_a = match == null ? void 0 : match[2]) == null ? void 0 : _a.trim();
|
|
299
|
+
level = (_b = match == null ? void 0 : match[1]) == null ? void 0 : _b.length;
|
|
300
|
+
}
|
|
291
301
|
return {
|
|
292
302
|
raw,
|
|
293
303
|
title,
|
|
304
|
+
level,
|
|
294
305
|
content,
|
|
295
306
|
frontmatter,
|
|
296
307
|
note
|
|
@@ -313,14 +324,14 @@ function parse(markdown, filepath, themeMeta) {
|
|
|
313
324
|
start = end + 1;
|
|
314
325
|
}
|
|
315
326
|
for (let i = 0; i < lines.length; i++) {
|
|
316
|
-
const line = lines[i].
|
|
327
|
+
const line = lines[i].trimEnd();
|
|
317
328
|
if (line.match(/^---+/)) {
|
|
318
329
|
slice(i);
|
|
319
330
|
const next = lines[i + 1];
|
|
320
331
|
if (line.match(/^---([^-].*)?$/) && !(next == null ? void 0 : next.match(/^\s*$/))) {
|
|
321
332
|
start = i;
|
|
322
333
|
for (i += 1; i < lines.length; i++) {
|
|
323
|
-
if (lines[i].
|
|
334
|
+
if (lines[i].trimEnd().match(/^---$/))
|
|
324
335
|
break;
|
|
325
336
|
}
|
|
326
337
|
}
|
|
@@ -21,7 +21,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
21
21
|
// src/core.ts
|
|
22
22
|
var _jsyaml = require('js-yaml'); var _jsyaml2 = _interopRequireDefault(_jsyaml);
|
|
23
23
|
|
|
24
|
-
// ../../node_modules/.pnpm/@antfu+utils@0.
|
|
24
|
+
// ../../node_modules/.pnpm/@antfu+utils@0.4.0/node_modules/@antfu/utils/dist/index.mjs
|
|
25
25
|
function toArray(array) {
|
|
26
26
|
array = array || [];
|
|
27
27
|
if (Array.isArray(array))
|
|
@@ -48,6 +48,7 @@ function range(...args) {
|
|
|
48
48
|
}
|
|
49
49
|
return arr;
|
|
50
50
|
}
|
|
51
|
+
var toString = (v) => Object.prototype.toString.call(v);
|
|
51
52
|
function notNullish(v) {
|
|
52
53
|
return v != null;
|
|
53
54
|
}
|
|
@@ -55,7 +56,7 @@ function isTruthy(v) {
|
|
|
55
56
|
return Boolean(v);
|
|
56
57
|
}
|
|
57
58
|
var isNumber = (val) => typeof val === "number";
|
|
58
|
-
var isObject = (val) => toString
|
|
59
|
+
var isObject = (val) => toString(val) === "[object Object]";
|
|
59
60
|
function objectMap(obj, fn) {
|
|
60
61
|
return Object.fromEntries(Object.entries(obj).map(([k, v]) => fn(k, v)).filter(notNullish));
|
|
61
62
|
}
|
|
@@ -287,10 +288,20 @@ function parseSlide(raw) {
|
|
|
287
288
|
content = content.slice(0, last.index).trim();
|
|
288
289
|
}
|
|
289
290
|
}
|
|
290
|
-
|
|
291
|
+
let title;
|
|
292
|
+
let level;
|
|
293
|
+
if (frontmatter.title || frontmatter.name) {
|
|
294
|
+
title = frontmatter.title || frontmatter.name;
|
|
295
|
+
level = frontmatter.level || 1;
|
|
296
|
+
} else {
|
|
297
|
+
const match = content.match(/^(#+) (.*)$/m);
|
|
298
|
+
title = (_a = match == null ? void 0 : match[2]) == null ? void 0 : _a.trim();
|
|
299
|
+
level = (_b = match == null ? void 0 : match[1]) == null ? void 0 : _b.length;
|
|
300
|
+
}
|
|
291
301
|
return {
|
|
292
302
|
raw,
|
|
293
303
|
title,
|
|
304
|
+
level,
|
|
294
305
|
content,
|
|
295
306
|
frontmatter,
|
|
296
307
|
note
|
|
@@ -313,14 +324,14 @@ function parse(markdown, filepath, themeMeta) {
|
|
|
313
324
|
start = end + 1;
|
|
314
325
|
}
|
|
315
326
|
for (let i = 0; i < lines.length; i++) {
|
|
316
|
-
const line = lines[i].
|
|
327
|
+
const line = lines[i].trimEnd();
|
|
317
328
|
if (line.match(/^---+/)) {
|
|
318
329
|
slice(i);
|
|
319
330
|
const next = lines[i + 1];
|
|
320
331
|
if (line.match(/^---([^-].*)?$/) && !(next == null ? void 0 : next.match(/^\s*$/))) {
|
|
321
332
|
start = i;
|
|
322
333
|
for (i += 1; i < lines.length; i++) {
|
|
323
|
-
if (lines[i].
|
|
334
|
+
if (lines[i].trimEnd().match(/^---$/))
|
|
324
335
|
break;
|
|
325
336
|
}
|
|
326
337
|
}
|
package/dist/core.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkWBX4FRCIjs = require('./chunk-WBX4FRCI.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -29,4 +29,4 @@ var _chunkVFP6MEJGjs = require('./chunk-VFP6MEJG.js');
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
exports.detectFeatures =
|
|
32
|
+
exports.detectFeatures = _chunkWBX4FRCIjs.detectFeatures; exports.filterDisabled = _chunkWBX4FRCIjs.filterDisabled; exports.mergeFeatureFlags = _chunkWBX4FRCIjs.mergeFeatureFlags; exports.parse = _chunkWBX4FRCIjs.parse; exports.parseAspectRatio = _chunkWBX4FRCIjs.parseAspectRatio; exports.parseRangeString = _chunkWBX4FRCIjs.parseRangeString; exports.parseSlide = _chunkWBX4FRCIjs.parseSlide; exports.prettify = _chunkWBX4FRCIjs.prettify; exports.prettifySlide = _chunkWBX4FRCIjs.prettifySlide; exports.resolveConfig = _chunkWBX4FRCIjs.resolveConfig; exports.resolveFonts = _chunkWBX4FRCIjs.resolveFonts; exports.scanMonacoModules = _chunkWBX4FRCIjs.scanMonacoModules; exports.stringify = _chunkWBX4FRCIjs.stringify; exports.stringifySlide = _chunkWBX4FRCIjs.stringifySlide;
|
package/dist/core.mjs
CHANGED
package/dist/fs.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkWBX4FRCIjs = require('./chunk-WBX4FRCI.js');
|
|
18
18
|
|
|
19
19
|
// src/fs.ts
|
|
20
20
|
var _fs = require('fs');
|
|
@@ -22,7 +22,7 @@ var _path = require('path');
|
|
|
22
22
|
async function load(filepath, themeMeta, content) {
|
|
23
23
|
const dir = _path.dirname.call(void 0, filepath);
|
|
24
24
|
const markdown = content != null ? content : await _fs.promises.readFile(filepath, "utf-8");
|
|
25
|
-
const data =
|
|
25
|
+
const data = _chunkWBX4FRCIjs.parse.call(void 0, markdown, filepath, themeMeta);
|
|
26
26
|
const entries = /* @__PURE__ */ new Set([
|
|
27
27
|
filepath
|
|
28
28
|
]);
|
|
@@ -31,15 +31,15 @@ async function load(filepath, themeMeta, content) {
|
|
|
31
31
|
continue;
|
|
32
32
|
const path = _path.resolve.call(void 0, dir, slide.frontmatter.src);
|
|
33
33
|
const raw = await _fs.promises.readFile(path, "utf-8");
|
|
34
|
-
const source =
|
|
35
|
-
const inline =
|
|
36
|
-
slide.source =
|
|
34
|
+
const source = _chunkWBX4FRCIjs.parseSlide.call(void 0, raw);
|
|
35
|
+
const inline = _chunkWBX4FRCIjs.__spreadValues.call(void 0, {}, slide);
|
|
36
|
+
slide.source = _chunkWBX4FRCIjs.__spreadValues.call(void 0, {
|
|
37
37
|
filepath: path
|
|
38
38
|
}, source);
|
|
39
39
|
slide.inline = inline;
|
|
40
40
|
Object.assign(slide, slide.source);
|
|
41
|
-
slide.frontmatter =
|
|
42
|
-
data.features =
|
|
41
|
+
slide.frontmatter = _chunkWBX4FRCIjs.__spreadValues.call(void 0, _chunkWBX4FRCIjs.__spreadValues.call(void 0, {}, slide.source.frontmatter), inline.frontmatter);
|
|
42
|
+
data.features = _chunkWBX4FRCIjs.mergeFeatureFlags.call(void 0, data.features, _chunkWBX4FRCIjs.detectFeatures.call(void 0, raw));
|
|
43
43
|
entries.add(path);
|
|
44
44
|
}
|
|
45
45
|
data.entries = Array.from(entries);
|
|
@@ -47,10 +47,10 @@ async function load(filepath, themeMeta, content) {
|
|
|
47
47
|
}
|
|
48
48
|
async function save(data, filepath) {
|
|
49
49
|
filepath = filepath || data.filepath;
|
|
50
|
-
await _fs.promises.writeFile(filepath,
|
|
50
|
+
await _fs.promises.writeFile(filepath, _chunkWBX4FRCIjs.stringify.call(void 0, data), "utf-8");
|
|
51
51
|
}
|
|
52
52
|
async function saveExternalSlide(slide) {
|
|
53
|
-
await _fs.promises.writeFile(slide.filepath,
|
|
53
|
+
await _fs.promises.writeFile(slide.filepath, _chunkWBX4FRCIjs.stringifySlide.call(void 0, slide), "utf-8");
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
|
|
@@ -70,4 +70,4 @@ async function saveExternalSlide(slide) {
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
exports.detectFeatures =
|
|
73
|
+
exports.detectFeatures = _chunkWBX4FRCIjs.detectFeatures; exports.filterDisabled = _chunkWBX4FRCIjs.filterDisabled; exports.load = load; exports.mergeFeatureFlags = _chunkWBX4FRCIjs.mergeFeatureFlags; exports.parse = _chunkWBX4FRCIjs.parse; exports.parseAspectRatio = _chunkWBX4FRCIjs.parseAspectRatio; exports.parseRangeString = _chunkWBX4FRCIjs.parseRangeString; exports.parseSlide = _chunkWBX4FRCIjs.parseSlide; exports.prettify = _chunkWBX4FRCIjs.prettify; exports.prettifySlide = _chunkWBX4FRCIjs.prettifySlide; exports.resolveConfig = _chunkWBX4FRCIjs.resolveConfig; exports.resolveFonts = _chunkWBX4FRCIjs.resolveFonts; exports.save = save; exports.saveExternalSlide = saveExternalSlide; exports.scanMonacoModules = _chunkWBX4FRCIjs.scanMonacoModules; exports.stringify = _chunkWBX4FRCIjs.stringify; exports.stringifySlide = _chunkWBX4FRCIjs.stringifySlide;
|
package/dist/fs.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkWBX4FRCIjs = require('./chunk-WBX4FRCI.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -29,4 +29,4 @@ var _chunkVFP6MEJGjs = require('./chunk-VFP6MEJG.js');
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
exports.detectFeatures =
|
|
32
|
+
exports.detectFeatures = _chunkWBX4FRCIjs.detectFeatures; exports.filterDisabled = _chunkWBX4FRCIjs.filterDisabled; exports.mergeFeatureFlags = _chunkWBX4FRCIjs.mergeFeatureFlags; exports.parse = _chunkWBX4FRCIjs.parse; exports.parseAspectRatio = _chunkWBX4FRCIjs.parseAspectRatio; exports.parseRangeString = _chunkWBX4FRCIjs.parseRangeString; exports.parseSlide = _chunkWBX4FRCIjs.parseSlide; exports.prettify = _chunkWBX4FRCIjs.prettify; exports.prettifySlide = _chunkWBX4FRCIjs.prettifySlide; exports.resolveConfig = _chunkWBX4FRCIjs.resolveConfig; exports.resolveFonts = _chunkWBX4FRCIjs.resolveFonts; exports.scanMonacoModules = _chunkWBX4FRCIjs.scanMonacoModules; exports.stringify = _chunkWBX4FRCIjs.stringify; exports.stringifySlide = _chunkWBX4FRCIjs.stringifySlide;
|
package/dist/index.mjs
CHANGED
package/fs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/fs'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.2",
|
|
4
4
|
"description": "Markdown parser for Slidev",
|
|
5
5
|
"homepage": "https://sli.dev",
|
|
6
6
|
"bugs": "https://github.com/slidevjs/slidev/issues",
|
|
@@ -13,27 +13,30 @@
|
|
|
13
13
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
|
-
"
|
|
16
|
+
"*.d.ts"
|
|
17
17
|
],
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"import": "./dist/index.mjs",
|
|
21
|
-
"require": "./dist/index.js"
|
|
21
|
+
"require": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts"
|
|
22
23
|
},
|
|
23
24
|
"./core": {
|
|
24
25
|
"import": "./dist/core.mjs",
|
|
25
|
-
"require": "./dist/core.js"
|
|
26
|
+
"require": "./dist/core.js",
|
|
27
|
+
"types": "./dist/core.d.ts"
|
|
26
28
|
},
|
|
27
29
|
"./fs": {
|
|
28
30
|
"import": "./dist/fs.mjs",
|
|
29
|
-
"require": "./dist/fs.js"
|
|
31
|
+
"require": "./dist/fs.js",
|
|
32
|
+
"types": "./fs.d.ts"
|
|
30
33
|
}
|
|
31
34
|
},
|
|
32
35
|
"main": "dist/index.js",
|
|
33
36
|
"module": "dist/index.mjs",
|
|
34
37
|
"types": "dist/index.d.ts",
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@slidev/types": "0.
|
|
39
|
+
"@slidev/types": "0.28.2",
|
|
37
40
|
"js-yaml": "^4.1.0"
|
|
38
41
|
},
|
|
39
42
|
"engines": {
|
|
@@ -42,5 +45,6 @@
|
|
|
42
45
|
"scripts": {
|
|
43
46
|
"build": "rimraf dist && tsup src/index.ts src/core.ts src/fs.ts --format cjs,esm --dts --splitting",
|
|
44
47
|
"dev": "nr build --watch"
|
|
45
|
-
}
|
|
48
|
+
},
|
|
49
|
+
"readme": "# @slidev/parser\n\n[](https://www.npmjs.com/package/@slidev/parser)\n\nSlides markdown parser for [Slidev](https://sli.dev).\n\nLearn more about the [Syntax](https://sli.dev/guide/syntax.html)\n\nRefer to the TypeScript definitions for API.\n\n## License\n\nMIT License © 2021 [Anthony Fu](https://github.com/antfu)\n\n"
|
|
46
50
|
}
|