@cnblogs/markdown-it-presets 1.10.9 → 1.10.11
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 +147 -103
- package/dist/commonjs/math/index.cjs +137 -95
- package/dist/commonjs/presets/index.cjs +10 -8
- package/dist/es2015/math/impl.mjs +111 -94
- package/dist/es2015/math/impl.mjs.map +1 -1
- package/dist/es2015/math/model.mjs +1 -1
- package/dist/es2015/math/model.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/es2015/tsconfig.tsbuildinfo +1 -0
- 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/dist/umd/mathRenderer.js +1 -1
- package/package.json +19 -2
- 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 = {};
|
|
@@ -48,7 +82,7 @@ var defaultConfig = {
|
|
|
48
82
|
isEnabled: true
|
|
49
83
|
},
|
|
50
84
|
[2 /* Katex */]: {
|
|
51
|
-
entryScript: "https://
|
|
85
|
+
entryScript: "https://assets.cnblogs.com/katex/0.16.21/katex.min.js",
|
|
52
86
|
document: window.document,
|
|
53
87
|
engine: 2 /* Katex */,
|
|
54
88
|
isEnabled: true
|
|
@@ -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,42 +246,47 @@ 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)({
|
|
246
|
-
href: "https://
|
|
289
|
+
href: "https://assets.cnblogs.com/katex/0.16.21/katex.min.css",
|
|
247
290
|
id: "katex-style",
|
|
248
291
|
appendTo: _document.head
|
|
249
292
|
}),
|
|
@@ -253,16 +296,15 @@ var KatexRenderer = class {
|
|
|
253
296
|
appendTo: _document.head
|
|
254
297
|
})
|
|
255
298
|
]).then(() => (0, import_load_script_css.loadScript)({
|
|
256
|
-
src: "https://
|
|
299
|
+
src: "https://assets.cnblogs.com/katex/0.16.21/contrib/auto-render.min.js",
|
|
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,
|