llms-py 2.0.9__py3-none-any.whl → 3.0.10__py3-none-any.whl

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 (194) hide show
  1. llms/__init__.py +4 -0
  2. llms/__main__.py +9 -0
  3. llms/db.py +359 -0
  4. llms/extensions/analytics/ui/index.mjs +1444 -0
  5. llms/extensions/app/README.md +20 -0
  6. llms/extensions/app/__init__.py +589 -0
  7. llms/extensions/app/db.py +536 -0
  8. {llms_py-2.0.9.data/data → llms/extensions/app}/ui/Recents.mjs +100 -73
  9. llms_py-2.0.9.data/data/ui/Sidebar.mjs → llms/extensions/app/ui/index.mjs +150 -79
  10. llms/extensions/app/ui/threadStore.mjs +433 -0
  11. llms/extensions/core_tools/CALCULATOR.md +32 -0
  12. llms/extensions/core_tools/__init__.py +637 -0
  13. llms/extensions/core_tools/ui/codemirror/addon/edit/closebrackets.js +201 -0
  14. llms/extensions/core_tools/ui/codemirror/addon/edit/closetag.js +185 -0
  15. llms/extensions/core_tools/ui/codemirror/addon/edit/continuelist.js +101 -0
  16. llms/extensions/core_tools/ui/codemirror/addon/edit/matchbrackets.js +160 -0
  17. llms/extensions/core_tools/ui/codemirror/addon/edit/matchtags.js +66 -0
  18. llms/extensions/core_tools/ui/codemirror/addon/edit/trailingspace.js +27 -0
  19. llms/extensions/core_tools/ui/codemirror/addon/selection/active-line.js +72 -0
  20. llms/extensions/core_tools/ui/codemirror/addon/selection/mark-selection.js +119 -0
  21. llms/extensions/core_tools/ui/codemirror/addon/selection/selection-pointer.js +98 -0
  22. llms/extensions/core_tools/ui/codemirror/codemirror.css +344 -0
  23. llms/extensions/core_tools/ui/codemirror/codemirror.js +9884 -0
  24. llms/extensions/core_tools/ui/codemirror/doc/docs.css +225 -0
  25. llms/extensions/core_tools/ui/codemirror/doc/source_sans.woff +0 -0
  26. llms/extensions/core_tools/ui/codemirror/mode/clike/clike.js +942 -0
  27. llms/extensions/core_tools/ui/codemirror/mode/javascript/index.html +118 -0
  28. llms/extensions/core_tools/ui/codemirror/mode/javascript/javascript.js +962 -0
  29. llms/extensions/core_tools/ui/codemirror/mode/javascript/typescript.html +62 -0
  30. llms/extensions/core_tools/ui/codemirror/mode/python/python.js +402 -0
  31. llms/extensions/core_tools/ui/codemirror/theme/dracula.css +40 -0
  32. llms/extensions/core_tools/ui/codemirror/theme/mocha.css +135 -0
  33. llms/extensions/core_tools/ui/index.mjs +650 -0
  34. llms/extensions/gallery/README.md +61 -0
  35. llms/extensions/gallery/__init__.py +63 -0
  36. llms/extensions/gallery/db.py +243 -0
  37. llms/extensions/gallery/ui/index.mjs +482 -0
  38. llms/extensions/katex/README.md +39 -0
  39. llms/extensions/katex/__init__.py +6 -0
  40. llms/extensions/katex/ui/README.md +125 -0
  41. llms/extensions/katex/ui/contrib/auto-render.js +338 -0
  42. llms/extensions/katex/ui/contrib/auto-render.min.js +1 -0
  43. llms/extensions/katex/ui/contrib/auto-render.mjs +244 -0
  44. llms/extensions/katex/ui/contrib/copy-tex.js +127 -0
  45. llms/extensions/katex/ui/contrib/copy-tex.min.js +1 -0
  46. llms/extensions/katex/ui/contrib/copy-tex.mjs +105 -0
  47. llms/extensions/katex/ui/contrib/mathtex-script-type.js +109 -0
  48. llms/extensions/katex/ui/contrib/mathtex-script-type.min.js +1 -0
  49. llms/extensions/katex/ui/contrib/mathtex-script-type.mjs +24 -0
  50. llms/extensions/katex/ui/contrib/mhchem.js +3213 -0
  51. llms/extensions/katex/ui/contrib/mhchem.min.js +1 -0
  52. llms/extensions/katex/ui/contrib/mhchem.mjs +3109 -0
  53. llms/extensions/katex/ui/contrib/render-a11y-string.js +887 -0
  54. llms/extensions/katex/ui/contrib/render-a11y-string.min.js +1 -0
  55. llms/extensions/katex/ui/contrib/render-a11y-string.mjs +800 -0
  56. llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.ttf +0 -0
  57. llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.woff +0 -0
  58. llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  59. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  60. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  61. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  62. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  63. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  64. llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  65. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  66. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  67. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  68. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  69. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  70. llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  71. llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.ttf +0 -0
  72. llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.woff +0 -0
  73. llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.woff2 +0 -0
  74. llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  75. llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  76. llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  77. llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.ttf +0 -0
  78. llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.woff +0 -0
  79. llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.woff2 +0 -0
  80. llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.ttf +0 -0
  81. llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.woff +0 -0
  82. llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.woff2 +0 -0
  83. llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  84. llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  85. llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  86. llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.ttf +0 -0
  87. llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.woff +0 -0
  88. llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.woff2 +0 -0
  89. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  90. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  91. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  92. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  93. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  94. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  95. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  96. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  97. llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  98. llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.ttf +0 -0
  99. llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.woff +0 -0
  100. llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.woff2 +0 -0
  101. llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.ttf +0 -0
  102. llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.woff +0 -0
  103. llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  104. llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.ttf +0 -0
  105. llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.woff +0 -0
  106. llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  107. llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.ttf +0 -0
  108. llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.woff +0 -0
  109. llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  110. llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.ttf +0 -0
  111. llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.woff +0 -0
  112. llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  113. llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  114. llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  115. llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  116. llms/extensions/katex/ui/index.mjs +92 -0
  117. llms/extensions/katex/ui/katex-swap.css +1230 -0
  118. llms/extensions/katex/ui/katex-swap.min.css +1 -0
  119. llms/extensions/katex/ui/katex.css +1230 -0
  120. llms/extensions/katex/ui/katex.js +19080 -0
  121. llms/extensions/katex/ui/katex.min.css +1 -0
  122. llms/extensions/katex/ui/katex.min.js +1 -0
  123. llms/extensions/katex/ui/katex.min.mjs +1 -0
  124. llms/extensions/katex/ui/katex.mjs +18547 -0
  125. llms/extensions/providers/__init__.py +22 -0
  126. llms/extensions/providers/anthropic.py +233 -0
  127. llms/extensions/providers/cerebras.py +37 -0
  128. llms/extensions/providers/chutes.py +153 -0
  129. llms/extensions/providers/google.py +481 -0
  130. llms/extensions/providers/nvidia.py +103 -0
  131. llms/extensions/providers/openai.py +154 -0
  132. llms/extensions/providers/openrouter.py +74 -0
  133. llms/extensions/providers/zai.py +182 -0
  134. llms/extensions/system_prompts/README.md +22 -0
  135. llms/extensions/system_prompts/__init__.py +45 -0
  136. llms/extensions/system_prompts/ui/index.mjs +280 -0
  137. llms/extensions/system_prompts/ui/prompts.json +1067 -0
  138. llms/extensions/tools/__init__.py +144 -0
  139. llms/extensions/tools/ui/index.mjs +706 -0
  140. llms/index.html +58 -0
  141. llms/llms.json +400 -0
  142. llms/main.py +4407 -0
  143. llms/providers-extra.json +394 -0
  144. llms/providers.json +1 -0
  145. llms/ui/App.mjs +188 -0
  146. llms/ui/ai.mjs +217 -0
  147. llms/ui/app.css +7081 -0
  148. llms/ui/ctx.mjs +412 -0
  149. llms/ui/index.mjs +131 -0
  150. llms/ui/lib/chart.js +14 -0
  151. llms/ui/lib/charts.mjs +16 -0
  152. llms/ui/lib/color.js +14 -0
  153. llms/ui/lib/servicestack-vue.mjs +37 -0
  154. llms/ui/lib/vue.min.mjs +13 -0
  155. llms/ui/lib/vue.mjs +18530 -0
  156. {llms_py-2.0.9.data/data → llms}/ui/markdown.mjs +33 -15
  157. llms/ui/modules/chat/ChatBody.mjs +976 -0
  158. llms/ui/modules/chat/SettingsDialog.mjs +374 -0
  159. llms/ui/modules/chat/index.mjs +991 -0
  160. llms/ui/modules/icons.mjs +46 -0
  161. llms/ui/modules/layout.mjs +271 -0
  162. llms/ui/modules/model-selector.mjs +811 -0
  163. llms/ui/tailwind.input.css +742 -0
  164. {llms_py-2.0.9.data/data → llms}/ui/typography.css +133 -7
  165. llms/ui/utils.mjs +261 -0
  166. llms_py-3.0.10.dist-info/METADATA +49 -0
  167. llms_py-3.0.10.dist-info/RECORD +177 -0
  168. llms_py-3.0.10.dist-info/entry_points.txt +2 -0
  169. {llms_py-2.0.9.dist-info → llms_py-3.0.10.dist-info}/licenses/LICENSE +1 -2
  170. llms.py +0 -1402
  171. llms_py-2.0.9.data/data/index.html +0 -64
  172. llms_py-2.0.9.data/data/llms.json +0 -447
  173. llms_py-2.0.9.data/data/requirements.txt +0 -1
  174. llms_py-2.0.9.data/data/ui/App.mjs +0 -20
  175. llms_py-2.0.9.data/data/ui/ChatPrompt.mjs +0 -389
  176. llms_py-2.0.9.data/data/ui/Main.mjs +0 -680
  177. llms_py-2.0.9.data/data/ui/app.css +0 -3951
  178. llms_py-2.0.9.data/data/ui/lib/servicestack-vue.min.mjs +0 -37
  179. llms_py-2.0.9.data/data/ui/lib/vue.min.mjs +0 -12
  180. llms_py-2.0.9.data/data/ui/tailwind.input.css +0 -261
  181. llms_py-2.0.9.data/data/ui/threadStore.mjs +0 -273
  182. llms_py-2.0.9.data/data/ui/utils.mjs +0 -114
  183. llms_py-2.0.9.data/data/ui.json +0 -1069
  184. llms_py-2.0.9.dist-info/METADATA +0 -941
  185. llms_py-2.0.9.dist-info/RECORD +0 -30
  186. llms_py-2.0.9.dist-info/entry_points.txt +0 -2
  187. {llms_py-2.0.9.data/data → llms}/ui/fav.svg +0 -0
  188. {llms_py-2.0.9.data/data → llms}/ui/lib/highlight.min.mjs +0 -0
  189. {llms_py-2.0.9.data/data → llms}/ui/lib/idb.min.mjs +0 -0
  190. {llms_py-2.0.9.data/data → llms}/ui/lib/marked.min.mjs +0 -0
  191. /llms_py-2.0.9.data/data/ui/lib/servicestack-client.min.mjs → /llms/ui/lib/servicestack-client.mjs +0 -0
  192. {llms_py-2.0.9.data/data → llms}/ui/lib/vue-router.min.mjs +0 -0
  193. {llms_py-2.0.9.dist-info → llms_py-3.0.10.dist-info}/WHEEL +0 -0
  194. {llms_py-2.0.9.dist-info → llms_py-3.0.10.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,244 @@
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
+ // Concatenate all sibling text nodes.
142
+ // Webkit browsers split very large text nodes into smaller ones,
143
+ // so the delimiters may be split across different nodes.
144
+ var textContentConcat = childNode.textContent;
145
+ var sibling = childNode.nextSibling;
146
+ var nSiblings = 0;
147
+
148
+ while (sibling && sibling.nodeType === Node.TEXT_NODE) {
149
+ textContentConcat += sibling.textContent;
150
+ sibling = sibling.nextSibling;
151
+ nSiblings++;
152
+ }
153
+
154
+ var frag = renderMathInText(textContentConcat, optionsCopy);
155
+
156
+ if (frag) {
157
+ // Remove extra text nodes
158
+ for (var j = 0; j < nSiblings; j++) {
159
+ childNode.nextSibling.remove();
160
+ }
161
+
162
+ i += frag.childNodes.length - 1;
163
+ elem.replaceChild(frag, childNode);
164
+ } else {
165
+ // If the concatenated text does not contain math
166
+ // the siblings will not either
167
+ i += nSiblings;
168
+ }
169
+ } else if (childNode.nodeType === 1) {
170
+ (function () {
171
+ // Element node
172
+ var className = ' ' + childNode.className + ' ';
173
+ var shouldRender = optionsCopy.ignoredTags.indexOf(childNode.nodeName.toLowerCase()) === -1 && optionsCopy.ignoredClasses.every(x => className.indexOf(' ' + x + ' ') === -1);
174
+
175
+ if (shouldRender) {
176
+ renderElem(childNode, optionsCopy);
177
+ }
178
+ })();
179
+ } // Otherwise, it's something else, and ignore it.
180
+
181
+ }
182
+ };
183
+
184
+ var renderMathInElement = function renderMathInElement(elem, options) {
185
+ if (!elem) {
186
+ throw new Error("No element provided to render");
187
+ }
188
+
189
+ var optionsCopy = {}; // Object.assign(optionsCopy, option)
190
+
191
+ for (var option in options) {
192
+ if (options.hasOwnProperty(option)) {
193
+ optionsCopy[option] = options[option];
194
+ }
195
+ } // default options
196
+
197
+
198
+ optionsCopy.delimiters = optionsCopy.delimiters || [{
199
+ left: "$$",
200
+ right: "$$",
201
+ display: true
202
+ }, {
203
+ left: "\\(",
204
+ right: "\\)",
205
+ display: false
206
+ }, // LaTeX uses $…$, but it ruins the display of normal `$` in text:
207
+ // {left: "$", right: "$", display: false},
208
+ // $ must come after $$
209
+ // Render AMS environments even if outside $$…$$ delimiters.
210
+ {
211
+ left: "\\begin{equation}",
212
+ right: "\\end{equation}",
213
+ display: true
214
+ }, {
215
+ left: "\\begin{align}",
216
+ right: "\\end{align}",
217
+ display: true
218
+ }, {
219
+ left: "\\begin{alignat}",
220
+ right: "\\end{alignat}",
221
+ display: true
222
+ }, {
223
+ left: "\\begin{gather}",
224
+ right: "\\end{gather}",
225
+ display: true
226
+ }, {
227
+ left: "\\begin{CD}",
228
+ right: "\\end{CD}",
229
+ display: true
230
+ }, {
231
+ left: "\\[",
232
+ right: "\\]",
233
+ display: true
234
+ }];
235
+ optionsCopy.ignoredTags = optionsCopy.ignoredTags || ["script", "noscript", "style", "textarea", "pre", "code", "option"];
236
+ optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || [];
237
+ optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; // Enable sharing of global macros defined via `\gdef` between different
238
+ // math elements within a single call to `renderMathInElement`.
239
+
240
+ optionsCopy.macros = optionsCopy.macros || {};
241
+ renderElem(elem, optionsCopy);
242
+ };
243
+
244
+ export { renderMathInElement as default };
@@ -0,0 +1,127 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if(typeof define === 'function' && define.amd)
5
+ define([], factory);
6
+ else {
7
+ var a = factory();
8
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
+ }
10
+ })((typeof self !== 'undefined' ? self : this), function() {
11
+ return /******/ (function() { // webpackBootstrap
12
+ /******/ "use strict";
13
+ var __webpack_exports__ = {};
14
+
15
+ ;// CONCATENATED MODULE: ./contrib/copy-tex/katex2tex.js
16
+ // Set these to how you want inline and display math to be delimited.
17
+ const defaultCopyDelimiters = {
18
+ inline: ['$', '$'],
19
+ // alternative: ['\(', '\)']
20
+ display: ['$$', '$$'] // alternative: ['\[', '\]']
21
+
22
+ }; // Replace .katex elements with their TeX source (<annotation> element).
23
+ // Modifies fragment in-place. Useful for writing your own 'copy' handler,
24
+ // as in copy-tex.js.
25
+
26
+ function katexReplaceWithTex(fragment, copyDelimiters) {
27
+ if (copyDelimiters === void 0) {
28
+ copyDelimiters = defaultCopyDelimiters;
29
+ }
30
+
31
+ // Remove .katex-html blocks that are preceded by .katex-mathml blocks
32
+ // (which will get replaced below).
33
+ const katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html');
34
+
35
+ for (let i = 0; i < katexHtml.length; i++) {
36
+ const element = katexHtml[i];
37
+
38
+ if (element.remove) {
39
+ element.remove();
40
+ } else if (element.parentNode) {
41
+ element.parentNode.removeChild(element);
42
+ }
43
+ } // Replace .katex-mathml elements with their annotation (TeX source)
44
+ // descendant, with inline delimiters.
45
+
46
+
47
+ const katexMathml = fragment.querySelectorAll('.katex-mathml');
48
+
49
+ for (let i = 0; i < katexMathml.length; i++) {
50
+ const element = katexMathml[i];
51
+ const texSource = element.querySelector('annotation');
52
+
53
+ if (texSource) {
54
+ if (element.replaceWith) {
55
+ element.replaceWith(texSource);
56
+ } else if (element.parentNode) {
57
+ element.parentNode.replaceChild(texSource, element);
58
+ }
59
+
60
+ texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1];
61
+ }
62
+ } // Switch display math to display delimiters.
63
+
64
+
65
+ const displays = fragment.querySelectorAll('.katex-display annotation');
66
+
67
+ for (let i = 0; i < displays.length; i++) {
68
+ const element = displays[i];
69
+ element.innerHTML = copyDelimiters.display[0] + element.innerHTML.substr(copyDelimiters.inline[0].length, element.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1];
70
+ }
71
+
72
+ return fragment;
73
+ }
74
+ /* harmony default export */ var katex2tex = (katexReplaceWithTex);
75
+ ;// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.js
76
+ // Return <div class="katex"> element containing node, or null if not found.
77
+
78
+ function closestKatex(node) {
79
+ // If node is a Text Node, for example, go up to containing Element,
80
+ // where we can apply the `closest` method.
81
+ const element = node instanceof Element ? node : node.parentElement;
82
+ return element && element.closest('.katex');
83
+ } // Global copy handler to modify behavior on/within .katex elements.
84
+
85
+
86
+ document.addEventListener('copy', function (event) {
87
+ const selection = window.getSelection();
88
+
89
+ if (selection.isCollapsed || !event.clipboardData) {
90
+ return; // default action OK if selection is empty or unchangeable
91
+ }
92
+
93
+ const clipboardData = event.clipboardData;
94
+ const range = selection.getRangeAt(0); // When start point is within a formula, expand to entire formula.
95
+
96
+ const startKatex = closestKatex(range.startContainer);
97
+
98
+ if (startKatex) {
99
+ range.setStartBefore(startKatex);
100
+ } // Similarly, when end point is within a formula, expand to entire formula.
101
+
102
+
103
+ const endKatex = closestKatex(range.endContainer);
104
+
105
+ if (endKatex) {
106
+ range.setEndAfter(endKatex);
107
+ }
108
+
109
+ const fragment = range.cloneContents();
110
+
111
+ if (!fragment.querySelector('.katex-mathml')) {
112
+ return; // default action OK if no .katex-mathml elements
113
+ }
114
+
115
+ const htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); // Preserve usual HTML copy/paste behavior.
116
+
117
+ clipboardData.setData('text/html', htmlContents); // Rewrite plain-text version.
118
+
119
+ clipboardData.setData('text/plain', katex2tex(fragment).textContent); // Prevent normal copy handling.
120
+
121
+ event.preventDefault();
122
+ });
123
+ __webpack_exports__ = __webpack_exports__["default"];
124
+ /******/ return __webpack_exports__;
125
+ /******/ })()
126
+ ;
127
+ });
@@ -0,0 +1 @@
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}("undefined"!=typeof self?self:this,(function(){return function(){"use strict";var e={};const t={inline:["$","$"],display:["$$","$$"]};var n=function(e,n){void 0===n&&(n=t);const o=e.querySelectorAll(".katex-mathml + .katex-html");for(let e=0;e<o.length;e++){const t=o[e];t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}const r=e.querySelectorAll(".katex-mathml");for(let e=0;e<r.length;e++){const t=r[e],o=t.querySelector("annotation");o&&(t.replaceWith?t.replaceWith(o):t.parentNode&&t.parentNode.replaceChild(o,t),o.innerHTML=n.inline[0]+o.innerHTML+n.inline[1])}const l=e.querySelectorAll(".katex-display annotation");for(let e=0;e<l.length;e++){const t=l[e];t.innerHTML=n.display[0]+t.innerHTML.substr(n.inline[0].length,t.innerHTML.length-n.inline[0].length-n.inline[1].length)+n.display[1]}return e};function o(e){const t=e instanceof Element?e:e.parentElement;return t&&t.closest(".katex")}return document.addEventListener("copy",(function(e){const t=window.getSelection();if(t.isCollapsed||!e.clipboardData)return;const r=e.clipboardData,l=t.getRangeAt(0),i=o(l.startContainer);i&&l.setStartBefore(i);const a=o(l.endContainer);a&&l.setEndAfter(a);const s=l.cloneContents();if(!s.querySelector(".katex-mathml"))return;const c=Array.prototype.map.call(s.childNodes,(e=>e instanceof Text?e.textContent:e.outerHTML)).join("");r.setData("text/html",c),r.setData("text/plain",n(s).textContent),e.preventDefault()})),e=e.default}()}));
@@ -0,0 +1,105 @@
1
+ // Set these to how you want inline and display math to be delimited.
2
+ var defaultCopyDelimiters = {
3
+ inline: ['$', '$'],
4
+ // alternative: ['\(', '\)']
5
+ display: ['$$', '$$'] // alternative: ['\[', '\]']
6
+
7
+ }; // Replace .katex elements with their TeX source (<annotation> element).
8
+ // Modifies fragment in-place. Useful for writing your own 'copy' handler,
9
+ // as in copy-tex.js.
10
+
11
+ function katexReplaceWithTex(fragment, copyDelimiters) {
12
+ if (copyDelimiters === void 0) {
13
+ copyDelimiters = defaultCopyDelimiters;
14
+ }
15
+
16
+ // Remove .katex-html blocks that are preceded by .katex-mathml blocks
17
+ // (which will get replaced below).
18
+ var katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html');
19
+
20
+ for (var i = 0; i < katexHtml.length; i++) {
21
+ var element = katexHtml[i];
22
+
23
+ if (element.remove) {
24
+ element.remove();
25
+ } else if (element.parentNode) {
26
+ element.parentNode.removeChild(element);
27
+ }
28
+ } // Replace .katex-mathml elements with their annotation (TeX source)
29
+ // descendant, with inline delimiters.
30
+
31
+
32
+ var katexMathml = fragment.querySelectorAll('.katex-mathml');
33
+
34
+ for (var _i = 0; _i < katexMathml.length; _i++) {
35
+ var _element = katexMathml[_i];
36
+
37
+ var texSource = _element.querySelector('annotation');
38
+
39
+ if (texSource) {
40
+ if (_element.replaceWith) {
41
+ _element.replaceWith(texSource);
42
+ } else if (_element.parentNode) {
43
+ _element.parentNode.replaceChild(texSource, _element);
44
+ }
45
+
46
+ texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1];
47
+ }
48
+ } // Switch display math to display delimiters.
49
+
50
+
51
+ var displays = fragment.querySelectorAll('.katex-display annotation');
52
+
53
+ for (var _i2 = 0; _i2 < displays.length; _i2++) {
54
+ var _element2 = displays[_i2];
55
+ _element2.innerHTML = copyDelimiters.display[0] + _element2.innerHTML.substr(copyDelimiters.inline[0].length, _element2.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1];
56
+ }
57
+
58
+ return fragment;
59
+ }
60
+
61
+ function closestKatex(node) {
62
+ // If node is a Text Node, for example, go up to containing Element,
63
+ // where we can apply the `closest` method.
64
+ var element = node instanceof Element ? node : node.parentElement;
65
+ return element && element.closest('.katex');
66
+ } // Global copy handler to modify behavior on/within .katex elements.
67
+
68
+
69
+ document.addEventListener('copy', function (event) {
70
+ var selection = window.getSelection();
71
+
72
+ if (selection.isCollapsed || !event.clipboardData) {
73
+ return; // default action OK if selection is empty or unchangeable
74
+ }
75
+
76
+ var clipboardData = event.clipboardData;
77
+ var range = selection.getRangeAt(0); // When start point is within a formula, expand to entire formula.
78
+
79
+ var startKatex = closestKatex(range.startContainer);
80
+
81
+ if (startKatex) {
82
+ range.setStartBefore(startKatex);
83
+ } // Similarly, when end point is within a formula, expand to entire formula.
84
+
85
+
86
+ var endKatex = closestKatex(range.endContainer);
87
+
88
+ if (endKatex) {
89
+ range.setEndAfter(endKatex);
90
+ }
91
+
92
+ var fragment = range.cloneContents();
93
+
94
+ if (!fragment.querySelector('.katex-mathml')) {
95
+ return; // default action OK if no .katex-mathml elements
96
+ }
97
+
98
+ var htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); // Preserve usual HTML copy/paste behavior.
99
+
100
+ clipboardData.setData('text/html', htmlContents); // Rewrite plain-text version.
101
+
102
+ clipboardData.setData('text/plain', katexReplaceWithTex(fragment).textContent); // Prevent normal copy handling.
103
+
104
+ event.preventDefault();
105
+ });
@@ -0,0 +1,109 @@
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 {
7
+ var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]);
8
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
+ }
10
+ })((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) {
11
+ return /******/ (function() { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ 757:
16
+ /***/ (function(module) {
17
+
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE__757__;
19
+
20
+ /***/ })
21
+
22
+ /******/ });
23
+ /************************************************************************/
24
+ /******/ // The module cache
25
+ /******/ var __webpack_module_cache__ = {};
26
+ /******/
27
+ /******/ // The require function
28
+ /******/ function __webpack_require__(moduleId) {
29
+ /******/ // Check if module is in cache
30
+ /******/ var 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
+ /******/ var 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
+ /******/ var 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(var 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
+ var __webpack_exports__ = {};
80
+ /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(757);
81
+ /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__);
82
+
83
+ let scripts = document.body.getElementsByTagName("script");
84
+ scripts = Array.prototype.slice.call(scripts);
85
+ scripts.forEach(function (script) {
86
+ if (!script.type || !script.type.match(/math\/tex/i)) {
87
+ return -1;
88
+ }
89
+
90
+ const display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null;
91
+ const katexElement = document.createElement(display ? "div" : "span");
92
+ katexElement.setAttribute("class", display ? "equation" : "inline-equation");
93
+
94
+ try {
95
+ katex__WEBPACK_IMPORTED_MODULE_0___default().render(script.text, katexElement, {
96
+ displayMode: display
97
+ });
98
+ } catch (err) {
99
+ //console.error(err); linter doesn't like this
100
+ katexElement.textContent = script.text;
101
+ }
102
+
103
+ script.parentNode.replaceChild(katexElement, script);
104
+ });
105
+ __webpack_exports__ = __webpack_exports__["default"];
106
+ /******/ return __webpack_exports__;
107
+ /******/ })()
108
+ ;
109
+ });
@@ -0,0 +1 @@
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],t);else{var n="object"==typeof exports?t(require("katex")):t(e.katex);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}("undefined"!=typeof self?self:this,(function(e){return function(){"use strict";var t={757:function(t){t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o={},i=r(757),a=r.n(i);let u=document.body.getElementsByTagName("script");return u=Array.prototype.slice.call(u),u.forEach((function(e){if(!e.type||!e.type.match(/math\/tex/i))return-1;const t=null!=e.type.match(/mode\s*=\s*display(;|\s|\n|$)/),n=document.createElement(t?"div":"span");n.setAttribute("class",t?"equation":"inline-equation");try{a().render(e.text,n,{displayMode:t})}catch(t){n.textContent=e.text}e.parentNode.replaceChild(n,e)})),o=o.default}()}));
@@ -0,0 +1,24 @@
1
+ import katex from '../katex.mjs';
2
+
3
+ var scripts = document.body.getElementsByTagName("script");
4
+ scripts = Array.prototype.slice.call(scripts);
5
+ scripts.forEach(function (script) {
6
+ if (!script.type || !script.type.match(/math\/tex/i)) {
7
+ return -1;
8
+ }
9
+
10
+ var display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null;
11
+ var katexElement = document.createElement(display ? "div" : "span");
12
+ katexElement.setAttribute("class", display ? "equation" : "inline-equation");
13
+
14
+ try {
15
+ katex.render(script.text, katexElement, {
16
+ displayMode: display
17
+ });
18
+ } catch (err) {
19
+ //console.error(err); linter doesn't like this
20
+ katexElement.textContent = script.text;
21
+ }
22
+
23
+ script.parentNode.replaceChild(katexElement, script);
24
+ });