res-oqc 1.0.2 → 1.0.3

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 (82) hide show
  1. package/assets/katex/README.md +92 -0
  2. package/assets/katex/contrib/auto-render.js +327 -0
  3. package/assets/katex/contrib/auto-render.min.js +1 -0
  4. package/assets/katex/contrib/auto-render.mjs +222 -0
  5. package/assets/katex/contrib/copy-tex.css +14 -0
  6. package/assets/katex/contrib/copy-tex.js +116 -0
  7. package/assets/katex/contrib/copy-tex.min.css +1 -0
  8. package/assets/katex/contrib/copy-tex.min.js +1 -0
  9. package/assets/katex/contrib/copy-tex.mjs +86 -0
  10. package/assets/katex/contrib/mathtex-script-type.js +112 -0
  11. package/assets/katex/contrib/mathtex-script-type.min.js +1 -0
  12. package/assets/katex/contrib/mathtex-script-type.mjs +24 -0
  13. package/assets/katex/contrib/mhchem.min.js +1 -0
  14. package/assets/katex/contrib/mhchem.mjs +3109 -0
  15. package/assets/katex/contrib/render-a11y-string.js +875 -0
  16. package/assets/katex/contrib/render-a11y-string.min.js +1 -0
  17. package/assets/katex/contrib/render-a11y-string.mjs +794 -0
  18. package/assets/katex/fonts/KaTeX_AMS-Regular.ttf +0 -0
  19. package/assets/katex/fonts/KaTeX_AMS-Regular.woff +0 -0
  20. package/assets/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  21. package/assets/katex/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  22. package/assets/katex/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  23. package/assets/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  24. package/assets/katex/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  25. package/assets/katex/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  26. package/assets/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  27. package/assets/katex/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  28. package/assets/katex/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  29. package/assets/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  30. package/assets/katex/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  31. package/assets/katex/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  32. package/assets/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  33. package/assets/katex/fonts/KaTeX_Main-Bold.ttf +0 -0
  34. package/assets/katex/fonts/KaTeX_Main-Bold.woff +0 -0
  35. package/assets/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
  36. package/assets/katex/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  37. package/assets/katex/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  38. package/assets/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  39. package/assets/katex/fonts/KaTeX_Main-Italic.ttf +0 -0
  40. package/assets/katex/fonts/KaTeX_Main-Italic.woff +0 -0
  41. package/assets/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
  42. package/assets/katex/fonts/KaTeX_Main-Regular.ttf +0 -0
  43. package/assets/katex/fonts/KaTeX_Main-Regular.woff +0 -0
  44. package/assets/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
  45. package/assets/katex/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  46. package/assets/katex/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  47. package/assets/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  48. package/assets/katex/fonts/KaTeX_Math-Italic.ttf +0 -0
  49. package/assets/katex/fonts/KaTeX_Math-Italic.woff +0 -0
  50. package/assets/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
  51. package/assets/katex/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  52. package/assets/katex/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  53. package/assets/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  54. package/assets/katex/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  55. package/assets/katex/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  56. package/assets/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  57. package/assets/katex/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  58. package/assets/katex/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  59. package/assets/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  60. package/assets/katex/fonts/KaTeX_Script-Regular.ttf +0 -0
  61. package/assets/katex/fonts/KaTeX_Script-Regular.woff +0 -0
  62. package/assets/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
  63. package/assets/katex/fonts/KaTeX_Size1-Regular.ttf +0 -0
  64. package/assets/katex/fonts/KaTeX_Size1-Regular.woff +0 -0
  65. package/assets/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  66. package/assets/katex/fonts/KaTeX_Size2-Regular.ttf +0 -0
  67. package/assets/katex/fonts/KaTeX_Size2-Regular.woff +0 -0
  68. package/assets/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  69. package/assets/katex/fonts/KaTeX_Size3-Regular.ttf +0 -0
  70. package/assets/katex/fonts/KaTeX_Size3-Regular.woff +0 -0
  71. package/assets/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  72. package/assets/katex/fonts/KaTeX_Size4-Regular.ttf +0 -0
  73. package/assets/katex/fonts/KaTeX_Size4-Regular.woff +0 -0
  74. package/assets/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  75. package/assets/katex/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  76. package/assets/katex/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  77. package/assets/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  78. package/assets/katex/katex.css +1091 -0
  79. package/assets/katex/katex.min.css +13 -0
  80. package/assets/katex/katex.min.js +1 -0
  81. package/assets/katex/katex.mjs +17731 -0
  82. package/package.json +1 -1
