mr-md 1.0.3 → 1.0.4
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/builder.d.ts.map +1 -1
- package/dist/builder.js +8 -10
- package/dist/renderer/utils.d.ts.map +1 -1
- package/dist/renderer/utils.js +14 -2
- package/package.json +60 -60
- package/src/builder.ts +8 -12
- package/src/renderer/utils.ts +17 -2
package/dist/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEX,gBAAgB,EAEhB,YAAY,EACZ,YAAY,EACZ,OAAO,EAGP,UAAU,EAEV,cAAc,EAId,YAAY,EACZ,MAAM,EACN,UAAU,EAGV,YAAY,EACZ,SAAS,EAIT,iBAAiB,EAEjB,cAAc,EACd,MAAM,YAAY,CAAC;AAsCpB,qBAAa,aAAa;IACzB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,WAAW,CAAe;gBAEtB,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,EAAE,SAAS,CAAC,EAAE,MAAM;IA+BzE;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxB;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK/B,2CAA2C;IAC3C,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI;IAK7B,4CAA4C;IAC5C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK1B;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI;IAKlD,kEAAkE;IAClE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,CA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AI;IAKvD,MAAM,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI;IAO1C,KAAK,IAAI,MAAM;IAuCf,qCAAqC;IACrC,MAAM,IAAI,OAAO;CAOjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CACtB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,YAAiB,GACxB,cAAc,CAEhB;AAID,qBAAa,aAAa;IACzB,OAAO,CAAC,IAAI,CAAkC;IAC9C,OAAO,CAAC,eAAe,CAAwB;IAC/C,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,WAAW,CAAe;gBAEtB,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,EAAE,SAAS,CAAC,EAAE,MAAM;IAyBzE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK/B,OAAO,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI;IAM7C,KAAK,IAAI,MAAM;CAsBf;AAED,wBAAgB,MAAM,CACrB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,YAAiB,GACxB,aAAa,CAEf"}
|
package/dist/builder.js
CHANGED
|
@@ -109,17 +109,16 @@ export class LessonBuilder {
|
|
|
109
109
|
/** @internal Used by ChapterBuilder to push down shared config */
|
|
110
110
|
_inheritOptions(parentOpts, parentRawOpts) {
|
|
111
111
|
this.options = {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.options.contentBase,
|
|
112
|
+
...this.options,
|
|
113
|
+
outDir: this._rawOptions.outDir ?? parentOpts.outDir ?? this.options.outDir,
|
|
114
|
+
contentBase: this._rawOptions.contentBase ?? this.options.contentBase,
|
|
116
115
|
theme: this._rawOptions.theme ?? parentOpts.theme ?? this.options.theme,
|
|
117
116
|
palette: this._rawOptions.palette ?? parentOpts.palette ?? this.options.palette,
|
|
118
117
|
strict: this._rawOptions.strict ?? parentOpts.strict ?? this.options.strict,
|
|
119
118
|
preset: {
|
|
119
|
+
...this.options.preset,
|
|
120
120
|
...parentOpts.preset,
|
|
121
121
|
...this._rawOptions.preset,
|
|
122
|
-
...this.options.preset,
|
|
123
122
|
},
|
|
124
123
|
};
|
|
125
124
|
}
|
|
@@ -515,17 +514,16 @@ export class ChapterBuilder {
|
|
|
515
514
|
/** @internal Used by CourseBuilder to push down shared config */
|
|
516
515
|
_inheritOptions(parentOpts, parentRawOpts) {
|
|
517
516
|
this.options = {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
this.options.contentBase,
|
|
517
|
+
...this.options,
|
|
518
|
+
outDir: this._rawOptions.outDir ?? parentOpts.outDir ?? this.options.outDir,
|
|
519
|
+
contentBase: this._rawOptions.contentBase ?? this.options.contentBase,
|
|
522
520
|
theme: this._rawOptions.theme ?? parentOpts.theme ?? this.options.theme,
|
|
523
521
|
palette: this._rawOptions.palette ?? parentOpts.palette ?? this.options.palette,
|
|
524
522
|
strict: this._rawOptions.strict ?? parentOpts.strict ?? this.options.strict,
|
|
525
523
|
preset: {
|
|
524
|
+
...this.options.preset,
|
|
526
525
|
...parentOpts.preset,
|
|
527
526
|
...this._rawOptions.preset,
|
|
528
|
-
...this.options.preset,
|
|
529
527
|
},
|
|
530
528
|
};
|
|
531
529
|
for (const lb of this.lessonBuilders) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/renderer/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,OAAO;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;CACrC;AAID,iBAAS,cAAc,CACtB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,YAAY,EACrB,YAAY,GAAE,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,MAAe,GAClD,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/renderer/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,OAAO;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;CACrC;AAID,iBAAS,cAAc,CACtB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,YAAY,EACrB,YAAY,GAAE,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,MAAe,GAClD,MAAM,CA0CR;AAED,iBAAS,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAgDnE;AAED,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/renderer/utils.js
CHANGED
|
@@ -14,9 +14,15 @@ function resolveContent(src, options, expectedType = "text") {
|
|
|
14
14
|
src.startsWith("/") ||
|
|
15
15
|
src.startsWith("./") ||
|
|
16
16
|
src.startsWith("../");
|
|
17
|
-
|
|
17
|
+
let filePath = path.isAbsolute(src)
|
|
18
18
|
? src
|
|
19
19
|
: path.resolve(options.contentBase ?? ".", src);
|
|
20
|
+
if (!fs.existsSync(filePath) && !path.isAbsolute(src)) {
|
|
21
|
+
const cwdFilePath = path.resolve(process.cwd(), src);
|
|
22
|
+
if (fs.existsSync(cwdFilePath)) {
|
|
23
|
+
filePath = cwdFilePath;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
20
26
|
if (fs.existsSync(filePath)) {
|
|
21
27
|
const stat = fs.statSync(filePath);
|
|
22
28
|
if (stat.isFile()) {
|
|
@@ -35,9 +41,15 @@ function resolveAssetSrc(src, options) {
|
|
|
35
41
|
const isWebAbsolute = src.startsWith("/") && !fs.existsSync(src);
|
|
36
42
|
if (isWebAbsolute)
|
|
37
43
|
return src;
|
|
38
|
-
|
|
44
|
+
let filePath = path.isAbsolute(src)
|
|
39
45
|
? src
|
|
40
46
|
: path.resolve(options.contentBase ?? ".", src);
|
|
47
|
+
if (!fs.existsSync(filePath) && !path.isAbsolute(src)) {
|
|
48
|
+
const cwdFilePath = path.resolve(process.cwd(), src);
|
|
49
|
+
if (fs.existsSync(cwdFilePath)) {
|
|
50
|
+
filePath = cwdFilePath;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
41
53
|
if (!fs.existsSync(filePath)) {
|
|
42
54
|
if (options.strict !== false)
|
|
43
55
|
throw new Error(`Missing media asset: ${filePath}`);
|
package/package.json
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
2
|
+
"name": "mr-md",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Mr Markdown is an opinionated TypeScript SDK for building interactive, single-file learning pages.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"directories": {
|
|
20
|
+
"demo": "demo"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.build.json && mkdir -p dist/styles dist/client && cp -r src/styles/* dist/styles/ && cp -r src/client/* dist/client/",
|
|
24
|
+
"prepublishOnly": "bun run build",
|
|
25
|
+
"build:example": "bun demo/src/course.ts",
|
|
26
|
+
"serve:example": "bunx serve demo/out",
|
|
27
|
+
"typecheck": "bunx tsc --noEmit",
|
|
28
|
+
"test": "bun test && bun run typecheck",
|
|
29
|
+
"test:watch": "bun test --watch",
|
|
30
|
+
"lint": "biome lint .",
|
|
31
|
+
"format": "biome format --write .",
|
|
32
|
+
"check": "biome check --write ."
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"markdown",
|
|
36
|
+
"blog",
|
|
37
|
+
"interactive",
|
|
38
|
+
"education",
|
|
39
|
+
"shiki",
|
|
40
|
+
"katex",
|
|
41
|
+
"course"
|
|
42
|
+
],
|
|
43
|
+
"author": "Chirayu Chhabra",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/chirayuChhabra/blogkit.git"
|
|
47
|
+
},
|
|
48
|
+
"license": "ISC",
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/katex": "^0.16.8",
|
|
51
|
+
"@types/node": "^25.8.0",
|
|
52
|
+
"biome": "^0.3.3",
|
|
53
|
+
"ts-node": "^10.9.2",
|
|
54
|
+
"typescript": "^6.0.3"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"highlight.js": "^11.11.1",
|
|
58
|
+
"katex": "^0.16.47",
|
|
59
|
+
"marked": "^18.0.4",
|
|
60
|
+
"marked-highlight": "^2.2.4"
|
|
61
|
+
}
|
|
62
62
|
}
|
package/src/builder.ts
CHANGED
|
@@ -155,21 +155,19 @@ export class LessonBuilder {
|
|
|
155
155
|
/** @internal Used by ChapterBuilder to push down shared config */
|
|
156
156
|
_inheritOptions(parentOpts: BuildOptions, parentRawOpts?: BuildOptions) {
|
|
157
157
|
this.options = {
|
|
158
|
+
...this.options,
|
|
158
159
|
outDir:
|
|
159
|
-
this._rawOptions.outDir ??
|
|
160
|
-
contentBase:
|
|
161
|
-
this._rawOptions.contentBase ??
|
|
162
|
-
parentRawOpts?.contentBase ??
|
|
163
|
-
this.options.contentBase,
|
|
160
|
+
this._rawOptions.outDir ?? parentOpts.outDir ?? this.options.outDir,
|
|
161
|
+
contentBase: this._rawOptions.contentBase ?? this.options.contentBase,
|
|
164
162
|
theme: this._rawOptions.theme ?? parentOpts.theme ?? this.options.theme,
|
|
165
163
|
palette:
|
|
166
164
|
this._rawOptions.palette ?? parentOpts.palette ?? this.options.palette,
|
|
167
165
|
strict:
|
|
168
166
|
this._rawOptions.strict ?? parentOpts.strict ?? this.options.strict,
|
|
169
167
|
preset: {
|
|
168
|
+
...this.options.preset,
|
|
170
169
|
...parentOpts.preset,
|
|
171
170
|
...this._rawOptions.preset,
|
|
172
|
-
...this.options.preset,
|
|
173
171
|
},
|
|
174
172
|
};
|
|
175
173
|
}
|
|
@@ -670,21 +668,19 @@ export class ChapterBuilder {
|
|
|
670
668
|
/** @internal Used by CourseBuilder to push down shared config */
|
|
671
669
|
_inheritOptions(parentOpts: BuildOptions, parentRawOpts?: BuildOptions) {
|
|
672
670
|
this.options = {
|
|
671
|
+
...this.options,
|
|
673
672
|
outDir:
|
|
674
|
-
this._rawOptions.outDir ??
|
|
675
|
-
contentBase:
|
|
676
|
-
this._rawOptions.contentBase ??
|
|
677
|
-
parentRawOpts?.contentBase ??
|
|
678
|
-
this.options.contentBase,
|
|
673
|
+
this._rawOptions.outDir ?? parentOpts.outDir ?? this.options.outDir,
|
|
674
|
+
contentBase: this._rawOptions.contentBase ?? this.options.contentBase,
|
|
679
675
|
theme: this._rawOptions.theme ?? parentOpts.theme ?? this.options.theme,
|
|
680
676
|
palette:
|
|
681
677
|
this._rawOptions.palette ?? parentOpts.palette ?? this.options.palette,
|
|
682
678
|
strict:
|
|
683
679
|
this._rawOptions.strict ?? parentOpts.strict ?? this.options.strict,
|
|
684
680
|
preset: {
|
|
681
|
+
...this.options.preset,
|
|
685
682
|
...parentOpts.preset,
|
|
686
683
|
...this._rawOptions.preset,
|
|
687
|
-
...this.options.preset,
|
|
688
684
|
},
|
|
689
685
|
};
|
|
690
686
|
|
package/src/renderer/utils.ts
CHANGED
|
@@ -30,10 +30,17 @@ function resolveContent(
|
|
|
30
30
|
src.startsWith("./") ||
|
|
31
31
|
src.startsWith("../");
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
let filePath = path.isAbsolute(src)
|
|
34
34
|
? src
|
|
35
35
|
: path.resolve(options.contentBase ?? ".", src);
|
|
36
36
|
|
|
37
|
+
if (!fs.existsSync(filePath) && !path.isAbsolute(src)) {
|
|
38
|
+
const cwdFilePath = path.resolve(process.cwd(), src);
|
|
39
|
+
if (fs.existsSync(cwdFilePath)) {
|
|
40
|
+
filePath = cwdFilePath;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
37
44
|
if (fs.existsSync(filePath)) {
|
|
38
45
|
const stat = fs.statSync(filePath);
|
|
39
46
|
if (stat.isFile()) {
|
|
@@ -57,9 +64,17 @@ function resolveAssetSrc(src: string, options: BuildOptions): string {
|
|
|
57
64
|
const isWebAbsolute = src.startsWith("/") && !fs.existsSync(src);
|
|
58
65
|
if (isWebAbsolute) return src;
|
|
59
66
|
|
|
60
|
-
|
|
67
|
+
let filePath = path.isAbsolute(src)
|
|
61
68
|
? src
|
|
62
69
|
: path.resolve(options.contentBase ?? ".", src);
|
|
70
|
+
|
|
71
|
+
if (!fs.existsSync(filePath) && !path.isAbsolute(src)) {
|
|
72
|
+
const cwdFilePath = path.resolve(process.cwd(), src);
|
|
73
|
+
if (fs.existsSync(cwdFilePath)) {
|
|
74
|
+
filePath = cwdFilePath;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
63
78
|
if (!fs.existsSync(filePath)) {
|
|
64
79
|
if (options.strict !== false)
|
|
65
80
|
throw new Error(`Missing media asset: ${filePath}`);
|