@cnblogs/markdown-it-presets 1.10.11 → 1.10.13
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/commonjs/index.cjs +197 -261
- package/dist/commonjs/math/index.cjs +35 -78
- package/dist/commonjs/presets/index.cjs +162 -183
- package/dist/es2020/math/factory.mjs.map +1 -0
- package/dist/{es2015 → es2020}/math/impl.mjs +27 -41
- package/dist/es2020/math/impl.mjs.map +1 -0
- package/dist/{es2015 → es2020}/presets/index.mjs +7 -7
- package/dist/es2020/presets/index.mjs.map +1 -0
- package/dist/{es2015 → es2020}/presets/option.mjs +1 -0
- package/dist/{es2015 → es2020}/presets/option.mjs.map +1 -1
- package/dist/es2020/presets/plugins/highlight-code-lines.plugin.mjs.map +1 -0
- package/dist/es2020/presets/plugins/html-filter.plugin.mjs.map +1 -0
- package/dist/es2020/presets/plugins/imsize/helpers/parse_image_size.mjs.map +1 -0
- package/dist/es2020/presets/plugins/imsize/index.mjs.map +1 -0
- package/dist/es2020/presets/plugins/meta.mjs.map +1 -0
- package/dist/{es2015 → es2020}/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.mjs +1 -1
- package/dist/es2020/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.mjs.map +1 -0
- package/dist/es2020/presets/plugins/multiline-blockquote/multiline-blockquote.rule.mjs.map +1 -0
- package/dist/es2020/presets/plugins/simple-math.plugin.mjs.map +1 -0
- package/dist/{es2015 → es2020}/presets/plugins/simple-mermaid.plugin.mjs.map +1 -1
- package/dist/es2020/presets/plugins/toc/index.mjs.map +1 -0
- package/dist/{es2015 → es2020}/presets/plugins/unique-custom-id.mjs +1 -1
- package/dist/es2020/presets/plugins/unique-custom-id.mjs.map +1 -0
- package/dist/es2020/tsconfig.tsbuildinfo +1 -0
- package/dist/styles/task-lists.min.js +1 -1
- package/dist/types/index.d.ts +1 -4
- package/dist/types/math/index.d.ts +1 -4
- package/dist/types/tsdoc-metadata.json +1 -1
- package/dist/umd/markdownItPresets.js +1 -1
- package/dist/umd/mathRenderer.js +1 -2
- package/package.json +55 -50
- package/tsconfig.base.json +2 -2
- package/dist/es2015/math/factory.mjs.map +0 -1
- package/dist/es2015/math/impl.mjs.map +0 -1
- package/dist/es2015/presets/index.mjs.map +0 -1
- package/dist/es2015/presets/plugins/highlight-code-lines.plugin.mjs.map +0 -1
- package/dist/es2015/presets/plugins/html-filter.plugin.mjs.map +0 -1
- package/dist/es2015/presets/plugins/imsize/helpers/parse_image_size.mjs.map +0 -1
- package/dist/es2015/presets/plugins/imsize/index.mjs.map +0 -1
- package/dist/es2015/presets/plugins/meta.mjs.map +0 -1
- package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.mjs.map +0 -1
- package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.rule.mjs.map +0 -1
- package/dist/es2015/presets/plugins/simple-math.plugin.mjs.map +0 -1
- package/dist/es2015/presets/plugins/toc/index.mjs.map +0 -1
- package/dist/es2015/presets/plugins/unique-custom-id.mjs.map +0 -1
- package/dist/es2015/tsconfig.tsbuildinfo +0 -1
- package/dist/umd/mathRenderer.js.LICENSE.txt +0 -1
- /package/dist/{es2015 → es2020}/index.mjs +0 -0
- /package/dist/{es2015 → es2020}/index.mjs.map +0 -0
- /package/dist/{es2015 → es2020}/math/factory.mjs +0 -0
- /package/dist/{es2015 → es2020}/math/index.mjs +0 -0
- /package/dist/{es2015 → es2020}/math/index.mjs.map +0 -0
- /package/dist/{es2015 → es2020}/math/model.mjs +0 -0
- /package/dist/{es2015 → es2020}/math/model.mjs.map +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/highlight-code-lines.plugin.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/html-filter.plugin.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/imsize/helpers/normalize_reference.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/imsize/helpers/normalize_reference.mjs.map +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/imsize/helpers/parse_image_size.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/imsize/index.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/index.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/index.mjs.map +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/meta.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/multiline-blockquote/multiline-blockquote.rule.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/simple-math.plugin.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/simple-mermaid.plugin.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/toc/index.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/toc/slugify.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/toc/slugify.mjs.map +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/toc/toc-item.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/toc/toc-item.mjs.map +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/toc/toc-option.mjs +0 -0
- /package/dist/{es2015 → es2020}/presets/plugins/toc/toc-option.mjs.map +0 -0
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
5
|
var __export = (target, all) => {
|
|
20
6
|
for (var name in all)
|
|
21
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -29,26 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
29
15
|
return to;
|
|
30
16
|
};
|
|
31
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
-
var __async = (__this, __arguments, generator) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
var fulfilled = (value) => {
|
|
35
|
-
try {
|
|
36
|
-
step(generator.next(value));
|
|
37
|
-
} catch (e) {
|
|
38
|
-
reject(e);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var rejected = (value) => {
|
|
42
|
-
try {
|
|
43
|
-
step(generator.throw(value));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
reject(e);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
18
|
|
|
53
19
|
// src/math/index.ts
|
|
54
20
|
var math_exports = {};
|
|
@@ -118,15 +84,12 @@ var Mathjax2Renderer = class {
|
|
|
118
84
|
this._config = this._defaultConfig;
|
|
119
85
|
}
|
|
120
86
|
get _global() {
|
|
121
|
-
|
|
122
|
-
return (_a = this._config.document.defaultView) != null ? _a : window;
|
|
87
|
+
return this._config.document.defaultView ?? window;
|
|
123
88
|
}
|
|
124
89
|
render(container, callback) {
|
|
125
|
-
if (!this._config.isEnabled)
|
|
126
|
-
return Promise.resolve();
|
|
90
|
+
if (!this._config.isEnabled) return Promise.resolve();
|
|
127
91
|
return this.init().then((mathjax) => {
|
|
128
|
-
if (!mathjax)
|
|
129
|
-
return;
|
|
92
|
+
if (!mathjax) return;
|
|
130
93
|
const { onRendered } = this._config;
|
|
131
94
|
mathjax.Hub.Queue(["Typeset", mathjax.Hub, container]);
|
|
132
95
|
if (onRendered != null) {
|
|
@@ -142,8 +105,7 @@ var Mathjax2Renderer = class {
|
|
|
142
105
|
return this;
|
|
143
106
|
}
|
|
144
107
|
init() {
|
|
145
|
-
if (this._initTask)
|
|
146
|
-
return this._initTask;
|
|
108
|
+
if (this._initTask) return this._initTask;
|
|
147
109
|
const { entryScript, tapMathJaxConfig, document } = this._config;
|
|
148
110
|
return this._initTask = (0, import_load_script_css.loadScript)({
|
|
149
111
|
src: entryScript,
|
|
@@ -151,14 +113,15 @@ var Mathjax2Renderer = class {
|
|
|
151
113
|
timeoutSeconds: 10,
|
|
152
114
|
appendTo: document.head
|
|
153
115
|
}).then(() => {
|
|
154
|
-
var _a;
|
|
155
116
|
const { MathJax } = this._global;
|
|
156
117
|
if (MathJax) {
|
|
157
118
|
MathJax.Hub.Config(
|
|
158
|
-
|
|
119
|
+
tapMathJaxConfig?.call(
|
|
159
120
|
void 0,
|
|
160
121
|
Object.assign({}, this._defaultMathJaxConfig)
|
|
161
|
-
)
|
|
122
|
+
) ?? {
|
|
123
|
+
...this._defaultMathJaxConfig
|
|
124
|
+
}
|
|
162
125
|
);
|
|
163
126
|
MathJax.Hub.Configured();
|
|
164
127
|
return MathJax;
|
|
@@ -201,19 +164,17 @@ var MathJax3Renderer = class {
|
|
|
201
164
|
return this;
|
|
202
165
|
}
|
|
203
166
|
render(container, callback) {
|
|
204
|
-
if (!this._config.isEnabled)
|
|
205
|
-
return Promise.resolve();
|
|
167
|
+
if (!this._config.isEnabled) return Promise.resolve();
|
|
206
168
|
return this.init().then((mathjax) => {
|
|
207
169
|
mathjax ? mathjax.startup.promise = mathjax.startup.promise.then(
|
|
208
170
|
() => mathjax.typesetPromise([container]).then(() => {
|
|
209
|
-
var _a;
|
|
210
171
|
try {
|
|
211
|
-
|
|
172
|
+
this._config.onRendered?.call(void 0, mathjax);
|
|
212
173
|
} catch (e) {
|
|
213
174
|
console.error(e);
|
|
214
175
|
}
|
|
215
176
|
try {
|
|
216
|
-
callback
|
|
177
|
+
callback?.call(void 0);
|
|
217
178
|
} catch (e) {
|
|
218
179
|
console.error(e);
|
|
219
180
|
}
|
|
@@ -222,18 +183,17 @@ var MathJax3Renderer = class {
|
|
|
222
183
|
}).catch(console.warn);
|
|
223
184
|
}
|
|
224
185
|
init() {
|
|
225
|
-
|
|
226
|
-
return ((_a = this._initTask) != null ? _a : this._initTask = new Promise((resolve, reject) => {
|
|
227
|
-
var _a2, _b;
|
|
186
|
+
return (this._initTask ?? (this._initTask = new Promise((resolve, reject) => {
|
|
228
187
|
const { entryScript, tapMathJaxConfig, document: _document } = this._config;
|
|
229
|
-
const _window =
|
|
230
|
-
_window.MathJax =
|
|
188
|
+
const _window = _document.defaultView ?? window;
|
|
189
|
+
_window.MathJax = tapMathJaxConfig?.call(void 0, {
|
|
190
|
+
...this._defaultMathJaxConfig
|
|
191
|
+
}) ?? { ...this._defaultMathJaxConfig };
|
|
231
192
|
if (!_window.MathJax.startup) {
|
|
232
193
|
_window.MathJax.startup = {};
|
|
233
194
|
}
|
|
234
195
|
_window.MathJax.startup.ready = () => {
|
|
235
|
-
|
|
236
|
-
(_b2 = (_a3 = _window.MathJax) == null ? void 0 : _a3.startup) == null ? void 0 : _b2.defaultReady();
|
|
196
|
+
_window.MathJax?.startup?.defaultReady();
|
|
237
197
|
resolve(_window.MathJax);
|
|
238
198
|
};
|
|
239
199
|
(0, import_load_script_css.loadScript)({
|
|
@@ -242,7 +202,7 @@ var MathJax3Renderer = class {
|
|
|
242
202
|
executionStrategy: "defer",
|
|
243
203
|
appendTo: _window.document.head
|
|
244
204
|
}).catch(reject);
|
|
245
|
-
})).catch(() => this._initTask = void 0);
|
|
205
|
+
}))).catch(() => this._initTask = void 0);
|
|
246
206
|
}
|
|
247
207
|
};
|
|
248
208
|
var KatexRenderer = class {
|
|
@@ -260,29 +220,25 @@ var KatexRenderer = class {
|
|
|
260
220
|
this._katexOption = Object.assign({}, this._defaultKatexOptions);
|
|
261
221
|
}
|
|
262
222
|
get _global() {
|
|
263
|
-
|
|
264
|
-
return (_a = this._config.document.defaultView) != null ? _a : window;
|
|
223
|
+
return this._config.document.defaultView ?? window;
|
|
265
224
|
}
|
|
266
225
|
config(value) {
|
|
267
226
|
this._config = Object.assign({}, this._defaultConfig, value);
|
|
268
227
|
return this;
|
|
269
228
|
}
|
|
270
|
-
render(container, callback) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
});
|
|
229
|
+
async render(container, callback) {
|
|
230
|
+
if (!this._config.isEnabled) {
|
|
231
|
+
return Promise.resolve();
|
|
232
|
+
}
|
|
233
|
+
await this.init();
|
|
234
|
+
const global = this._global;
|
|
235
|
+
global.renderMathInElement(container, this._katexOption);
|
|
236
|
+
if (callback) {
|
|
237
|
+
callback();
|
|
238
|
+
}
|
|
282
239
|
}
|
|
283
240
|
init() {
|
|
284
|
-
|
|
285
|
-
return ((_a = this._initTask) != null ? _a : this._initTask = new Promise((resolve, reject) => {
|
|
241
|
+
return (this._initTask ?? (this._initTask = new Promise((resolve, reject) => {
|
|
286
242
|
const { entryScript, document: _document } = this._config;
|
|
287
243
|
Promise.all([
|
|
288
244
|
(0, import_load_script_css.loadCss)({
|
|
@@ -300,14 +256,15 @@ var KatexRenderer = class {
|
|
|
300
256
|
id: "katex-auto-render",
|
|
301
257
|
appendTo: _document.head
|
|
302
258
|
}).then(() => {
|
|
303
|
-
|
|
304
|
-
this._katexOption = (_b = (_a2 = this._config.tapMathJaxConfig) == null ? void 0 : _a2.call(
|
|
259
|
+
this._katexOption = this._config.tapMathJaxConfig?.call(
|
|
305
260
|
void 0,
|
|
306
261
|
this._katexOption
|
|
307
|
-
)
|
|
262
|
+
) ?? {
|
|
263
|
+
...this._defaultKatexOptions
|
|
264
|
+
};
|
|
308
265
|
resolve();
|
|
309
266
|
})).catch(reject);
|
|
310
|
-
})).catch(() => this._initTask = void 0);
|
|
267
|
+
}))).catch(() => this._initTask = void 0);
|
|
311
268
|
}
|
|
312
269
|
};
|
|
313
270
|
|