@cnblogs/markdown-it-presets 1.10.9 → 1.10.10
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 +144 -100
- package/dist/commonjs/math/index.cjs +134 -92
- package/dist/commonjs/presets/index.cjs +10 -8
- package/dist/es2015/math/impl.mjs +109 -92
- package/dist/es2015/math/impl.mjs.map +1 -1
- package/dist/es2015/presets/index.mjs +7 -7
- package/dist/es2015/presets/index.mjs.map +1 -1
- package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.mjs +1 -1
- package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.mjs.map +1 -1
- package/dist/es2015/presets/plugins/unique-custom-id.mjs +1 -1
- package/dist/es2015/presets/plugins/unique-custom-id.mjs.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/presets/index.d.ts +2 -0
- package/dist/umd/markdownItPresets.js +1 -1
- package/package.json +18 -1
- package/tsconfig.base.json +2 -2
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
5
|
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
|
+
};
|
|
5
19
|
var __export = (target, all) => {
|
|
6
20
|
for (var name in all)
|
|
7
21
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,6 +29,26 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
29
|
return to;
|
|
16
30
|
};
|
|
17
31
|
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
|
+
};
|
|
18
52
|
|
|
19
53
|
// src/math/index.ts
|
|
20
54
|
var math_exports = {};
|
|
@@ -57,33 +91,35 @@ var defaultConfig = {
|
|
|
57
91
|
|
|
58
92
|
// src/math/impl.ts
|
|
59
93
|
var Mathjax2Renderer = class {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
[
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
94
|
+
constructor() {
|
|
95
|
+
this._defaultConfig = defaultConfig[0 /* MathJax2 */];
|
|
96
|
+
this._defaultMathJaxConfig = {
|
|
97
|
+
tex2jax: {
|
|
98
|
+
inlineMath: [
|
|
99
|
+
["$", "$"],
|
|
100
|
+
["\\(", "\\)"]
|
|
101
|
+
],
|
|
102
|
+
processClass: "math",
|
|
103
|
+
processEscapes: true
|
|
104
|
+
},
|
|
105
|
+
TeX: {
|
|
106
|
+
equationNumbers: {
|
|
107
|
+
autoNumber: "AMS",
|
|
108
|
+
useLabelIds: true
|
|
109
|
+
},
|
|
110
|
+
extensions: ["extpfeil.js", "mediawiki-texvc.js"],
|
|
111
|
+
Macros: { bm: "\\boldsymbol" }
|
|
74
112
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
};
|
|
83
|
-
_config = this._defaultConfig;
|
|
84
|
-
_initTask;
|
|
113
|
+
CommonHTML: { linebreaks: { automatic: true } },
|
|
114
|
+
"HTML-CSS": { linebreaks: { automatic: true } },
|
|
115
|
+
SVG: { linebreaks: { automatic: true } },
|
|
116
|
+
skipStartupTypeset: true
|
|
117
|
+
};
|
|
118
|
+
this._config = this._defaultConfig;
|
|
119
|
+
}
|
|
85
120
|
get _global() {
|
|
86
|
-
|
|
121
|
+
var _a;
|
|
122
|
+
return (_a = this._config.document.defaultView) != null ? _a : window;
|
|
87
123
|
}
|
|
88
124
|
render(container, callback) {
|
|
89
125
|
if (!this._config.isEnabled)
|
|
@@ -115,15 +151,14 @@ var Mathjax2Renderer = class {
|
|
|
115
151
|
timeoutSeconds: 10,
|
|
116
152
|
appendTo: document.head
|
|
117
153
|
}).then(() => {
|
|
154
|
+
var _a;
|
|
118
155
|
const { MathJax } = this._global;
|
|
119
156
|
if (MathJax) {
|
|
120
157
|
MathJax.Hub.Config(
|
|
121
|
-
tapMathJaxConfig
|
|
158
|
+
(_a = tapMathJaxConfig == null ? void 0 : tapMathJaxConfig.call(
|
|
122
159
|
void 0,
|
|
123
160
|
Object.assign({}, this._defaultMathJaxConfig)
|
|
124
|
-
)
|
|
125
|
-
...this._defaultMathJaxConfig
|
|
126
|
-
}
|
|
161
|
+
)) != null ? _a : __spreadValues({}, this._defaultMathJaxConfig)
|
|
127
162
|
);
|
|
128
163
|
MathJax.Hub.Configured();
|
|
129
164
|
return MathJax;
|
|
@@ -132,34 +167,35 @@ var Mathjax2Renderer = class {
|
|
|
132
167
|
}
|
|
133
168
|
};
|
|
134
169
|
var MathJax3Renderer = class {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
[
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
170
|
+
constructor() {
|
|
171
|
+
this._defaultConfig = defaultConfig[1 /* MathJax3 */];
|
|
172
|
+
this._defaultMathJaxConfig = {
|
|
173
|
+
tex: {
|
|
174
|
+
inlineMath: [
|
|
175
|
+
["$", "$"],
|
|
176
|
+
["\\(", "\\)"]
|
|
177
|
+
],
|
|
178
|
+
processEscapes: true,
|
|
179
|
+
tags: "ams",
|
|
180
|
+
useLabelIds: true,
|
|
181
|
+
macros: {
|
|
182
|
+
bm: "\\boldsymbol"
|
|
183
|
+
},
|
|
184
|
+
packages: { "[+]": ["noerrors", "extpfeil"] }
|
|
147
185
|
},
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
_config = this._defaultConfig;
|
|
162
|
-
_initTask;
|
|
186
|
+
options: {
|
|
187
|
+
processHtmlClass: "math",
|
|
188
|
+
ignoreHtmlClass: "tex2jax_ignore"
|
|
189
|
+
},
|
|
190
|
+
loader: {
|
|
191
|
+
load: ["[tex]/noerrors", "[tex]/extpfeil"]
|
|
192
|
+
},
|
|
193
|
+
startup: {
|
|
194
|
+
typeset: false
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
this._config = this._defaultConfig;
|
|
198
|
+
}
|
|
163
199
|
config(value) {
|
|
164
200
|
this._config = Object.assign({}, this._defaultConfig, value);
|
|
165
201
|
return this;
|
|
@@ -170,13 +206,14 @@ var MathJax3Renderer = class {
|
|
|
170
206
|
return this.init().then((mathjax) => {
|
|
171
207
|
mathjax ? mathjax.startup.promise = mathjax.startup.promise.then(
|
|
172
208
|
() => mathjax.typesetPromise([container]).then(() => {
|
|
209
|
+
var _a;
|
|
173
210
|
try {
|
|
174
|
-
this._config.onRendered
|
|
211
|
+
(_a = this._config.onRendered) == null ? void 0 : _a.call(void 0, mathjax);
|
|
175
212
|
} catch (e) {
|
|
176
213
|
console.error(e);
|
|
177
214
|
}
|
|
178
215
|
try {
|
|
179
|
-
callback
|
|
216
|
+
callback == null ? void 0 : callback.call(void 0);
|
|
180
217
|
} catch (e) {
|
|
181
218
|
console.error(e);
|
|
182
219
|
}
|
|
@@ -185,17 +222,18 @@ var MathJax3Renderer = class {
|
|
|
185
222
|
}).catch(console.warn);
|
|
186
223
|
}
|
|
187
224
|
init() {
|
|
188
|
-
|
|
225
|
+
var _a;
|
|
226
|
+
return ((_a = this._initTask) != null ? _a : this._initTask = new Promise((resolve, reject) => {
|
|
227
|
+
var _a2, _b;
|
|
189
228
|
const { entryScript, tapMathJaxConfig, document: _document } = this._config;
|
|
190
|
-
const _window = _document.defaultView
|
|
191
|
-
_window.MathJax = tapMathJaxConfig
|
|
192
|
-
...this._defaultMathJaxConfig
|
|
193
|
-
}) ?? { ...this._defaultMathJaxConfig };
|
|
229
|
+
const _window = (_a2 = _document.defaultView) != null ? _a2 : window;
|
|
230
|
+
_window.MathJax = (_b = tapMathJaxConfig == null ? void 0 : tapMathJaxConfig.call(void 0, __spreadValues({}, this._defaultMathJaxConfig))) != null ? _b : __spreadValues({}, this._defaultMathJaxConfig);
|
|
194
231
|
if (!_window.MathJax.startup) {
|
|
195
232
|
_window.MathJax.startup = {};
|
|
196
233
|
}
|
|
197
234
|
_window.MathJax.startup.ready = () => {
|
|
198
|
-
|
|
235
|
+
var _a3, _b2;
|
|
236
|
+
(_b2 = (_a3 = _window.MathJax) == null ? void 0 : _a3.startup) == null ? void 0 : _b2.defaultReady();
|
|
199
237
|
resolve(_window.MathJax);
|
|
200
238
|
};
|
|
201
239
|
(0, import_load_script_css.loadScript)({
|
|
@@ -208,38 +246,43 @@ var MathJax3Renderer = class {
|
|
|
208
246
|
}
|
|
209
247
|
};
|
|
210
248
|
var KatexRenderer = class {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
249
|
+
constructor() {
|
|
250
|
+
this._defaultConfig = defaultConfig[2 /* Katex */];
|
|
251
|
+
this._defaultKatexOptions = {
|
|
252
|
+
delimiters: [
|
|
253
|
+
{ left: "$$", right: "$$", display: true },
|
|
254
|
+
{ left: "$", right: "$", display: false },
|
|
255
|
+
{ left: "\\(", right: "\\)", display: false },
|
|
256
|
+
{ left: "\\[", right: "\\]", display: true }
|
|
257
|
+
]
|
|
258
|
+
};
|
|
259
|
+
this._config = this._defaultConfig;
|
|
260
|
+
this._katexOption = Object.assign({}, this._defaultKatexOptions);
|
|
261
|
+
}
|
|
223
262
|
get _global() {
|
|
224
|
-
|
|
263
|
+
var _a;
|
|
264
|
+
return (_a = this._config.document.defaultView) != null ? _a : window;
|
|
225
265
|
}
|
|
226
266
|
config(value) {
|
|
227
267
|
this._config = Object.assign({}, this._defaultConfig, value);
|
|
228
268
|
return this;
|
|
229
269
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
callback
|
|
239
|
-
|
|
270
|
+
render(container, callback) {
|
|
271
|
+
return __async(this, null, function* () {
|
|
272
|
+
if (!this._config.isEnabled) {
|
|
273
|
+
return Promise.resolve();
|
|
274
|
+
}
|
|
275
|
+
yield this.init();
|
|
276
|
+
const global = this._global;
|
|
277
|
+
global.renderMathInElement(container, this._katexOption);
|
|
278
|
+
if (callback) {
|
|
279
|
+
callback();
|
|
280
|
+
}
|
|
281
|
+
});
|
|
240
282
|
}
|
|
241
283
|
init() {
|
|
242
|
-
|
|
284
|
+
var _a;
|
|
285
|
+
return ((_a = this._initTask) != null ? _a : this._initTask = new Promise((resolve, reject) => {
|
|
243
286
|
const { entryScript, document: _document } = this._config;
|
|
244
287
|
Promise.all([
|
|
245
288
|
(0, import_load_script_css.loadCss)({
|
|
@@ -257,12 +300,11 @@ var KatexRenderer = class {
|
|
|
257
300
|
id: "katex-auto-render",
|
|
258
301
|
appendTo: _document.head
|
|
259
302
|
}).then(() => {
|
|
260
|
-
|
|
303
|
+
var _a2, _b;
|
|
304
|
+
this._katexOption = (_b = (_a2 = this._config.tapMathJaxConfig) == null ? void 0 : _a2.call(
|
|
261
305
|
void 0,
|
|
262
306
|
this._katexOption
|
|
263
|
-
)
|
|
264
|
-
...this._defaultKatexOptions
|
|
265
|
-
};
|
|
307
|
+
)) != null ? _b : __spreadValues({}, this._defaultKatexOptions);
|
|
266
308
|
resolve();
|
|
267
309
|
})).catch(reject);
|
|
268
310
|
})).catch(() => this._initTask = void 0);
|
|
@@ -5279,6 +5279,7 @@ var presets_exports = {};
|
|
|
5279
5279
|
__export(presets_exports, {
|
|
5280
5280
|
HighlightCodeLinesPlugin: () => highlightCodeLines,
|
|
5281
5281
|
ImageSizePlugin: () => ImageSizePlugin,
|
|
5282
|
+
MarkdownIt: () => import_markdown_it.default,
|
|
5282
5283
|
MultilineBlockquotePlugin: () => MultilineBlockquotePlugin,
|
|
5283
5284
|
MultilineBlockquoteRule: () => MultilineBlockquoteRule,
|
|
5284
5285
|
anchorOption: () => anchorOption,
|
|
@@ -5618,7 +5619,7 @@ var uniqueCustomIdAttr = (state) => {
|
|
|
5618
5619
|
const { tokens } = state;
|
|
5619
5620
|
let map;
|
|
5620
5621
|
tokens.filter((x) => !!x.attrGet("id")).forEach((token) => {
|
|
5621
|
-
map
|
|
5622
|
+
map != null ? map : map = {};
|
|
5622
5623
|
const idAttrValue = token.attrGet("id");
|
|
5623
5624
|
if (map.hasOwnProperty(idAttrValue)) {
|
|
5624
5625
|
const count = map[idAttrValue];
|
|
@@ -5683,7 +5684,7 @@ var MultilineBlockquoteRule = (state, startLine, endLine) => {
|
|
|
5683
5684
|
|
|
5684
5685
|
// src/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.ts
|
|
5685
5686
|
var MultilineBlockquotePlugin = (md, options) => {
|
|
5686
|
-
options
|
|
5687
|
+
options != null ? options : options = {};
|
|
5687
5688
|
md.block.ruler.before("blockquote", "multiline_blockquote", (...args) => {
|
|
5688
5689
|
if (options.enable != null && !options.enable(md))
|
|
5689
5690
|
return false;
|
|
@@ -6106,7 +6107,7 @@ var defaultCodeHighlight = (str, lang) => {
|
|
|
6106
6107
|
try {
|
|
6107
6108
|
const result = import_highlight.default.highlight(lang, str, true);
|
|
6108
6109
|
return `<pre class="hljs"><code data-lang="${result.language}">${result.value}</code></pre>`;
|
|
6109
|
-
} catch {
|
|
6110
|
+
} catch (e) {
|
|
6110
6111
|
}
|
|
6111
6112
|
}
|
|
6112
6113
|
return `<pre class="hljs"><code>${mdUtils.escapeHtml(str)}</code></pre>`;
|
|
@@ -6141,16 +6142,16 @@ var markdownItFactory = ({
|
|
|
6141
6142
|
} = defaultMarkdownItOption) => {
|
|
6142
6143
|
const mdOpt = {
|
|
6143
6144
|
html,
|
|
6144
|
-
breaks: preserveLineBreaks
|
|
6145
|
+
breaks: preserveLineBreaks != null ? preserveLineBreaks : true,
|
|
6145
6146
|
linkify: true
|
|
6146
6147
|
};
|
|
6147
|
-
taskListsOption
|
|
6148
|
-
linkifyOption = Object.assign({}, defaultLinkifyOptions, linkifyOption
|
|
6148
|
+
taskListsOption != null ? taskListsOption : taskListsOption = defaultTaskListsOption;
|
|
6149
|
+
linkifyOption = Object.assign({}, defaultLinkifyOptions, linkifyOption != null ? linkifyOption : defaultLinkifyOptions);
|
|
6149
6150
|
if (codeHighlight) {
|
|
6150
6151
|
mdOpt.highlight = defaultCodeHighlight;
|
|
6151
6152
|
}
|
|
6152
|
-
const md = new import_markdown_it.default(mdOpt).use(import_markdown_it_container.default).use(diagramPlugin).use(import_markdown_it_anchor.default, anchorOption).use(plugin).use(import_markdown_it_abbr.default).use(import_markdown_it_deflist.default).use(import_markdown_it_emoji.default).use(import_markdown_it_footnote.default).use(import_markdown_it_mark.default).use(import_markdown_it_sub.default).use(import_markdown_it_sup.default).use(highlightCodeLines).use(import_markdown_it_lazy_headers.default).use(import_markdown_it_task_lists.default, taskListsOption).use(HtmlFilterPlugin).use(...addLinkAttributes).use(MultilineBlockquotePlugin).use(MetaPlugin, { show: showFrontMatter
|
|
6153
|
-
if (enableMarkdownAttrs
|
|
6153
|
+
const md = new import_markdown_it.default(mdOpt).use(import_markdown_it_container.default).use(diagramPlugin).use(import_markdown_it_anchor.default, anchorOption).use(plugin).use(import_markdown_it_abbr.default).use(import_markdown_it_deflist.default).use(import_markdown_it_emoji.default).use(import_markdown_it_footnote.default).use(import_markdown_it_mark.default).use(import_markdown_it_sub.default).use(import_markdown_it_sup.default).use(highlightCodeLines).use(import_markdown_it_lazy_headers.default).use(import_markdown_it_task_lists.default, taskListsOption).use(HtmlFilterPlugin).use(...addLinkAttributes).use(MultilineBlockquotePlugin).use(MetaPlugin, { show: showFrontMatter != null ? showFrontMatter : true });
|
|
6154
|
+
if (enableMarkdownAttrs != null ? enableMarkdownAttrs : true) {
|
|
6154
6155
|
md.use(import_markdown_it_attrs.default, {
|
|
6155
6156
|
allowedAttributes: ["id", "class", LineNumberAttrRegex],
|
|
6156
6157
|
disableParagraphBlock: true
|
|
@@ -6188,6 +6189,7 @@ var markdownItFactory = ({
|
|
|
6188
6189
|
0 && (module.exports = {
|
|
6189
6190
|
HighlightCodeLinesPlugin,
|
|
6190
6191
|
ImageSizePlugin,
|
|
6192
|
+
MarkdownIt,
|
|
6191
6193
|
MultilineBlockquotePlugin,
|
|
6192
6194
|
MultilineBlockquoteRule,
|
|
6193
6195
|
anchorOption,
|
|
@@ -1,33 +1,44 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { loadCss, loadScript } from '@cnblogs/load-script-css';
|
|
2
11
|
import { defaultConfig, MathEngine, } from './model';
|
|
3
12
|
export class Mathjax2Renderer {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
[
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
constructor() {
|
|
14
|
+
this._defaultConfig = defaultConfig[MathEngine.MathJax2];
|
|
15
|
+
this._defaultMathJaxConfig = {
|
|
16
|
+
tex2jax: {
|
|
17
|
+
inlineMath: [
|
|
18
|
+
['$', '$'],
|
|
19
|
+
['\\(', '\\)'],
|
|
20
|
+
],
|
|
21
|
+
processClass: 'math',
|
|
22
|
+
processEscapes: true,
|
|
23
|
+
},
|
|
24
|
+
TeX: {
|
|
25
|
+
equationNumbers: {
|
|
26
|
+
autoNumber: 'AMS',
|
|
27
|
+
useLabelIds: true,
|
|
28
|
+
},
|
|
29
|
+
extensions: ['extpfeil.js', 'mediawiki-texvc.js'],
|
|
30
|
+
Macros: { bm: '\\boldsymbol' },
|
|
18
31
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
_config = this._defaultConfig;
|
|
28
|
-
_initTask;
|
|
32
|
+
CommonHTML: { linebreaks: { automatic: true } },
|
|
33
|
+
'HTML-CSS': { linebreaks: { automatic: true } },
|
|
34
|
+
SVG: { linebreaks: { automatic: true } },
|
|
35
|
+
skipStartupTypeset: true,
|
|
36
|
+
};
|
|
37
|
+
this._config = this._defaultConfig;
|
|
38
|
+
}
|
|
29
39
|
get _global() {
|
|
30
|
-
|
|
40
|
+
var _a;
|
|
41
|
+
return ((_a = this._config.document.defaultView) !== null && _a !== void 0 ? _a : window);
|
|
31
42
|
}
|
|
32
43
|
render(container, callback) {
|
|
33
44
|
if (!this._config.isEnabled)
|
|
@@ -62,11 +73,10 @@ export class Mathjax2Renderer {
|
|
|
62
73
|
appendTo: document.head,
|
|
63
74
|
})
|
|
64
75
|
.then(() => {
|
|
76
|
+
var _a;
|
|
65
77
|
const { MathJax } = this._global;
|
|
66
78
|
if (MathJax) {
|
|
67
|
-
MathJax.Hub.Config(tapMathJaxConfig
|
|
68
|
-
...this._defaultMathJaxConfig,
|
|
69
|
-
});
|
|
79
|
+
MathJax.Hub.Config((_a = tapMathJaxConfig === null || tapMathJaxConfig === void 0 ? void 0 : tapMathJaxConfig.call(undefined, Object.assign({}, this._defaultMathJaxConfig))) !== null && _a !== void 0 ? _a : Object.assign({}, this._defaultMathJaxConfig));
|
|
70
80
|
MathJax.Hub.Configured();
|
|
71
81
|
return MathJax;
|
|
72
82
|
}
|
|
@@ -75,34 +85,35 @@ export class Mathjax2Renderer {
|
|
|
75
85
|
}
|
|
76
86
|
}
|
|
77
87
|
export class MathJax3Renderer {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
[
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
constructor() {
|
|
89
|
+
this._defaultConfig = defaultConfig[MathEngine.MathJax3];
|
|
90
|
+
this._defaultMathJaxConfig = {
|
|
91
|
+
tex: {
|
|
92
|
+
inlineMath: [
|
|
93
|
+
['$', '$'],
|
|
94
|
+
['\\(', '\\)'],
|
|
95
|
+
],
|
|
96
|
+
processEscapes: true,
|
|
97
|
+
tags: 'ams',
|
|
98
|
+
useLabelIds: true,
|
|
99
|
+
macros: {
|
|
100
|
+
bm: '\\boldsymbol',
|
|
101
|
+
},
|
|
102
|
+
packages: { '[+]': ['noerrors', 'extpfeil'] },
|
|
103
|
+
},
|
|
104
|
+
options: {
|
|
105
|
+
processHtmlClass: 'math',
|
|
106
|
+
ignoreHtmlClass: 'tex2jax_ignore',
|
|
107
|
+
},
|
|
108
|
+
loader: {
|
|
109
|
+
load: ['[tex]/noerrors', '[tex]/extpfeil'],
|
|
110
|
+
},
|
|
111
|
+
startup: {
|
|
112
|
+
typeset: false,
|
|
90
113
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
processHtmlClass: 'math',
|
|
95
|
-
ignoreHtmlClass: 'tex2jax_ignore',
|
|
96
|
-
},
|
|
97
|
-
loader: {
|
|
98
|
-
load: ['[tex]/noerrors', '[tex]/extpfeil'],
|
|
99
|
-
},
|
|
100
|
-
startup: {
|
|
101
|
-
typeset: false,
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
_config = this._defaultConfig;
|
|
105
|
-
_initTask;
|
|
114
|
+
};
|
|
115
|
+
this._config = this._defaultConfig;
|
|
116
|
+
}
|
|
106
117
|
config(value) {
|
|
107
118
|
this._config = Object.assign({}, this._defaultConfig, value);
|
|
108
119
|
return this;
|
|
@@ -114,14 +125,15 @@ export class MathJax3Renderer {
|
|
|
114
125
|
.then(mathjax => {
|
|
115
126
|
mathjax
|
|
116
127
|
? (mathjax.startup.promise = mathjax.startup.promise.then(() => mathjax.typesetPromise([container]).then(() => {
|
|
128
|
+
var _a;
|
|
117
129
|
try {
|
|
118
|
-
this._config.onRendered
|
|
130
|
+
(_a = this._config.onRendered) === null || _a === void 0 ? void 0 : _a.call(undefined, mathjax);
|
|
119
131
|
}
|
|
120
132
|
catch (e) {
|
|
121
133
|
console.error(e);
|
|
122
134
|
}
|
|
123
135
|
try {
|
|
124
|
-
callback
|
|
136
|
+
callback === null || callback === void 0 ? void 0 : callback.call(undefined);
|
|
125
137
|
}
|
|
126
138
|
catch (e) {
|
|
127
139
|
console.error(e);
|
|
@@ -132,17 +144,18 @@ export class MathJax3Renderer {
|
|
|
132
144
|
.catch(console.warn);
|
|
133
145
|
}
|
|
134
146
|
init() {
|
|
135
|
-
|
|
147
|
+
var _a;
|
|
148
|
+
return ((_a = this._initTask) !== null && _a !== void 0 ? _a : (this._initTask = new Promise((resolve, reject) => {
|
|
149
|
+
var _a, _b;
|
|
136
150
|
const { entryScript, tapMathJaxConfig, document: _document } = this._config;
|
|
137
|
-
const _window = (_document.defaultView
|
|
138
|
-
_window.MathJax = tapMathJaxConfig
|
|
139
|
-
...this._defaultMathJaxConfig,
|
|
140
|
-
}) ?? { ...this._defaultMathJaxConfig };
|
|
151
|
+
const _window = ((_a = _document.defaultView) !== null && _a !== void 0 ? _a : window);
|
|
152
|
+
_window.MathJax = (_b = tapMathJaxConfig === null || tapMathJaxConfig === void 0 ? void 0 : tapMathJaxConfig.call(undefined, Object.assign({}, this._defaultMathJaxConfig))) !== null && _b !== void 0 ? _b : Object.assign({}, this._defaultMathJaxConfig);
|
|
141
153
|
if (!_window.MathJax.startup) {
|
|
142
154
|
_window.MathJax.startup = {};
|
|
143
155
|
}
|
|
144
156
|
_window.MathJax.startup.ready = () => {
|
|
145
|
-
|
|
157
|
+
var _a, _b;
|
|
158
|
+
(_b = (_a = _window.MathJax) === null || _a === void 0 ? void 0 : _a.startup) === null || _b === void 0 ? void 0 : _b.defaultReady();
|
|
146
159
|
resolve(_window.MathJax);
|
|
147
160
|
};
|
|
148
161
|
loadScript({
|
|
@@ -151,42 +164,47 @@ export class MathJax3Renderer {
|
|
|
151
164
|
executionStrategy: 'defer',
|
|
152
165
|
appendTo: _window.document.head,
|
|
153
166
|
}).catch(reject);
|
|
154
|
-
})).catch(() => (this._initTask = undefined));
|
|
167
|
+
}))).catch(() => (this._initTask = undefined));
|
|
155
168
|
}
|
|
156
169
|
}
|
|
157
170
|
export class KatexRenderer {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
constructor() {
|
|
172
|
+
this._defaultConfig = defaultConfig[MathEngine.Katex];
|
|
173
|
+
this._defaultKatexOptions = {
|
|
174
|
+
delimiters: [
|
|
175
|
+
{ left: "$$", right: "$$", display: true },
|
|
176
|
+
{ left: "$", right: "$", display: false },
|
|
177
|
+
{ left: "\\(", right: "\\)", display: false },
|
|
178
|
+
{ left: "\\[", right: "\\]", display: true }
|
|
179
|
+
],
|
|
180
|
+
};
|
|
181
|
+
this._config = this._defaultConfig;
|
|
182
|
+
this._katexOption = Object.assign({}, this._defaultKatexOptions);
|
|
183
|
+
}
|
|
170
184
|
get _global() {
|
|
171
|
-
|
|
185
|
+
var _a;
|
|
186
|
+
return ((_a = this._config.document.defaultView) !== null && _a !== void 0 ? _a : window);
|
|
172
187
|
}
|
|
173
188
|
config(value) {
|
|
174
189
|
this._config = Object.assign({}, this._defaultConfig, value);
|
|
175
190
|
return this;
|
|
176
191
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
callback
|
|
186
|
-
|
|
192
|
+
render(container, callback) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
if (!this._config.isEnabled) {
|
|
195
|
+
return Promise.resolve();
|
|
196
|
+
}
|
|
197
|
+
yield this.init();
|
|
198
|
+
const global = this._global;
|
|
199
|
+
global.renderMathInElement(container, this._katexOption);
|
|
200
|
+
if (callback) {
|
|
201
|
+
callback();
|
|
202
|
+
}
|
|
203
|
+
});
|
|
187
204
|
}
|
|
188
205
|
init() {
|
|
189
|
-
|
|
206
|
+
var _a;
|
|
207
|
+
return ((_a = this._initTask) !== null && _a !== void 0 ? _a : (this._initTask = new Promise((resolve, reject) => {
|
|
190
208
|
const { entryScript, document: _document } = this._config;
|
|
191
209
|
Promise.all([
|
|
192
210
|
loadCss({
|
|
@@ -204,12 +222,11 @@ export class KatexRenderer {
|
|
|
204
222
|
id: 'katex-auto-render',
|
|
205
223
|
appendTo: _document.head,
|
|
206
224
|
}).then(() => {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
};
|
|
225
|
+
var _a, _b;
|
|
226
|
+
this._katexOption = (_b = (_a = this._config.tapMathJaxConfig) === null || _a === void 0 ? void 0 : _a.call(undefined, this._katexOption)) !== null && _b !== void 0 ? _b : Object.assign({}, this._defaultKatexOptions);
|
|
210
227
|
resolve();
|
|
211
228
|
})).catch(reject);
|
|
212
|
-
})).catch(() => (this._initTask = undefined));
|
|
229
|
+
}))).catch(() => (this._initTask = undefined));
|
|
213
230
|
}
|
|
214
231
|
}
|
|
215
232
|
//# sourceMappingURL=impl.js.map
|