@cnblogs/markdown-it-presets 1.9.3 → 1.9.5

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