@slidev/parser 52.20.1 → 53.1.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/core.d.mts +1 -5
- package/dist/core.mjs +5 -4
- package/dist/fs.d.mts +1 -3
- package/dist/fs.mjs +2 -3
- package/dist/index.d.mts +1 -1
- package/dist/{utils-DpcPp-I0.d.mts → utils-DZbiIvf-.d.mts} +0 -6
- package/dist/utils.d.mts +1 -1
- package/dist/utils.mjs +3 -6
- package/package.json +3 -3
package/dist/core.d.mts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { a as TimesplitOutput, i as TimesplitInput, n as parseRangeString, o as parseTimesplits, r as parseTimeString, t as parseAspectRatio } from "./utils-
|
|
1
|
+
import { a as TimesplitOutput, i as TimesplitInput, n as parseRangeString, o as parseTimesplits, r as parseTimeString, t as parseAspectRatio } from "./utils-DZbiIvf-.mjs";
|
|
2
2
|
import { FontOptions, ResolvedFontOptions, SlidevConfig, SlidevDetectedFeatures, SlidevMarkdown, SlidevPreparserExtension, SlidevThemeMeta, SourceSlideInfo } from "@slidev/types";
|
|
3
|
-
//#region src/config.d.ts
|
|
4
3
|
export declare function getDefaultConfig(): SlidevConfig;
|
|
5
4
|
export declare function resolveConfig(headmatter: any, themeMeta?: SlidevThemeMeta, filepath?: string, verify?: boolean): SlidevConfig;
|
|
6
5
|
export declare function verifyConfig(config: SlidevConfig, themeMeta?: SlidevThemeMeta, warn?: (v: string) => void): void;
|
|
7
6
|
export declare function resolveFonts(fonts?: FontOptions): ResolvedFontOptions;
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/core.d.ts
|
|
10
7
|
export interface SlidevParserOptions {
|
|
11
8
|
noParseYAML?: boolean;
|
|
12
9
|
preserveCR?: boolean;
|
|
@@ -24,5 +21,4 @@ export declare function detectFeatures(code: string): SlidevDetectedFeatures;
|
|
|
24
21
|
export declare function parseSlide(raw: string, options?: SlidevParserOptions): Omit<SourceSlideInfo, 'filepath' | 'index' | 'start' | 'contentStart' | 'end'>;
|
|
25
22
|
export declare function parse(markdown: string, filepath: string, extensions?: SlidevPreparserExtension[], options?: SlidevParserOptions): Promise<SlidevMarkdown>;
|
|
26
23
|
export declare function parseSync(markdown: string, filepath: string, options?: SlidevParserOptions): SlidevMarkdown;
|
|
27
|
-
//#endregion
|
|
28
24
|
export { TimesplitInput, TimesplitOutput, parseAspectRatio, parseRangeString, parseTimeString, parseTimesplits };
|
package/dist/core.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseAspectRatio, parseRangeString, parseTimeString, parseTimesplits } from "./utils.mjs";
|
|
2
2
|
import { ensurePrefix, toArray, uniq } from "@antfu/utils";
|
|
3
3
|
import YAML from "yaml";
|
|
4
|
-
|
|
4
|
+
// src/config.ts
|
|
5
5
|
const RE_QUOTED_STRING = /^(['"]).*\1$/;
|
|
6
6
|
const RE_FILENAME_STEM = /([^\\/]+?)(?:\.\w+)?$/;
|
|
7
7
|
function getDefaultConfig() {
|
|
@@ -198,8 +198,7 @@ function resolveDrawings(options = {}, filepath) {
|
|
|
198
198
|
syncAll
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
-
|
|
202
|
-
//#region src/core.ts
|
|
201
|
+
// src/core.ts
|
|
203
202
|
const RE_FRONTMATTER = /^---.*\r?\n([\s\S]*?)---/;
|
|
204
203
|
const RE_YAML_CODEBLOCK = /^\s*```ya?ml([\s\S]*?)```/;
|
|
205
204
|
const RE_DOLLAR_INLINE = /\$.*?\$/;
|
|
@@ -212,6 +211,7 @@ const RE_HEADING = /^(#+) (.*)$/m;
|
|
|
212
211
|
const RE_CODE_BLOCK = /^```[\s\S]+?^```/gm;
|
|
213
212
|
const RE_LEADING_BACKTICKS = /^\s*`+/;
|
|
214
213
|
const RE_CRLF = /\r?\n/g;
|
|
214
|
+
const RE_BOM = /^/;
|
|
215
215
|
function advanceHtmlCommentState(line, inHtmlComment) {
|
|
216
216
|
let cursor = 0;
|
|
217
217
|
while (cursor < line.length) if (inHtmlComment) {
|
|
@@ -353,6 +353,7 @@ function parseSlide(raw, options = {}) {
|
|
|
353
353
|
};
|
|
354
354
|
}
|
|
355
355
|
async function parse(markdown, filepath, extensions, options = {}) {
|
|
356
|
+
markdown = markdown.replace(RE_BOM, "");
|
|
356
357
|
const lines = markdown.split(options.preserveCR ? "\n" : RE_CRLF);
|
|
357
358
|
const slides = [];
|
|
358
359
|
let start = 0;
|
|
@@ -417,6 +418,7 @@ async function parse(markdown, filepath, extensions, options = {}) {
|
|
|
417
418
|
};
|
|
418
419
|
}
|
|
419
420
|
function parseSync(markdown, filepath, options = {}) {
|
|
421
|
+
markdown = markdown.replace(RE_BOM, "");
|
|
420
422
|
const lines = markdown.split(options.preserveCR ? "\n" : RE_CRLF);
|
|
421
423
|
const slides = [];
|
|
422
424
|
let start = 0;
|
|
@@ -497,5 +499,4 @@ function hash(str) {
|
|
|
497
499
|
}
|
|
498
500
|
return hash.toString(36).slice(0, 12);
|
|
499
501
|
}
|
|
500
|
-
//#endregion
|
|
501
502
|
export { detectFeatures, extractImagesUsage, getDefaultConfig, parse, parseAspectRatio, parseRangeString, parseSlide, parseSync, parseTimeString, parseTimesplits, prettify, prettifySlide, resolveConfig, resolveFonts, stringify, stringifySlide, verifyConfig };
|
package/dist/fs.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as TimesplitOutput, i as TimesplitInput, n as parseRangeString, o as parseTimesplits, r as parseTimeString, t as parseAspectRatio } from "./utils-
|
|
1
|
+
import { a as TimesplitOutput, i as TimesplitInput, n as parseRangeString, o as parseTimesplits, r as parseTimeString, t as parseAspectRatio } from "./utils-DZbiIvf-.mjs";
|
|
2
2
|
import { SlidevParserOptions, detectFeatures, extractImagesUsage, getDefaultConfig, parse, parseSlide, parseSync, prettify, prettifySlide, resolveConfig, resolveFonts, stringify, stringifySlide, verifyConfig } from "./core.mjs";
|
|
3
3
|
import { PreparserExtensionLoader, SlidevData, SlidevMarkdown } from "@slidev/types";
|
|
4
|
-
//#region src/fs.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Whether `filePath` resolves inside any of `roots` (no `..` escape).
|
|
7
6
|
* Inlined here (rather than imported from the `slidev` package) because
|
|
@@ -26,5 +25,4 @@ export interface LoadRootsInfo {
|
|
|
26
25
|
export type LoadedSlidevData = Omit<SlidevData, 'config' | 'themeMeta'>;
|
|
27
26
|
export declare function load(options: LoadRootsInfo, filepath: string, sources?: Record<string, string> | ((path: string) => Promise<string>), mode?: string): Promise<LoadedSlidevData>;
|
|
28
27
|
export declare function save(markdown: SlidevMarkdown): Promise<string>;
|
|
29
|
-
//#endregion
|
|
30
28
|
export { SlidevParserOptions, TimesplitInput, TimesplitOutput, detectFeatures, extractImagesUsage, getDefaultConfig, parse, parseAspectRatio, parseRangeString, parseSlide, parseSync, parseTimeString, parseTimesplits, prettify, prettifySlide, resolveConfig, resolveFonts, stringify, stringifySlide, verifyConfig };
|
package/dist/fs.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import YAML from "yaml";
|
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { readFile, writeFile } from "node:fs/promises";
|
|
7
7
|
import { dirname, isAbsolute, relative, resolve } from "pathe";
|
|
8
|
-
|
|
8
|
+
// src/fs.ts
|
|
9
9
|
/**
|
|
10
10
|
* Whether `filePath` resolves inside any of `roots` (no `..` escape).
|
|
11
11
|
* Inlined here (rather than imported from the `slidev` package) because
|
|
@@ -17,7 +17,7 @@ function isPathInsideRoots(filePath, roots) {
|
|
|
17
17
|
return rel === "" || !!rel && !rel.startsWith("..") && !isAbsolute(rel);
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
const RE_FRONTMATTER_START =
|
|
20
|
+
const RE_FRONTMATTER_START = /^?---(?:[^-].*)?$/;
|
|
21
21
|
const RE_BLANK_LINE = /^\s*$/;
|
|
22
22
|
const RE_FRONTMATTER_END = /^---$/;
|
|
23
23
|
const RE_CRLF = /\r?\n/g;
|
|
@@ -141,5 +141,4 @@ async function save(markdown) {
|
|
|
141
141
|
await writeFile(markdown.filepath, fileContent, "utf-8");
|
|
142
142
|
return fileContent;
|
|
143
143
|
}
|
|
144
|
-
//#endregion
|
|
145
144
|
export { detectFeatures, extractImagesUsage, getDefaultConfig, injectPreparserExtensionLoader, isPathInsideRoots, load, parse, parseAspectRatio, parseRangeString, parseSlide, parseSync, parseTimeString, parseTimesplits, prettify, prettifySlide, resolveConfig, resolveFonts, save, stringify, stringifySlide, verifyConfig };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as TimesplitOutput, i as TimesplitInput, n as parseRangeString, o as parseTimesplits, r as parseTimeString, t as parseAspectRatio } from "./utils-
|
|
1
|
+
import { a as TimesplitOutput, i as TimesplitInput, n as parseRangeString, o as parseTimesplits, r as parseTimeString, t as parseAspectRatio } from "./utils-DZbiIvf-.mjs";
|
|
2
2
|
import { SlidevParserOptions, detectFeatures, extractImagesUsage, getDefaultConfig, parse, parseSlide, parseSync, prettify, prettifySlide, resolveConfig, resolveFonts, stringify, stringifySlide, verifyConfig } from "./core.mjs";
|
|
3
3
|
export { SlidevParserOptions, TimesplitInput, TimesplitOutput, detectFeatures, extractImagesUsage, getDefaultConfig, parse, parseAspectRatio, parseRangeString, parseSlide, parseSync, parseTimeString, parseTimesplits, prettify, prettifySlide, resolveConfig, resolveFonts, stringify, stringifySlide, verifyConfig };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/timesplit/timesplit.d.ts
|
|
2
1
|
interface TimesplitInput {
|
|
3
2
|
no: number;
|
|
4
3
|
timesplit: string;
|
|
@@ -12,14 +11,10 @@ interface TimesplitOutput {
|
|
|
12
11
|
title?: string;
|
|
13
12
|
}
|
|
14
13
|
declare function parseTimesplits(inputs: TimesplitInput[]): TimesplitOutput[];
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/timesplit/timestring.d.ts
|
|
17
14
|
declare function parseTimeString(timestamp: string | number): {
|
|
18
15
|
seconds: number;
|
|
19
16
|
relative: boolean;
|
|
20
17
|
};
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/utils.d.ts
|
|
23
18
|
/**
|
|
24
19
|
* 1,3-5,8 => [1, 3, 4, 5, 8]
|
|
25
20
|
*/
|
|
@@ -28,5 +23,4 @@ declare function parseRangeString(total: number, rangeStr?: string): number[];
|
|
|
28
23
|
* Accepts `16/9` `1:1` `3x4`
|
|
29
24
|
*/
|
|
30
25
|
declare function parseAspectRatio(str: string | number): number;
|
|
31
|
-
//#endregion
|
|
32
26
|
export { TimesplitOutput as a, TimesplitInput as i, parseRangeString as n, parseTimesplits as o, parseTimeString as r, parseAspectRatio as t };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as TimesplitOutput, i as TimesplitInput, n as parseRangeString, o as parseTimesplits, r as parseTimeString, t as parseAspectRatio } from "./utils-
|
|
1
|
+
import { a as TimesplitOutput, i as TimesplitInput, n as parseRangeString, o as parseTimesplits, r as parseTimeString, t as parseAspectRatio } from "./utils-DZbiIvf-.mjs";
|
|
2
2
|
export { TimesplitInput, TimesplitOutput, parseAspectRatio, parseRangeString, parseTimeString, parseTimesplits };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNumber, range, uniq } from "@antfu/utils";
|
|
2
|
-
|
|
2
|
+
// src/timesplit/timestring.ts
|
|
3
3
|
/**
|
|
4
4
|
* Parse timestamp into seconds
|
|
5
5
|
*
|
|
@@ -82,8 +82,7 @@ function parseTimeString(timestamp) {
|
|
|
82
82
|
relative
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
//#region src/timesplit/timesplit.ts
|
|
85
|
+
// src/timesplit/timesplit.ts
|
|
87
86
|
function parseTimesplits(inputs) {
|
|
88
87
|
let ts = 0;
|
|
89
88
|
const outputs = [];
|
|
@@ -113,8 +112,7 @@ function parseTimesplits(inputs) {
|
|
|
113
112
|
}
|
|
114
113
|
return outputs;
|
|
115
114
|
}
|
|
116
|
-
|
|
117
|
-
//#region src/utils.ts
|
|
115
|
+
// src/utils.ts
|
|
118
116
|
const RE_ASPECT_RATIO_SEPARATOR = /[:/x|]/;
|
|
119
117
|
/**
|
|
120
118
|
* 1,3-5,8 => [1, 3, 4, 5, 8]
|
|
@@ -142,5 +140,4 @@ function parseAspectRatio(str) {
|
|
|
142
140
|
if (Number.isNaN(w) || Number.isNaN(h) || h === 0) throw new Error(`Invalid aspect ratio "${str}"`);
|
|
143
141
|
return w / h;
|
|
144
142
|
}
|
|
145
|
-
//#endregion
|
|
146
143
|
export { parseAspectRatio, parseRangeString, parseTimeString, parseTimesplits };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/parser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "53.1.0",
|
|
4
4
|
"description": "Markdown parser for Slidev",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
29
|
+
"node": ">=22.12.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@antfu/utils": "^9.3.0",
|
|
33
|
-
"@slidev/types": "
|
|
33
|
+
"@slidev/types": "53.1.0",
|
|
34
34
|
"pathe": "^2.0.3",
|
|
35
35
|
"yaml": "^2.9.1"
|
|
36
36
|
},
|