@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
package/dist/commonjs/index.cjs
CHANGED
|
@@ -2,8 +2,22 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
7
21
|
var __commonJS = (cb, mod) => function __require() {
|
|
8
22
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
23
|
};
|
|
@@ -28,6 +42,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
42
|
mod
|
|
29
43
|
));
|
|
30
44
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
|
+
var __async = (__this, __arguments, generator) => {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
var fulfilled = (value) => {
|
|
48
|
+
try {
|
|
49
|
+
step(generator.next(value));
|
|
50
|
+
} catch (e) {
|
|
51
|
+
reject(e);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var rejected = (value) => {
|
|
55
|
+
try {
|
|
56
|
+
step(generator.throw(value));
|
|
57
|
+
} catch (e) {
|
|
58
|
+
reject(e);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
62
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
63
|
+
});
|
|
64
|
+
};
|
|
31
65
|
|
|
32
66
|
// node_modules/entities/lib/maps/entities.json
|
|
33
67
|
var require_entities = __commonJS({
|
|
@@ -5279,6 +5313,7 @@ var src_exports = {};
|
|
|
5279
5313
|
__export(src_exports, {
|
|
5280
5314
|
HighlightCodeLinesPlugin: () => highlightCodeLines,
|
|
5281
5315
|
ImageSizePlugin: () => ImageSizePlugin,
|
|
5316
|
+
MarkdownIt: () => import_markdown_it.default,
|
|
5282
5317
|
MathEngine: () => MathEngine,
|
|
5283
5318
|
MultilineBlockquotePlugin: () => MultilineBlockquotePlugin,
|
|
5284
5319
|
MultilineBlockquoteRule: () => MultilineBlockquoteRule,
|
|
@@ -5622,7 +5657,7 @@ var uniqueCustomIdAttr = (state) => {
|
|
|
5622
5657
|
const { tokens } = state;
|
|
5623
5658
|
let map;
|
|
5624
5659
|
tokens.filter((x) => !!x.attrGet("id")).forEach((token) => {
|
|
5625
|
-
map
|
|
5660
|
+
map != null ? map : map = {};
|
|
5626
5661
|
const idAttrValue = token.attrGet("id");
|
|
5627
5662
|
if (map.hasOwnProperty(idAttrValue)) {
|
|
5628
5663
|
const count = map[idAttrValue];
|
|
@@ -5687,7 +5722,7 @@ var MultilineBlockquoteRule = (state, startLine, endLine) => {
|
|
|
5687
5722
|
|
|
5688
5723
|
// src/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.ts
|
|
5689
5724
|
var MultilineBlockquotePlugin = (md, options) => {
|
|
5690
|
-
options
|
|
5725
|
+
options != null ? options : options = {};
|
|
5691
5726
|
md.block.ruler.before("blockquote", "multiline_blockquote", (...args) => {
|
|
5692
5727
|
if (options.enable != null && !options.enable(md))
|
|
5693
5728
|
return false;
|
|
@@ -6110,7 +6145,7 @@ var defaultCodeHighlight = (str, lang) => {
|
|
|
6110
6145
|
try {
|
|
6111
6146
|
const result = import_highlight.default.highlight(lang, str, true);
|
|
6112
6147
|
return `<pre class="hljs"><code data-lang="${result.language}">${result.value}</code></pre>`;
|
|
6113
|
-
} catch {
|
|
6148
|
+
} catch (e) {
|
|
6114
6149
|
}
|
|
6115
6150
|
}
|
|
6116
6151
|
return `<pre class="hljs"><code>${mdUtils.escapeHtml(str)}</code></pre>`;
|
|
@@ -6145,16 +6180,16 @@ var markdownItFactory = ({
|
|
|
6145
6180
|
} = defaultMarkdownItOption) => {
|
|
6146
6181
|
const mdOpt = {
|
|
6147
6182
|
html,
|
|
6148
|
-
breaks: preserveLineBreaks
|
|
6183
|
+
breaks: preserveLineBreaks != null ? preserveLineBreaks : true,
|
|
6149
6184
|
linkify: true
|
|
6150
6185
|
};
|
|
6151
|
-
taskListsOption
|
|
6152
|
-
linkifyOption = Object.assign({}, defaultLinkifyOptions, linkifyOption
|
|
6186
|
+
taskListsOption != null ? taskListsOption : taskListsOption = defaultTaskListsOption;
|
|
6187
|
+
linkifyOption = Object.assign({}, defaultLinkifyOptions, linkifyOption != null ? linkifyOption : defaultLinkifyOptions);
|
|
6153
6188
|
if (codeHighlight) {
|
|
6154
6189
|
mdOpt.highlight = defaultCodeHighlight;
|
|
6155
6190
|
}
|
|
6156
|
-
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
|
|
6157
|
-
if (enableMarkdownAttrs
|
|
6191
|
+
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 });
|
|
6192
|
+
if (enableMarkdownAttrs != null ? enableMarkdownAttrs : true) {
|
|
6158
6193
|
md.use(import_markdown_it_attrs.default, {
|
|
6159
6194
|
allowedAttributes: ["id", "class", LineNumberAttrRegex],
|
|
6160
6195
|
disableParagraphBlock: true
|
|
@@ -6222,33 +6257,35 @@ var defaultConfig = {
|
|
|
6222
6257
|
|
|
6223
6258
|
// src/math/impl.ts
|
|
6224
6259
|
var Mathjax2Renderer = class {
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
[
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
TeX: {
|
|
6236
|
-
equationNumbers: {
|
|
6237
|
-
autoNumber: "AMS",
|
|
6238
|
-
useLabelIds: true
|
|
6260
|
+
constructor() {
|
|
6261
|
+
this._defaultConfig = defaultConfig[0 /* MathJax2 */];
|
|
6262
|
+
this._defaultMathJaxConfig = {
|
|
6263
|
+
tex2jax: {
|
|
6264
|
+
inlineMath: [
|
|
6265
|
+
["$", "$"],
|
|
6266
|
+
["\\(", "\\)"]
|
|
6267
|
+
],
|
|
6268
|
+
processClass: "math",
|
|
6269
|
+
processEscapes: true
|
|
6239
6270
|
},
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6271
|
+
TeX: {
|
|
6272
|
+
equationNumbers: {
|
|
6273
|
+
autoNumber: "AMS",
|
|
6274
|
+
useLabelIds: true
|
|
6275
|
+
},
|
|
6276
|
+
extensions: ["extpfeil.js", "mediawiki-texvc.js"],
|
|
6277
|
+
Macros: { bm: "\\boldsymbol" }
|
|
6278
|
+
},
|
|
6279
|
+
CommonHTML: { linebreaks: { automatic: true } },
|
|
6280
|
+
"HTML-CSS": { linebreaks: { automatic: true } },
|
|
6281
|
+
SVG: { linebreaks: { automatic: true } },
|
|
6282
|
+
skipStartupTypeset: true
|
|
6283
|
+
};
|
|
6284
|
+
this._config = this._defaultConfig;
|
|
6285
|
+
}
|
|
6250
6286
|
get _global() {
|
|
6251
|
-
|
|
6287
|
+
var _a;
|
|
6288
|
+
return (_a = this._config.document.defaultView) != null ? _a : window;
|
|
6252
6289
|
}
|
|
6253
6290
|
render(container, callback) {
|
|
6254
6291
|
if (!this._config.isEnabled)
|
|
@@ -6280,15 +6317,14 @@ var Mathjax2Renderer = class {
|
|
|
6280
6317
|
timeoutSeconds: 10,
|
|
6281
6318
|
appendTo: document.head
|
|
6282
6319
|
}).then(() => {
|
|
6320
|
+
var _a;
|
|
6283
6321
|
const { MathJax } = this._global;
|
|
6284
6322
|
if (MathJax) {
|
|
6285
6323
|
MathJax.Hub.Config(
|
|
6286
|
-
tapMathJaxConfig
|
|
6324
|
+
(_a = tapMathJaxConfig == null ? void 0 : tapMathJaxConfig.call(
|
|
6287
6325
|
void 0,
|
|
6288
6326
|
Object.assign({}, this._defaultMathJaxConfig)
|
|
6289
|
-
)
|
|
6290
|
-
...this._defaultMathJaxConfig
|
|
6291
|
-
}
|
|
6327
|
+
)) != null ? _a : __spreadValues({}, this._defaultMathJaxConfig)
|
|
6292
6328
|
);
|
|
6293
6329
|
MathJax.Hub.Configured();
|
|
6294
6330
|
return MathJax;
|
|
@@ -6297,34 +6333,35 @@ var Mathjax2Renderer = class {
|
|
|
6297
6333
|
}
|
|
6298
6334
|
};
|
|
6299
6335
|
var MathJax3Renderer = class {
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
[
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6336
|
+
constructor() {
|
|
6337
|
+
this._defaultConfig = defaultConfig[1 /* MathJax3 */];
|
|
6338
|
+
this._defaultMathJaxConfig = {
|
|
6339
|
+
tex: {
|
|
6340
|
+
inlineMath: [
|
|
6341
|
+
["$", "$"],
|
|
6342
|
+
["\\(", "\\)"]
|
|
6343
|
+
],
|
|
6344
|
+
processEscapes: true,
|
|
6345
|
+
tags: "ams",
|
|
6346
|
+
useLabelIds: true,
|
|
6347
|
+
macros: {
|
|
6348
|
+
bm: "\\boldsymbol"
|
|
6349
|
+
},
|
|
6350
|
+
packages: { "[+]": ["noerrors", "extpfeil"] }
|
|
6312
6351
|
},
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
}
|
|
6326
|
-
_config = this._defaultConfig;
|
|
6327
|
-
_initTask;
|
|
6352
|
+
options: {
|
|
6353
|
+
processHtmlClass: "math",
|
|
6354
|
+
ignoreHtmlClass: "tex2jax_ignore"
|
|
6355
|
+
},
|
|
6356
|
+
loader: {
|
|
6357
|
+
load: ["[tex]/noerrors", "[tex]/extpfeil"]
|
|
6358
|
+
},
|
|
6359
|
+
startup: {
|
|
6360
|
+
typeset: false
|
|
6361
|
+
}
|
|
6362
|
+
};
|
|
6363
|
+
this._config = this._defaultConfig;
|
|
6364
|
+
}
|
|
6328
6365
|
config(value) {
|
|
6329
6366
|
this._config = Object.assign({}, this._defaultConfig, value);
|
|
6330
6367
|
return this;
|
|
@@ -6335,13 +6372,14 @@ var MathJax3Renderer = class {
|
|
|
6335
6372
|
return this.init().then((mathjax) => {
|
|
6336
6373
|
mathjax ? mathjax.startup.promise = mathjax.startup.promise.then(
|
|
6337
6374
|
() => mathjax.typesetPromise([container]).then(() => {
|
|
6375
|
+
var _a;
|
|
6338
6376
|
try {
|
|
6339
|
-
this._config.onRendered
|
|
6377
|
+
(_a = this._config.onRendered) == null ? void 0 : _a.call(void 0, mathjax);
|
|
6340
6378
|
} catch (e) {
|
|
6341
6379
|
console.error(e);
|
|
6342
6380
|
}
|
|
6343
6381
|
try {
|
|
6344
|
-
callback
|
|
6382
|
+
callback == null ? void 0 : callback.call(void 0);
|
|
6345
6383
|
} catch (e) {
|
|
6346
6384
|
console.error(e);
|
|
6347
6385
|
}
|
|
@@ -6350,17 +6388,18 @@ var MathJax3Renderer = class {
|
|
|
6350
6388
|
}).catch(console.warn);
|
|
6351
6389
|
}
|
|
6352
6390
|
init() {
|
|
6353
|
-
|
|
6391
|
+
var _a;
|
|
6392
|
+
return ((_a = this._initTask) != null ? _a : this._initTask = new Promise((resolve, reject) => {
|
|
6393
|
+
var _a2, _b;
|
|
6354
6394
|
const { entryScript, tapMathJaxConfig, document: _document } = this._config;
|
|
6355
|
-
const _window = _document.defaultView
|
|
6356
|
-
_window.MathJax = tapMathJaxConfig
|
|
6357
|
-
...this._defaultMathJaxConfig
|
|
6358
|
-
}) ?? { ...this._defaultMathJaxConfig };
|
|
6395
|
+
const _window = (_a2 = _document.defaultView) != null ? _a2 : window;
|
|
6396
|
+
_window.MathJax = (_b = tapMathJaxConfig == null ? void 0 : tapMathJaxConfig.call(void 0, __spreadValues({}, this._defaultMathJaxConfig))) != null ? _b : __spreadValues({}, this._defaultMathJaxConfig);
|
|
6359
6397
|
if (!_window.MathJax.startup) {
|
|
6360
6398
|
_window.MathJax.startup = {};
|
|
6361
6399
|
}
|
|
6362
6400
|
_window.MathJax.startup.ready = () => {
|
|
6363
|
-
|
|
6401
|
+
var _a3, _b2;
|
|
6402
|
+
(_b2 = (_a3 = _window.MathJax) == null ? void 0 : _a3.startup) == null ? void 0 : _b2.defaultReady();
|
|
6364
6403
|
resolve(_window.MathJax);
|
|
6365
6404
|
};
|
|
6366
6405
|
(0, import_load_script_css.loadScript)({
|
|
@@ -6373,38 +6412,43 @@ var MathJax3Renderer = class {
|
|
|
6373
6412
|
}
|
|
6374
6413
|
};
|
|
6375
6414
|
var KatexRenderer = class {
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6415
|
+
constructor() {
|
|
6416
|
+
this._defaultConfig = defaultConfig[2 /* Katex */];
|
|
6417
|
+
this._defaultKatexOptions = {
|
|
6418
|
+
delimiters: [
|
|
6419
|
+
{ left: "$$", right: "$$", display: true },
|
|
6420
|
+
{ left: "$", right: "$", display: false },
|
|
6421
|
+
{ left: "\\(", right: "\\)", display: false },
|
|
6422
|
+
{ left: "\\[", right: "\\]", display: true }
|
|
6423
|
+
]
|
|
6424
|
+
};
|
|
6425
|
+
this._config = this._defaultConfig;
|
|
6426
|
+
this._katexOption = Object.assign({}, this._defaultKatexOptions);
|
|
6427
|
+
}
|
|
6388
6428
|
get _global() {
|
|
6389
|
-
|
|
6429
|
+
var _a;
|
|
6430
|
+
return (_a = this._config.document.defaultView) != null ? _a : window;
|
|
6390
6431
|
}
|
|
6391
6432
|
config(value) {
|
|
6392
6433
|
this._config = Object.assign({}, this._defaultConfig, value);
|
|
6393
6434
|
return this;
|
|
6394
6435
|
}
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
callback
|
|
6404
|
-
|
|
6436
|
+
render(container, callback) {
|
|
6437
|
+
return __async(this, null, function* () {
|
|
6438
|
+
if (!this._config.isEnabled) {
|
|
6439
|
+
return Promise.resolve();
|
|
6440
|
+
}
|
|
6441
|
+
yield this.init();
|
|
6442
|
+
const global2 = this._global;
|
|
6443
|
+
global2.renderMathInElement(container, this._katexOption);
|
|
6444
|
+
if (callback) {
|
|
6445
|
+
callback();
|
|
6446
|
+
}
|
|
6447
|
+
});
|
|
6405
6448
|
}
|
|
6406
6449
|
init() {
|
|
6407
|
-
|
|
6450
|
+
var _a;
|
|
6451
|
+
return ((_a = this._initTask) != null ? _a : this._initTask = new Promise((resolve, reject) => {
|
|
6408
6452
|
const { entryScript, document: _document } = this._config;
|
|
6409
6453
|
Promise.all([
|
|
6410
6454
|
(0, import_load_script_css.loadCss)({
|
|
@@ -6422,12 +6466,11 @@ var KatexRenderer = class {
|
|
|
6422
6466
|
id: "katex-auto-render",
|
|
6423
6467
|
appendTo: _document.head
|
|
6424
6468
|
}).then(() => {
|
|
6425
|
-
|
|
6469
|
+
var _a2, _b;
|
|
6470
|
+
this._katexOption = (_b = (_a2 = this._config.tapMathJaxConfig) == null ? void 0 : _a2.call(
|
|
6426
6471
|
void 0,
|
|
6427
6472
|
this._katexOption
|
|
6428
|
-
)
|
|
6429
|
-
...this._defaultKatexOptions
|
|
6430
|
-
};
|
|
6473
|
+
)) != null ? _b : __spreadValues({}, this._defaultKatexOptions);
|
|
6431
6474
|
resolve();
|
|
6432
6475
|
})).catch(reject);
|
|
6433
6476
|
})).catch(() => this._initTask = void 0);
|
|
@@ -6451,6 +6494,7 @@ var createMathRenderer = (rendererConfig) => {
|
|
|
6451
6494
|
0 && (module.exports = {
|
|
6452
6495
|
HighlightCodeLinesPlugin,
|
|
6453
6496
|
ImageSizePlugin,
|
|
6497
|
+
MarkdownIt,
|
|
6454
6498
|
MathEngine,
|
|
6455
6499
|
MultilineBlockquotePlugin,
|
|
6456
6500
|
MultilineBlockquoteRule,
|