@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,3 +1,210 @@
1
- export { createMathJaxRenderer } from './factory';
2
- export { MathEngine } from './model';
3
- //# sourceMappingURL=index.js.map
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+
18
+ // src/math/model.ts
19
+ var MathEngine = /* @__PURE__ */ ((MathEngine2) => {
20
+ MathEngine2[MathEngine2["MathJax2"] = 0] = "MathJax2";
21
+ MathEngine2[MathEngine2["MathJax3"] = 1] = "MathJax3";
22
+ return MathEngine2;
23
+ })(MathEngine || {});
24
+ var defaultConfig = {
25
+ [0 /* MathJax2 */]: {
26
+ entryScript: "https://mathjax.cnblogs.com/2_7_5/MathJax.js?config=TeX-AMS-MML_HTMLorMML&delayStartupUntil=configured&v=20200504",
27
+ document: window.document,
28
+ engine: 0 /* MathJax2 */,
29
+ isEnabled: true
30
+ },
31
+ [1 /* MathJax3 */]: {
32
+ entryScript: "https://mathjax.cnblogs.com/3_2_1/es5/tex-mml-chtml.js",
33
+ document: window.document,
34
+ engine: 1 /* MathJax3 */,
35
+ isEnabled: true
36
+ }
37
+ };
38
+
39
+ // src/math/impl.ts
40
+ import { loadScript } from "@cnblogs/load-script-css";
41
+ var Mathjax2Renderer = class {
42
+ constructor() {
43
+ this._defaultConfig = defaultConfig[0 /* MathJax2 */];
44
+ this._defaultMathJaxConfig = {
45
+ tex2jax: {
46
+ inlineMath: [
47
+ ["$", "$"],
48
+ ["\\(", "\\)"]
49
+ ],
50
+ processClass: "math",
51
+ processEscapes: true
52
+ },
53
+ TeX: {
54
+ equationNumbers: {
55
+ autoNumber: "AMS",
56
+ useLabelIds: true
57
+ },
58
+ extensions: ["extpfeil.js", "mediawiki-texvc.js"],
59
+ Macros: { bm: "\\boldsymbol" }
60
+ },
61
+ "HTML-CSS": { linebreaks: { automatic: true } },
62
+ SVG: { linebreaks: { automatic: true } },
63
+ skipStartupTypeset: true
64
+ };
65
+ this._config = this._defaultConfig;
66
+ }
67
+ get _global() {
68
+ var _a;
69
+ return (_a = this._config.document.defaultView) != null ? _a : window;
70
+ }
71
+ render(container, callback) {
72
+ if (!this._config.isEnabled)
73
+ return Promise.resolve();
74
+ return this.init().then((mathjax) => {
75
+ if (!mathjax)
76
+ return;
77
+ const { onRendered } = this._config;
78
+ mathjax.Hub.Queue(["Typeset", mathjax.Hub, container]);
79
+ if (onRendered != null) {
80
+ mathjax.Hub.Queue(() => onRendered(mathjax));
81
+ }
82
+ if (callback) {
83
+ mathjax.Hub.Queue(callback);
84
+ }
85
+ }).catch(console.warn);
86
+ }
87
+ config(value) {
88
+ this._config = Object.assign({}, this._defaultConfig, value);
89
+ return this;
90
+ }
91
+ init() {
92
+ if (this._initTask)
93
+ return this._initTask;
94
+ const { entryScript, tapMathJaxConfig, document } = this._config;
95
+ return this._initTask = loadScript({
96
+ src: entryScript,
97
+ id: "mathjax",
98
+ timeoutSeconds: 10,
99
+ appendTo: document.head
100
+ }).then(() => {
101
+ var _a;
102
+ const { MathJax } = this._global;
103
+ if (MathJax) {
104
+ MathJax.Hub.Config(
105
+ (_a = tapMathJaxConfig == null ? void 0 : tapMathJaxConfig.call(
106
+ void 0,
107
+ Object.assign({}, this._defaultMathJaxConfig)
108
+ )) != null ? _a : __spreadValues({}, this._defaultMathJaxConfig)
109
+ );
110
+ MathJax.Hub.Configured();
111
+ return MathJax;
112
+ }
113
+ }).catch(() => this._initTask = void 0);
114
+ }
115
+ };
116
+ var MathJax3Renderer = class {
117
+ constructor() {
118
+ this._defaultConfig = defaultConfig[1 /* MathJax3 */];
119
+ this._defaultMathJaxConfig = {
120
+ tex: {
121
+ inlineMath: [
122
+ ["$", "$"],
123
+ ["\\(", "\\)"]
124
+ ],
125
+ processEscapes: true,
126
+ tags: "ams",
127
+ useLabelIds: true,
128
+ macros: {
129
+ bm: "\\boldsymbol"
130
+ },
131
+ packages: { "[+]": ["noerrors", "extpfeil"] }
132
+ },
133
+ options: {
134
+ processHtmlClass: "math",
135
+ ignoreHtmlClass: "tex2jax_ignore"
136
+ },
137
+ loader: {
138
+ load: ["[tex]/noerrors", "[tex]/extpfeil"]
139
+ },
140
+ startup: {
141
+ typeset: false
142
+ }
143
+ };
144
+ this._config = this._defaultConfig;
145
+ }
146
+ config(value) {
147
+ this._config = Object.assign({}, this._defaultConfig, value);
148
+ return this;
149
+ }
150
+ render(container, callback) {
151
+ if (!this._config.isEnabled)
152
+ return Promise.resolve();
153
+ return this.init().then((mathjax) => {
154
+ mathjax ? mathjax.startup.promise = mathjax.startup.promise.then(
155
+ () => mathjax.typesetPromise([container]).then(() => {
156
+ var _a;
157
+ try {
158
+ (_a = this._config.onRendered) == null ? void 0 : _a.call(void 0, mathjax);
159
+ } catch (e) {
160
+ console.error(e);
161
+ }
162
+ try {
163
+ callback == null ? void 0 : callback.call(void 0);
164
+ } catch (e) {
165
+ console.error(e);
166
+ }
167
+ })
168
+ ) : void 0;
169
+ }).catch(console.warn);
170
+ }
171
+ init() {
172
+ var _a;
173
+ return ((_a = this._initTask) != null ? _a : this._initTask = new Promise((resolve, reject) => {
174
+ var _a2, _b;
175
+ const { entryScript, tapMathJaxConfig, document: _document } = this._config;
176
+ const _window = (_a2 = _document.defaultView) != null ? _a2 : window;
177
+ _window.MathJax = (_b = tapMathJaxConfig == null ? void 0 : tapMathJaxConfig.call(void 0, __spreadValues({}, this._defaultMathJaxConfig))) != null ? _b : __spreadValues({}, this._defaultMathJaxConfig);
178
+ if (!_window.MathJax.startup) {
179
+ _window.MathJax.startup = {};
180
+ }
181
+ _window.MathJax.startup.ready = () => {
182
+ var _a3, _b2;
183
+ (_b2 = (_a3 = _window.MathJax) == null ? void 0 : _a3.startup) == null ? void 0 : _b2.defaultReady();
184
+ resolve(_window.MathJax);
185
+ };
186
+ loadScript({
187
+ src: entryScript,
188
+ id: "mathjax",
189
+ executionStrategy: "defer",
190
+ appendTo: _window.document.head
191
+ }).catch(reject);
192
+ })).catch(() => this._initTask = void 0);
193
+ }
194
+ };
195
+
196
+ // src/math/factory.ts
197
+ var createMathJaxRenderer = (rendererConfig) => {
198
+ switch (rendererConfig.engine) {
199
+ case 0 /* MathJax2 */:
200
+ return new Mathjax2Renderer().config(rendererConfig);
201
+ case 1 /* MathJax3 */:
202
+ return new MathJax3Renderer().config(rendererConfig);
203
+ default:
204
+ throw Error("Renderer unavailable");
205
+ }
206
+ };
207
+ export {
208
+ MathEngine,
209
+ createMathJaxRenderer
210
+ };