@@ -0,0 +1,92 @@
1
+ # [<img src="https://katex.org/img/katex-logo-black.svg" width="130" alt="KaTeX">](https://katex.org/)
2
+ [![npm](https://img.shields.io/npm/v/katex.svg)](https://www.npmjs.com/package/katex)
3
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
4
+ [![CI](https://github.com/KaTeX/KaTeX/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/KaTeX/KaTeX/actions?query=workflow%3ACI)
5
+ [![codecov](https://codecov.io/gh/KaTeX/KaTeX/branch/master/graph/badge.svg)](https://codecov.io/gh/KaTeX/KaTeX)
6
+ [![Discussions](https://img.shields.io/badge/Discussions-join-brightgreen)](https://github.com/KaTeX/KaTeX/discussions)
7
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/katex/badge?style=rounded)](https://www.jsdelivr.com/package/npm/katex)
8
+ ![katex.min.js size](https://img.badgesize.io/https://unpkg.com/katex/dist/katex.min.js?compression=gzip)
9
+ [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/KaTeX/KaTeX)
10
+
11
+ KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web.
12
+
13
+ * **Fast:** KaTeX renders its math synchronously and doesn't need to reflow the page. See how it compares to a competitor in [this speed test](http://www.intmath.com/cg5/katex-mathjax-comparison.php).
14
+ * **Print quality:** KaTeX's layout is based on Donald Knuth's TeX, the gold standard for math typesetting.
15
+ * **Self contained:** KaTeX has no dependencies and can easily be bundled with your website resources.
16
+ * **Server side rendering:** KaTeX produces the same output regardless of browser or environment, so you can pre-render expressions using Node.js and send them as plain HTML.
17
+
18
+ KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 11.
19
+
20
+ KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the [list of supported functions](https://katex.org/docs/supported.html).
21
+
22
+ Try out KaTeX [on the demo page](https://katex.org/#demo)!
23
+
24
+ ## Getting started
25
+
26
+ ### Starter template
27
+
28
+ ```html
29
+ <!DOCTYPE html>
30
+ <!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
31
+ <html>
32
+ <head>
33
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css" integrity="sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc" crossorigin="anonymous">
34
+
35
+ <!-- The loading of KaTeX is deferred to speed up page rendering -->
36
+ <script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.js" integrity="sha384-YNHdsYkH6gMx9y3mRkmcJ2mFUjTd0qNQQvY9VYZgQd7DcN7env35GzlmFaZ23JGp" crossorigin="anonymous"></script>
37
+
38
+ <!-- To automatically render math in text elements, include the auto-render extension: -->
39
+ <script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/contrib/auto-render.min.js" integrity="sha384-vZTG03m+2yp6N6BNi5iM4rW4oIwk5DfcNdFfxkk9ZWpDriOkXX8voJBFrAO7MpVl" crossorigin="anonymous"
40
+ onload="renderMathInElement(document.body);"></script>
41
+ </head>
42
+ ...
43
+ </html>
44
+ ```
45
+
46
+ You can also [download KaTeX](https://github.com/KaTeX/KaTeX/releases) and host it yourself.
47
+
48
+ For details on how to configure auto-render extension, refer to [the documentation](https://katex.org/docs/autorender.html).
49
+
50
+ ### API
51
+
52
+ Call `katex.render` to render a TeX expression directly into a DOM element.
53
+ For example:
54
+
55
+ ```js
56
+ katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, {
57
+ throwOnError: false
58
+ });
59
+ ```
60
+
61
+ Call `katex.renderToString` to generate an HTML string of the rendered math,
62
+ e.g., for server-side rendering. For example:
63
+
64
+ ```js
65
+ var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
66
+ throwOnError: false
67
+ });
68
+ // '<span class="katex">...</span>'
69
+ ```
70
+
71
+ Make sure to include the CSS and font files in both cases.
72
+ If you are doing all rendering on the server, there is no need to include the
73
+ JavaScript on the client.
74
+
75
+ The examples above use the `throwOnError: false` option, which renders invalid
76
+ inputs as the TeX source code in red (by default), with the error message as
77
+ hover text. For other available options, see the
78
+ [API documentation](https://katex.org/docs/api.html),
79
+ [options documentation](https://katex.org/docs/options.html), and
80
+ [handling errors documentation](https://katex.org/docs/error.html).
81
+
82
+ ## Demo and Documentation
83
+
84
+ Learn more about using KaTeX [on the website](https://katex.org)!
85
+
86
+ ## Contributing
87
+
88
+ See [CONTRIBUTING.md](CONTRIBUTING.md)
89
+
90
+ ## License
91
+
92
+ KaTeX is licensed under the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,327 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ {module.exports = factory(require('katex'));}
4
+ else if(typeof define === 'function' && define.amd)
5
+ {define(['katex'], factory);}
6
+ else if(typeof exports === 'object')
7
+ {exports['renderMathInElement'] = factory(require('katex'));}
8
+ else
9
+ {root['renderMathInElement'] = factory(root['katex']);}
10
+ })((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__974__) {
11
+ return /******/ (function() { // webpackBootstrap
12
+ /******/
13
+ /******/ const __webpack_modules__ = ({
14
+
15
+ /***/ 974:
16
+ /***/ function(module) {
17
+
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE__974__;
19
+
20
+ /***/ }
21
+
22
+ /******/ });
23
+ /************************************************************************/
24
+ /******/ // The module cache
25
+ /******/ const __webpack_module_cache__ = {};
26
+ /******/
27
+ /******/ // The require function
28
+ /******/ function __webpack_require__(moduleId) {
29
+ /******/ // Check if module is in cache
30
+ /******/ const cachedModule = __webpack_module_cache__[moduleId];
31
+ /******/ if (cachedModule !== undefined) {
32
+ /******/ return cachedModule.exports;
33
+ /******/ }
34
+ /******/ // Create a new module (and put it into the cache)
35
+ /******/ const module = __webpack_module_cache__[moduleId] = {
36
+ /******/ // no module.id needed
37
+ /******/ // no module.loaded needed
38
+ /******/ exports: {}
39
+ /******/ };
40
+ /******/
41
+ /******/ // Execute the module function
42
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
43
+ /******/
44
+ /******/ // Return the exports of the module
45
+ /******/ return module.exports;
46
+ /******/ }
47
+ /******/
48
+ /************************************************************************/
49
+ /******/ /* webpack/runtime/compat get default export */
50
+ /******/ !function() {
51
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
52
+ /******/ __webpack_require__.n = function(module) {
53
+ /******/ const getter = module && module.__esModule ?
54
+ /******/ function() { return module['default']; } :
55
+ /******/ function() { return module; };
56
+ /******/ __webpack_require__.d(getter, { a: getter });
57
+ /******/ return getter;
58
+ /******/ };
59
+ /******/ }();
60
+ /******/
61
+ /******/ /* webpack/runtime/define property getters */
62
+ /******/ !function() {
63
+ /******/ // define getter functions for harmony exports
64
+ /******/ __webpack_require__.d = function(exports, definition) {
65
+ /******/ for(const key in definition) {
66
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
67
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
68
+ /******/ }
69
+ /******/ }
70
+ /******/ };
71
+ /******/ }();
72
+ /******/
73
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
74
+ /******/ !function() {
75
+ /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); };
76
+ /******/ }();
77
+ /******/
78
+ /************************************************************************/
79
+ let __webpack_exports__ = {};
80
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
81
+ !function() {
82
+
83
+ // EXPORTS
84
+ __webpack_require__.d(__webpack_exports__, {
85
+ 'default': function() { return /* binding */ auto_render; }
86
+ });
87
+
88
+ // EXTERNAL MODULE: external "katex"
89
+ const external_katex_ = __webpack_require__(974);
90
+ const external_katex_default = /*#__PURE__*/__webpack_require__.n(external_katex_);
91
+ ;// CONCATENATED MODULE: ./contrib/auto-render/splitAtDelimiters.js
92
+ /* eslint no-constant-condition:0 */
93
+ const findEndOfMath = function findEndOfMath(delimiter, text, startIndex) {
94
+ // Adapted from
95
+ // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx
96
+ let index = startIndex;
97
+ let braceLevel = 0;
98
+ const delimLength = delimiter.length;
99
+
100
+ while (index < text.length) {
101
+ const character = text[index];
102
+
103
+ if (braceLevel <= 0 && text.slice(index, index + delimLength) === delimiter) {
104
+ return index;
105
+ } else if (character === '\\') {
106
+ index++;
107
+ } else if (character === '{') {
108
+ braceLevel++;
109
+ } else if (character === '}') {
110
+ braceLevel--;
111
+ }
112
+
113
+ index++;
114
+ }
115
+
116
+ return -1;
117
+ };
118
+
119
+ const escapeRegex = function escapeRegex(string) {
120
+ return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
121
+ };
122
+
123
+ const amsRegex = /^\\begin{/;
124
+
125
+ const splitAtDelimiters = function splitAtDelimiters(text, delimiters) {
126
+ let index;
127
+ const data = [];
128
+ const regexLeft = new RegExp('(' + delimiters.map(function (x) {
129
+ return escapeRegex(x.left);
130
+ }).join('|') + ')');
131
+
132
+ while (true) {
133
+ index = text.search(regexLeft);
134
+
135
+ if (index === -1) {
136
+ break;
137
+ }
138
+
139
+ if (index > 0) {
140
+ data.push({
141
+ type: 'text',
142
+ data: text.slice(0, index)
143
+ });
144
+ text = text.slice(index); // now text starts with delimiter
145
+ } // ... so this always succeeds:
146
+
147
+
148
+ const i = delimiters.findIndex(function (delim) {
149
+ return text.startsWith(delim.left);
150
+ });
151
+ index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length);
152
+
153
+ if (index === -1) {
154
+ break;
155
+ }
156
+
157
+ const rawData = text.slice(0, index + delimiters[i].right.length);
158
+ const math = amsRegex.test(rawData) ? rawData : text.slice(delimiters[i].left.length, index);
159
+ data.push({
160
+ type: 'math',
161
+ data: math,
162
+ rawData: rawData,
163
+ display: delimiters[i].display
164
+ });
165
+ text = text.slice(index + delimiters[i].right.length);
166
+ }
167
+
168
+ if (text !== '') {
169
+ data.push({
170
+ type: 'text',
171
+ data: text
172
+ });
173
+ }
174
+
175
+ return data;
176
+ };
177
+
178
+ /* harmony default export */ const auto_render_splitAtDelimiters = (splitAtDelimiters);
179
+ ;// CONCATENATED MODULE: ./contrib/auto-render/auto-render.js
180
+ /* eslint no-console:0 */
181
+
182
+
183
+ /* Note: optionsCopy is mutated by this method. If it is ever exposed in the
184
+ * API, we should copy it before mutating.
185
+ */
186
+
187
+ const renderMathInText = function renderMathInText(text, optionsCopy) {
188
+ const data = auto_render_splitAtDelimiters(text, optionsCopy.delimiters);
189
+
190
+ if (data.length === 1 && data[0].type === 'text') {
191
+ // There is no formula in the text.
192
+ // Let's return null which means there is no need to replace
193
+ // the current text node with a new one.
194
+ return null;
195
+ }
196
+
197
+ const fragment = document.createDocumentFragment();
198
+
199
+ for (let i = 0; i < data.length; i++) {
200
+ if (data[i].type === 'text') {
201
+ fragment.appendChild(document.createTextNode(data[i].data));
202
+ } else {
203
+ const span = document.createElement('span');
204
+ let math = data[i].data; // Override any display mode defined in the settings with that
205
+ // defined by the text itself
206
+
207
+ optionsCopy.displayMode = data[i].display;
208
+
209
+ try {
210
+ if (optionsCopy.preProcess) {
211
+ math = optionsCopy.preProcess(math);
212
+ }
213
+
214
+ external_katex_default().render(math, span, optionsCopy);
215
+ } catch (e) {
216
+ if (!(e instanceof (external_katex_default()).ParseError)) {
217
+ throw e;
218
+ }
219
+
220
+ optionsCopy.errorCallback('KaTeX auto-render: Failed to parse `' + data[i].data + '` with ', e);
221
+ fragment.appendChild(document.createTextNode(data[i].rawData));
222
+ continue;
223
+ }
224
+
225
+ fragment.appendChild(span);
226
+ }
227
+ }
228
+
229
+ return fragment;
230
+ };
231
+
232
+ const renderElem = function renderElem(elem, optionsCopy) {
233
+ for (let i = 0; i < elem.childNodes.length; i++) {
234
+ var childNode = elem.childNodes[i];
235
+
236
+ if (childNode.nodeType === 3) {
237
+ // Text node
238
+ const frag = renderMathInText(childNode.textContent, optionsCopy);
239
+
240
+ if (frag) {
241
+ i += frag.childNodes.length - 1;
242
+ elem.replaceChild(frag, childNode);
243
+ }
244
+ } else if (childNode.nodeType === 1) {
245
+ (function () {
246
+ // Element node
247
+ const className = ' ' + childNode.className + ' ';
248
+ const shouldRender = optionsCopy.ignoredTags.indexOf(childNode.nodeName.toLowerCase()) === -1 && optionsCopy.ignoredClasses.every(function (x) {
249
+ return className.indexOf(' ' + x + ' ') === -1;
250
+ });
251
+
252
+ if (shouldRender) {
253
+ renderElem(childNode, optionsCopy);
254
+ }
255
+ })();
256
+ } // Otherwise, it's something else, and ignore it.
257
+
258
+ }
259
+ };
260
+
261
+ const renderMathInElement = function renderMathInElement(elem, options) {
262
+ if (!elem) {
263
+ throw new Error('No element provided to render');
264
+ }
265
+
266
+ const optionsCopy = {}; // Object.assign(optionsCopy, option)
267
+
268
+ for (const option in options) {
269
+ if (options.hasOwnProperty(option)) {
270
+ optionsCopy[option] = options[option];
271
+ }
272
+ } // default options
273
+
274
+
275
+ optionsCopy.delimiters = optionsCopy.delimiters || [{
276
+ left: '$$',
277
+ right: '$$',
278
+ display: true
279
+ }, {
280
+ left: '\\(',
281
+ right: '\\)',
282
+ display: false
283
+ }, // LaTeX uses $…$, but it ruins the display of normal `$` in text:
284
+ // {left: "$", right: "$", display: false},
285
+ // $ must come after $$
286
+ // Render AMS environments even if outside $$…$$ delimiters.
287
+ {
288
+ left: '\\begin{equation}',
289
+ right: '\\end{equation}',
290
+ display: true
291
+ }, {
292
+ left: '\\begin{align}',
293
+ right: '\\end{align}',
294
+ display: true
295
+ }, {
296
+ left: '\\begin{alignat}',
297
+ right: '\\end{alignat}',
298
+ display: true
299
+ }, {
300
+ left: '\\begin{gather}',
301
+ right: '\\end{gather}',
302
+ display: true
303
+ }, {
304
+ left: '\\begin{CD}',
305
+ right: '\\end{CD}',
306
+ display: true
307
+ }, {
308
+ left: '\\[',
309
+ right: '\\]',
310
+ display: true
311
+ }];
312
+ optionsCopy.ignoredTags = optionsCopy.ignoredTags || ['script', 'noscript', 'style', 'textarea', 'pre', 'code', 'option'];
313
+ optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || [];
314
+ optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; // Enable sharing of global macros defined via `\gdef` between different
315
+ // math elements within a single call to `renderMathInElement`.
316
+
317
+ optionsCopy.macros = optionsCopy.macros || {};
318
+ renderElem(elem, optionsCopy);
319
+ };
320
+
321
+ /* harmony default export */ var auto_render = (renderMathInElement);
322
+ }();
323
+ __webpack_exports__ = __webpack_exports__.default;
324
+ /******/ return __webpack_exports__;
325
+ /******/ })()
326
+ ;
327
+ });
@@ -0,0 +1 @@
1
+ !function(e,t){'object'==typeof exports&&'object'==typeof module?module.exports=t(require('katex')):'function'==typeof define&&define.amd?define(['katex'],t):'object'==typeof exports?exports.renderMathInElement=t(require('katex')):e.renderMathInElement=t(e.katex);}('undefined'!=typeof self?self:this,function(e){return function(){const t={974:function(t){t.exports=e;}},r={};function n(e){const a=r[e];if(void 0!==a){return a.exports;}const i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports;}n.n=function(e){const t=e&&e.__esModule?function(){return e.default;}:function(){return e;};return n.d(t,{a:t}),t;},n.d=function(e,t){for(const r in t){n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]});}},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t);};let a={};return function(){n.d(a,{default:function(){return s;}});var e=n(974),t=n.n(e),r=function(e,t,r){for(let n=r,a=0,i=e.length;n<t.length;){const o=t[n];if(a<=0&&t.slice(n,n+i)===e){return n;}'\\'===o?n++:'{'===o?a++:'}'===o&&a--,n++;}return-1;},i=/^\\begin{/,o=function(e,t){for(var n,a=[],o=new RegExp('('+t.map(function(e){return e.left.replace(/[-/\\^$*+?.()|[\]{}]/g,'\\$&');}).join('|')+')');-1!==(n=e.search(o));){n>0&&(a.push({type:'text',data:e.slice(0,n)}),e=e.slice(n));const l=t.findIndex(function(t){return e.startsWith(t.left);});if(-1===(n=r(t[l].right,e,t[l].left.length))){break;}const d=e.slice(0,n+t[l].right.length),s=i.test(d)?d:e.slice(t[l].left.length,n);a.push({type:'math',data:s,rawData:d,display:t[l].display}),e=e.slice(n+t[l].right.length);}return''!==e&&a.push({type:'text',data:e}),a;},l=function(e,r){const n=o(e,r.delimiters);if(1===n.length&&'text'===n[0].type){return null;}for(var a=document.createDocumentFragment(),i=0;i<n.length;i++){if('text'===n[i].type){a.appendChild(document.createTextNode(n[i].data));}else{let l=document.createElement('span'),d=n[i].data;r.displayMode=n[i].display;try{r.preProcess&&(d=r.preProcess(d)),t().render(d,l,r);}catch(e){if(!(e instanceof t().ParseError)){throw e;}r.errorCallback('KaTeX auto-render: Failed to parse `'+n[i].data+'` with ',e),a.appendChild(document.createTextNode(n[i].rawData));continue;}a.appendChild(l);}}return a;},d=function e(t,r){for(let n=0;n<t.childNodes.length;n++){var a=t.childNodes[n];if(3===a.nodeType){const i=l(a.textContent,r);i&&(n+=i.childNodes.length-1,t.replaceChild(i,a));}else {1===a.nodeType&&function(){const t=' '+a.className+' ';-1===r.ignoredTags.indexOf(a.nodeName.toLowerCase())&&r.ignoredClasses.every(function(e){return-1===t.indexOf(' '+e+' ');})&&e(a,r);}();}}},s=function(e,t){if(!e){throw new Error('No element provided to render');}const r={};for(const n in t){t.hasOwnProperty(n)&&(r[n]=t[n]);}r.delimiters=r.delimiters||[{left:'$$',right:'$$',display:!0},{left:'\\(',right:'\\)',display:!1},{left:'\\begin{equation}',right:'\\end{equation}',display:!0},{left:'\\begin{align}',right:'\\end{align}',display:!0},{left:'\\begin{alignat}',right:'\\end{alignat}',display:!0},{left:'\\begin{gather}',right:'\\end{gather}',display:!0},{left:'\\begin{CD}',right:'\\end{CD}',display:!0},{left:'\\[',right:'\\]',display:!0}],r.ignoredTags=r.ignoredTags||['script','noscript','style','textarea','pre','code','option'],r.ignoredClasses=r.ignoredClasses||[],r.errorCallback=r.errorCallback||console.error,r.macros=r.macros||{},d(e,r);};}(),a=a.default;}();});
@@ -0,0 +1,222 @@
1
+ import katex from '../katex.mjs';
2
+
3
+ /* eslint no-constant-condition:0 */
4
+ var findEndOfMath = function findEndOfMath(delimiter, text, startIndex) {
5
+ // Adapted from
6
+ // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx
7
+ var index = startIndex;
8
+ var braceLevel = 0;
9
+ var delimLength = delimiter.length;
10
+
11
+ while (index < text.length) {
12
+ var character = text[index];
13
+
14
+ if (braceLevel <= 0 && text.slice(index, index + delimLength) === delimiter) {
15
+ return index;
16
+ } else if (character === "\\") {
17
+ index++;
18
+ } else if (character === "{") {
19
+ braceLevel++;
20
+ } else if (character === "}") {
21
+ braceLevel--;
22
+ }
23
+
24
+ index++;
25
+ }
26
+
27
+ return -1;
28
+ };
29
+
30
+ var escapeRegex = function escapeRegex(string) {
31
+ return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
32
+ };
33
+
34
+ var amsRegex = /^\\begin{/;
35
+
36
+ var splitAtDelimiters = function splitAtDelimiters(text, delimiters) {
37
+ var index;
38
+ var data = [];
39
+ var regexLeft = new RegExp("(" + delimiters.map(x => escapeRegex(x.left)).join("|") + ")");
40
+
41
+ while (true) {
42
+ index = text.search(regexLeft);
43
+
44
+ if (index === -1) {
45
+ break;
46
+ }
47
+
48
+ if (index > 0) {
49
+ data.push({
50
+ type: "text",
51
+ data: text.slice(0, index)
52
+ });
53
+ text = text.slice(index); // now text starts with delimiter
54
+ } // ... so this always succeeds:
55
+
56
+
57
+ var i = delimiters.findIndex(delim => text.startsWith(delim.left));
58
+ index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length);
59
+
60
+ if (index === -1) {
61
+ break;
62
+ }
63
+
64
+ var rawData = text.slice(0, index + delimiters[i].right.length);
65
+ var math = amsRegex.test(rawData) ? rawData : text.slice(delimiters[i].left.length, index);
66
+ data.push({
67
+ type: "math",
68
+ data: math,
69
+ rawData,
70
+ display: delimiters[i].display
71
+ });
72
+ text = text.slice(index + delimiters[i].right.length);
73
+ }
74
+
75
+ if (text !== "") {
76
+ data.push({
77
+ type: "text",
78
+ data: text
79
+ });
80
+ }
81
+
82
+ return data;
83
+ };
84
+
85
+ /* eslint no-console:0 */
86
+ /* Note: optionsCopy is mutated by this method. If it is ever exposed in the
87
+ * API, we should copy it before mutating.
88
+ */
89
+
90
+ var renderMathInText = function renderMathInText(text, optionsCopy) {
91
+ var data = splitAtDelimiters(text, optionsCopy.delimiters);
92
+
93
+ if (data.length === 1 && data[0].type === 'text') {
94
+ // There is no formula in the text.
95
+ // Let's return null which means there is no need to replace
96
+ // the current text node with a new one.
97
+ return null;
98
+ }
99
+
100
+ var fragment = document.createDocumentFragment();
101
+
102
+ for (var i = 0; i < data.length; i++) {
103
+ if (data[i].type === "text") {
104
+ fragment.appendChild(document.createTextNode(data[i].data));
105
+ } else {
106
+ var span = document.createElement("span");
107
+ var math = data[i].data; // Override any display mode defined in the settings with that
108
+ // defined by the text itself
109
+
110
+ optionsCopy.displayMode = data[i].display;
111
+
112
+ try {
113
+ if (optionsCopy.preProcess) {
114
+ math = optionsCopy.preProcess(math);
115
+ }
116
+
117
+ katex.render(math, span, optionsCopy);
118
+ } catch (e) {
119
+ if (!(e instanceof katex.ParseError)) {
120
+ throw e;
121
+ }
122
+
123
+ optionsCopy.errorCallback("KaTeX auto-render: Failed to parse `" + data[i].data + "` with ", e);
124
+ fragment.appendChild(document.createTextNode(data[i].rawData));
125
+ continue;
126
+ }
127
+
128
+ fragment.appendChild(span);
129
+ }
130
+ }
131
+
132
+ return fragment;
133
+ };
134
+
135
+ var renderElem = function renderElem(elem, optionsCopy) {
136
+ for (var i = 0; i < elem.childNodes.length; i++) {
137
+ var childNode = elem.childNodes[i];
138
+
139
+ if (childNode.nodeType === 3) {
140
+ // Text node
141
+ var frag = renderMathInText(childNode.textContent, optionsCopy);
142
+
143
+ if (frag) {
144
+ i += frag.childNodes.length - 1;
145
+ elem.replaceChild(frag, childNode);
146
+ }
147
+ } else if (childNode.nodeType === 1) {
148
+ (function () {
149
+ // Element node
150
+ var className = ' ' + childNode.className + ' ';
151
+ var shouldRender = optionsCopy.ignoredTags.indexOf(childNode.nodeName.toLowerCase()) === -1 && optionsCopy.ignoredClasses.every(x => className.indexOf(' ' + x + ' ') === -1);
152
+
153
+ if (shouldRender) {
154
+ renderElem(childNode, optionsCopy);
155
+ }
156
+ })();
157
+ } // Otherwise, it's something else, and ignore it.
158
+
159
+ }
160
+ };
161
+
162
+ var renderMathInElement = function renderMathInElement(elem, options) {
163
+ if (!elem) {
164
+ throw new Error("No element provided to render");
165
+ }
166
+
167
+ var optionsCopy = {}; // Object.assign(optionsCopy, option)
168
+
169
+ for (var option in options) {
170
+ if (options.hasOwnProperty(option)) {
171
+ optionsCopy[option] = options[option];
172
+ }
173
+ } // default options
174
+
175
+
176
+ optionsCopy.delimiters = optionsCopy.delimiters || [{
177
+ left: "$$",
178
+ right: "$$",
179
+ display: true
180
+ }, {
181
+ left: "\\(",
182
+ right: "\\)",
183
+ display: false
184
+ }, // LaTeX uses $…$, but it ruins the display of normal `$` in text:
185
+ // {left: "$", right: "$", display: false},
186
+ // $ must come after $$
187
+ // Render AMS environments even if outside $$…$$ delimiters.
188
+ {
189
+ left: "\\begin{equation}",
190
+ right: "\\end{equation}",
191
+ display: true
192
+ }, {
193
+ left: "\\begin{align}",
194
+ right: "\\end{align}",
195
+ display: true
196
+ }, {
197
+ left: "\\begin{alignat}",
198
+ right: "\\end{alignat}",
199
+ display: true
200
+ }, {
201
+ left: "\\begin{gather}",
202
+ right: "\\end{gather}",
203
+ display: true
204
+ }, {
205
+ left: "\\begin{CD}",
206
+ right: "\\end{CD}",
207
+ display: true
208
+ }, {
209
+ left: "\\[",
210
+ right: "\\]",
211
+ display: true
212
+ }];
213
+ optionsCopy.ignoredTags = optionsCopy.ignoredTags || ["script", "noscript", "style", "textarea", "pre", "code", "option"];
214
+ optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || [];
215
+ optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; // Enable sharing of global macros defined via `\gdef` between different
216
+ // math elements within a single call to `renderMathInElement`.
217
+
218
+ optionsCopy.macros = optionsCopy.macros || {};
219
+ renderElem(elem, optionsCopy);
220
+ };
221
+
222
+ export default renderMathInElement;
@@ -0,0 +1,14 @@
1
+ /* Force selection of entire .katex/.katex-display blocks, so that we can
2
+ * copy/paste the entire source code. If you omit this CSS, partial
3
+ * selections of a formula will work, but will copy the ugly HTML
4
+ * representation instead of the LaTeX source code. (Full selections will
5
+ * still produce the LaTeX source code.)
6
+ */
7
+ .katex,
8
+ .katex-display {
9
+ -webkit-user-select: all;
10
+ -moz-user-select: all;
11
+ -ms-user-select: all;
12
+ user-select: all;
13
+ }
14
+