@slidev/parser 0.37.1 → 0.38.1

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.
@@ -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.6.3/node_modules/@antfu/utils/dist/index.mjs
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 hStart = 0;
432
- while (hStart < lines.length && lines[hStart].match(/^(---|\w*)+/))
433
- hStart++;
434
- let hEnd = hStart + 1;
435
- while (hEnd < lines.length && !lines[hEnd].match(/^---+/))
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 = (_a = _jsyaml2.default.load(lines.slice(hStart, hEnd).join("\n"))) != null ? _a : {};
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 = ((_b = slides[0]) == null ? void 0 : _b.frontmatter) || {};
470
- headmatter.title = headmatter.title || ((_c = slides[0]) == null ? void 0 : _c.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.6.3/node_modules/@antfu/utils/dist/index.mjs
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 hStart = 0;
432
- while (hStart < lines.length && lines[hStart].match(/^(---|\w*)+/))
433
- hStart++;
434
- let hEnd = hStart + 1;
435
- while (hEnd < lines.length && !lines[hEnd].match(/^---+/))
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 = (_a = YAML.load(lines.slice(hStart, hEnd).join("\n"))) != null ? _a : {};
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 = ((_b = slides[0]) == null ? void 0 : _b.frontmatter) || {};
470
- headmatter.title = headmatter.title || ((_c = slides[0]) == null ? void 0 : _c.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 _chunk72T7ERBCjs = require('./chunk-72T7ERBC.js');
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 = _chunk72T7ERBCjs.detectFeatures; exports.filterDisabled = _chunk72T7ERBCjs.filterDisabled; exports.mergeFeatureFlags = _chunk72T7ERBCjs.mergeFeatureFlags; exports.parse = _chunk72T7ERBCjs.parse; exports.parseAspectRatio = _chunk72T7ERBCjs.parseAspectRatio; exports.parseRangeString = _chunk72T7ERBCjs.parseRangeString; exports.parseSlide = _chunk72T7ERBCjs.parseSlide; exports.prettify = _chunk72T7ERBCjs.prettify; exports.prettifySlide = _chunk72T7ERBCjs.prettifySlide; exports.resolveConfig = _chunk72T7ERBCjs.resolveConfig; exports.resolveFonts = _chunk72T7ERBCjs.resolveFonts; exports.scanMonacoModules = _chunk72T7ERBCjs.scanMonacoModules; exports.stringify = _chunk72T7ERBCjs.stringify; exports.stringifySlide = _chunk72T7ERBCjs.stringifySlide; exports.verifyConfig = _chunk72T7ERBCjs.verifyConfig;
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
@@ -14,7 +14,7 @@ import {
14
14
  stringify,
15
15
  stringifySlide,
16
16
  verifyConfig
17
- } from "./chunk-RYLG7SAK.mjs";
17
+ } from "./chunk-RQLJEQ6S.mjs";
18
18
  export {
19
19
  detectFeatures,
20
20
  filterDisabled,
package/dist/fs.js CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
 
17
- var _chunk72T7ERBCjs = require('./chunk-72T7ERBC.js');
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 _chunk72T7ERBCjs.parse.call(void 0, markdown, filepath, themeMeta, [], async (headmatter, exts, filepath2) => {
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((_a = headmatter.addons) != null ? _a : [], filepath2) : []
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 _chunk72T7ERBCjs.parse.call(void 0, raw, path, themeMeta, preparserExtensions);
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 = _chunk72T7ERBCjs.mergeFeatureFlags.call(void 0, data.features, _chunk72T7ERBCjs.detectFeatures.call(void 0, raw));
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, _chunk72T7ERBCjs.stringify.call(void 0, data), "utf-8");
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, _chunk72T7ERBCjs.stringifySlide.call(void 0, slide), "utf-8");
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 = _chunk72T7ERBCjs.detectFeatures; exports.filterDisabled = _chunk72T7ERBCjs.filterDisabled; exports.injectPreparserExtensionLoader = injectPreparserExtensionLoader; exports.load = load; exports.mergeFeatureFlags = _chunk72T7ERBCjs.mergeFeatureFlags; exports.parse = _chunk72T7ERBCjs.parse; exports.parseAspectRatio = _chunk72T7ERBCjs.parseAspectRatio; exports.parseRangeString = _chunk72T7ERBCjs.parseRangeString; exports.parseSlide = _chunk72T7ERBCjs.parseSlide; exports.prettify = _chunk72T7ERBCjs.prettify; exports.prettifySlide = _chunk72T7ERBCjs.prettifySlide; exports.resolveConfig = _chunk72T7ERBCjs.resolveConfig; exports.resolveFonts = _chunk72T7ERBCjs.resolveFonts; exports.save = save; exports.saveExternalSlide = saveExternalSlide; exports.scanMonacoModules = _chunk72T7ERBCjs.scanMonacoModules; exports.stringify = _chunk72T7ERBCjs.stringify; exports.stringifySlide = _chunk72T7ERBCjs.stringifySlide; exports.verifyConfig = _chunk72T7ERBCjs.verifyConfig;
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-RYLG7SAK.mjs";
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((_a = headmatter.addons) != null ? _a : [], filepath2) : []
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 _chunk72T7ERBCjs = require('./chunk-72T7ERBC.js');
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 = _chunk72T7ERBCjs.detectFeatures; exports.filterDisabled = _chunk72T7ERBCjs.filterDisabled; exports.mergeFeatureFlags = _chunk72T7ERBCjs.mergeFeatureFlags; exports.parse = _chunk72T7ERBCjs.parse; exports.parseAspectRatio = _chunk72T7ERBCjs.parseAspectRatio; exports.parseRangeString = _chunk72T7ERBCjs.parseRangeString; exports.parseSlide = _chunk72T7ERBCjs.parseSlide; exports.prettify = _chunk72T7ERBCjs.prettify; exports.prettifySlide = _chunk72T7ERBCjs.prettifySlide; exports.resolveConfig = _chunk72T7ERBCjs.resolveConfig; exports.resolveFonts = _chunk72T7ERBCjs.resolveFonts; exports.scanMonacoModules = _chunk72T7ERBCjs.scanMonacoModules; exports.stringify = _chunk72T7ERBCjs.stringify; exports.stringifySlide = _chunk72T7ERBCjs.stringifySlide; exports.verifyConfig = _chunk72T7ERBCjs.verifyConfig;
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
@@ -14,7 +14,7 @@ import {
14
14
  stringify,
15
15
  stringifySlide,
16
16
  verifyConfig
17
- } from "./chunk-RYLG7SAK.mjs";
17
+ } from "./chunk-RQLJEQ6S.mjs";
18
18
  export {
19
19
  detectFeatures,
20
20
  filterDisabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/parser",
3
- "version": "0.37.1",
3
+ "version": "0.38.1",
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
- "@slidev/types": "0.37.1",
43
- "js-yaml": "^4.1.0"
42
+ "js-yaml": "^4.1.0",
43
+ "@slidev/types": "0.38.1"
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",