@cnblogs/markdown-it-presets 1.9.4 → 1.9.6

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.
Files changed (78) hide show
  1. package/dist/commonjs/index.cjs +936 -19
  2. package/dist/commonjs/math/index.cjs +234 -8
  3. package/dist/commonjs/presets/index.cjs +723 -124
  4. package/dist/es2015/index.mjs +893 -3
  5. package/dist/es2015/math/index.mjs +210 -3
  6. package/dist/es2015/presets/index.mjs +681 -100
  7. package/dist/umd/mathRenderer.js +1 -1
  8. package/package.json +8 -8
  9. package/dist/commonjs/index.cjs.map +0 -1
  10. package/dist/commonjs/math/factory.cjs +0 -17
  11. package/dist/commonjs/math/factory.cjs.map +0 -1
  12. package/dist/commonjs/math/impl.cjs +0 -166
  13. package/dist/commonjs/math/impl.cjs.map +0 -1
  14. package/dist/commonjs/math/index.cjs.map +0 -1
  15. package/dist/commonjs/math/model.cjs +0 -23
  16. package/dist/commonjs/math/model.cjs.map +0 -1
  17. package/dist/commonjs/presets/index.cjs.map +0 -1
  18. package/dist/commonjs/presets/option.cjs +0 -36
  19. package/dist/commonjs/presets/option.cjs.map +0 -1
  20. package/dist/commonjs/presets/plugins/highlight-code-lines.plugin.cjs +0 -52
  21. package/dist/commonjs/presets/plugins/highlight-code-lines.plugin.cjs.map +0 -1
  22. package/dist/commonjs/presets/plugins/html-filter.plugin.cjs +0 -47
  23. package/dist/commonjs/presets/plugins/html-filter.plugin.cjs.map +0 -1
  24. package/dist/commonjs/presets/plugins/meta.cjs +0 -40
  25. package/dist/commonjs/presets/plugins/meta.cjs.map +0 -1
  26. package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.cjs +0 -15
  27. package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.cjs.map +0 -1
  28. package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.rule.cjs +0 -44
  29. package/dist/commonjs/presets/plugins/multiline-blockquote/multiline-blockquote.rule.cjs.map +0 -1
  30. package/dist/commonjs/presets/plugins/simple-math.plugin.cjs +0 -151
  31. package/dist/commonjs/presets/plugins/simple-math.plugin.cjs.map +0 -1
  32. package/dist/commonjs/presets/plugins/simple-mermaid.plugin.cjs +0 -21
  33. package/dist/commonjs/presets/plugins/simple-mermaid.plugin.cjs.map +0 -1
  34. package/dist/commonjs/presets/plugins/toc/index.cjs +0 -187
  35. package/dist/commonjs/presets/plugins/toc/index.cjs.map +0 -1
  36. package/dist/commonjs/presets/plugins/toc/slugify.cjs +0 -8
  37. package/dist/commonjs/presets/plugins/toc/slugify.cjs.map +0 -1
  38. package/dist/commonjs/presets/plugins/toc/toc-item.cjs +0 -3
  39. package/dist/commonjs/presets/plugins/toc/toc-item.cjs.map +0 -1
  40. package/dist/commonjs/presets/plugins/toc/toc-option.cjs +0 -18
  41. package/dist/commonjs/presets/plugins/toc/toc-option.cjs.map +0 -1
  42. package/dist/commonjs/presets/plugins/unique-custom-id.cjs +0 -30
  43. package/dist/commonjs/presets/plugins/unique-custom-id.cjs.map +0 -1
  44. package/dist/es2015/index.mjs.map +0 -1
  45. package/dist/es2015/math/factory.mjs +0 -13
  46. package/dist/es2015/math/factory.mjs.map +0 -1
  47. package/dist/es2015/math/impl.mjs +0 -161
  48. package/dist/es2015/math/impl.mjs.map +0 -1
  49. package/dist/es2015/math/index.mjs.map +0 -1
  50. package/dist/es2015/math/model.mjs +0 -20
  51. package/dist/es2015/math/model.mjs.map +0 -1
  52. package/dist/es2015/presets/index.mjs.map +0 -1
  53. package/dist/es2015/presets/option.mjs +0 -27
  54. package/dist/es2015/presets/option.mjs.map +0 -1
  55. package/dist/es2015/presets/plugins/highlight-code-lines.plugin.mjs +0 -49
  56. package/dist/es2015/presets/plugins/highlight-code-lines.plugin.mjs.map +0 -1
  57. package/dist/es2015/presets/plugins/html-filter.plugin.mjs +0 -43
  58. package/dist/es2015/presets/plugins/html-filter.plugin.mjs.map +0 -1
  59. package/dist/es2015/presets/plugins/meta.mjs +0 -36
  60. package/dist/es2015/presets/plugins/meta.mjs.map +0 -1
  61. package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.mjs +0 -11
  62. package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.plugin.mjs.map +0 -1
  63. package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.rule.mjs +0 -40
  64. package/dist/es2015/presets/plugins/multiline-blockquote/multiline-blockquote.rule.mjs.map +0 -1
  65. package/dist/es2015/presets/plugins/simple-math.plugin.mjs +0 -147
  66. package/dist/es2015/presets/plugins/simple-math.plugin.mjs.map +0 -1
  67. package/dist/es2015/presets/plugins/simple-mermaid.plugin.mjs +0 -17
  68. package/dist/es2015/presets/plugins/simple-mermaid.plugin.mjs.map +0 -1
  69. package/dist/es2015/presets/plugins/toc/index.mjs +0 -184
  70. package/dist/es2015/presets/plugins/toc/index.mjs.map +0 -1
  71. package/dist/es2015/presets/plugins/toc/slugify.mjs +0 -5
  72. package/dist/es2015/presets/plugins/toc/slugify.mjs.map +0 -1
  73. package/dist/es2015/presets/plugins/toc/toc-item.mjs +0 -2
  74. package/dist/es2015/presets/plugins/toc/toc-item.mjs.map +0 -1
  75. package/dist/es2015/presets/plugins/toc/toc-option.mjs +0 -15
  76. package/dist/es2015/presets/plugins/toc/toc-option.mjs.map +0 -1
  77. package/dist/es2015/presets/plugins/unique-custom-id.mjs +0 -27
  78. package/dist/es2015/presets/plugins/unique-custom-id.mjs.map +0 -1
@@ -1,8 +1,234 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MathEngine = exports.createMathJaxRenderer = void 0;
4
- var factory_1 = require("./factory");
5
- Object.defineProperty(exports, "createMathJaxRenderer", { enumerable: true, get: function () { return factory_1.createMathJaxRenderer; } });
6
- var model_1 = require("./model");
7
- Object.defineProperty(exports, "MathEngine", { enumerable: true, get: function () { return model_1.MathEngine; } });
8
- //# sourceMappingURL=index.js.map
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
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
+ };
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, { get: all[name], enumerable: true });
22
+ };
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") {
25
+ for (let key of __getOwnPropNames(from))
26
+ if (!__hasOwnProp.call(to, key) && key !== except)
27
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28
+ }
29
+ return to;
30
+ };
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // src/math/index.ts
34
+ var math_exports = {};
35
+ __export(math_exports, {
36
+ MathEngine: () => MathEngine,
37
+ createMathJaxRenderer: () => createMathJaxRenderer
38
+ });
39
+ module.exports = __toCommonJS(math_exports);
40
+
41
+ // src/math/model.ts
42
+ var MathEngine = /* @__PURE__ */ ((MathEngine2) => {
43
+ MathEngine2[MathEngine2["MathJax2"] = 0] = "MathJax2";
44
+ MathEngine2[MathEngine2["MathJax3"] = 1] = "MathJax3";
45
+ return MathEngine2;
46
+ })(MathEngine || {});
47
+ var defaultConfig = {
48
+ [0 /* MathJax2 */]: {
49
+ entryScript: "https://mathjax.cnblogs.com/2_7_5/MathJax.js?config=TeX-AMS-MML_HTMLorMML&delayStartupUntil=configured&v=20200504",
50
+ document: window.document,
51
+ engine: 0 /* MathJax2 */,
52
+ isEnabled: true
53
+ },
54
+ [1 /* MathJax3 */]: {
55
+ entryScript: "https://mathjax.cnblogs.com/3_2_1/es5/tex-mml-chtml.js",
56
+ document: window.document,
57
+ engine: 1 /* MathJax3 */,
58
+ isEnabled: true
59
+ }
60
+ };
61
+
62
+ // src/math/impl.ts
63
+ var import_load_script_css = require("@cnblogs/load-script-css");
64
+ var Mathjax2Renderer = class {
65
+ constructor() {
66
+ this._defaultConfig = defaultConfig[0 /* MathJax2 */];
67
+ this._defaultMathJaxConfig = {
68
+ tex2jax: {
69
+ inlineMath: [
70
+ ["$", "$"],
71
+ ["\\(", "\\)"]
72
+ ],
73
+ processClass: "math",
74
+ processEscapes: true
75
+ },
76
+ TeX: {
77
+ equationNumbers: {
78
+ autoNumber: "AMS",
79
+ useLabelIds: true
80
+ },
81
+ extensions: ["extpfeil.js", "mediawiki-texvc.js"],
82
+ Macros: { bm: "\\boldsymbol" }
83
+ },
84
+ "HTML-CSS": { linebreaks: { automatic: true } },
85
+ SVG: { linebreaks: { automatic: true } },
86
+ skipStartupTypeset: true
87
+ };
88
+ this._config = this._defaultConfig;
89
+ }
90
+ get _global() {
91
+ var _a;
92
+ return (_a = this._config.document.defaultView) != null ? _a : window;
93
+ }
94
+ render(container, callback) {
95
+ if (!this._config.isEnabled)
96
+ return Promise.resolve();
97
+ return this.init().then((mathjax) => {
98
+ if (!mathjax)
99
+ return;
100
+ const { onRendered } = this._config;
101
+ mathjax.Hub.Queue(["Typeset", mathjax.Hub, container]);
102
+ if (onRendered != null) {
103
+ mathjax.Hub.Queue(() => onRendered(mathjax));
104
+ }
105
+ if (callback) {
106
+ mathjax.Hub.Queue(callback);
107
+ }
108
+ }).catch(console.warn);
109
+ }
110
+ config(value) {
111
+ this._config = Object.assign({}, this._defaultConfig, value);
112
+ return this;
113
+ }
114
+ init() {
115
+ if (this._initTask)
116
+ return this._initTask;
117
+ const { entryScript, tapMathJaxConfig, document } = this._config;
118
+ return this._initTask = (0, import_load_script_css.loadScript)({
119
+ src: entryScript,
120
+ id: "mathjax",
121
+ timeoutSeconds: 10,
122
+ appendTo: document.head
123
+ }).then(() => {
124
+ var _a;
125
+ const { MathJax } = this._global;
126
+ if (MathJax) {
127
+ MathJax.Hub.Config(
128
+ (_a = tapMathJaxConfig == null ? void 0 : tapMathJaxConfig.call(
129
+ void 0,
130
+ Object.assign({}, this._defaultMathJaxConfig)
131
+ )) != null ? _a : __spreadValues({}, this._defaultMathJaxConfig)
132
+ );
133
+ MathJax.Hub.Configured();
134
+ return MathJax;
135
+ }
136
+ }).catch(() => this._initTask = void 0);
137
+ }
138
+ };
139
+ var MathJax3Renderer = class {
140
+ constructor() {
141
+ this._defaultConfig = defaultConfig[1 /* MathJax3 */];
142
+ this._defaultMathJaxConfig = {
143
+ tex: {
144
+ inlineMath: [
145
+ ["$", "$"],
146
+ ["\\(", "\\)"]
147
+ ],
148
+ processEscapes: true,
149
+ tags: "ams",
150
+ useLabelIds: true,
151
+ macros: {
152
+ bm: "\\boldsymbol"
153
+ },
154
+ packages: { "[+]": ["noerrors", "extpfeil"] }
155
+ },
156
+ options: {
157
+ processHtmlClass: "math",
158
+ ignoreHtmlClass: "tex2jax_ignore"
159
+ },
160
+ loader: {
161
+ load: ["[tex]/noerrors", "[tex]/extpfeil"]
162
+ },
163
+ startup: {
164
+ typeset: false
165
+ }
166
+ };
167
+ this._config = this._defaultConfig;
168
+ }
169
+ config(value) {
170
+ this._config = Object.assign({}, this._defaultConfig, value);
171
+ return this;
172
+ }
173
+ render(container, callback) {
174
+ if (!this._config.isEnabled)
175
+ return Promise.resolve();
176
+ return this.init().then((mathjax) => {
177
+ mathjax ? mathjax.startup.promise = mathjax.startup.promise.then(
178
+ () => mathjax.typesetPromise([container]).then(() => {
179
+ var _a;
180
+ try {
181
+ (_a = this._config.onRendered) == null ? void 0 : _a.call(void 0, mathjax);
182
+ } catch (e) {
183
+ console.error(e);
184
+ }
185
+ try {
186
+ callback == null ? void 0 : callback.call(void 0);
187
+ } catch (e) {
188
+ console.error(e);
189
+ }
190
+ })
191
+ ) : void 0;
192
+ }).catch(console.warn);
193
+ }
194
+ init() {
195
+ var _a;
196
+ return ((_a = this._initTask) != null ? _a : this._initTask = new Promise((resolve, reject) => {
197
+ var _a2, _b;
198
+ const { entryScript, tapMathJaxConfig, document: _document } = this._config;
199
+ const _window = (_a2 = _document.defaultView) != null ? _a2 : window;
200
+ _window.MathJax = (_b = tapMathJaxConfig == null ? void 0 : tapMathJaxConfig.call(void 0, __spreadValues({}, this._defaultMathJaxConfig))) != null ? _b : __spreadValues({}, this._defaultMathJaxConfig);
201
+ if (!_window.MathJax.startup) {
202
+ _window.MathJax.startup = {};
203
+ }
204
+ _window.MathJax.startup.ready = () => {
205
+ var _a3, _b2;
206
+ (_b2 = (_a3 = _window.MathJax) == null ? void 0 : _a3.startup) == null ? void 0 : _b2.defaultReady();
207
+ resolve(_window.MathJax);
208
+ };
209
+ (0, import_load_script_css.loadScript)({
210
+ src: entryScript,
211
+ id: "mathjax",
212
+ executionStrategy: "defer",
213
+ appendTo: _window.document.head
214
+ }).catch(reject);
215
+ })).catch(() => this._initTask = void 0);
216
+ }
217
+ };
218
+
219
+ // src/math/factory.ts
220
+ var createMathJaxRenderer = (rendererConfig) => {
221
+ switch (rendererConfig.engine) {
222
+ case 0 /* MathJax2 */:
223
+ return new Mathjax2Renderer().config(rendererConfig);
224
+ case 1 /* MathJax3 */:
225
+ return new MathJax3Renderer().config(rendererConfig);
226
+ default:
227
+ throw Error("Renderer unavailable");
228
+ }
229
+ };
230
+ // Annotate the CommonJS export names for ESM import in node:
231
+ 0 && (module.exports = {
232
+ MathEngine,
233
+ createMathJaxRenderer
234
+ });