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.
- llms/__init__.py +4 -0
- llms/__main__.py +9 -0
- llms/db.py +359 -0
- llms/extensions/analytics/ui/index.mjs +1444 -0
- llms/extensions/app/README.md +20 -0
- llms/extensions/app/__init__.py +589 -0
- llms/extensions/app/db.py +536 -0
- {llms_py-2.0.9.data/data → llms/extensions/app}/ui/Recents.mjs +100 -73
- llms_py-2.0.9.data/data/ui/Sidebar.mjs → llms/extensions/app/ui/index.mjs +150 -79
- llms/extensions/app/ui/threadStore.mjs +433 -0
- llms/extensions/core_tools/CALCULATOR.md +32 -0
- llms/extensions/core_tools/__init__.py +637 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/closebrackets.js +201 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/closetag.js +185 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/continuelist.js +101 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/matchbrackets.js +160 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/matchtags.js +66 -0
- llms/extensions/core_tools/ui/codemirror/addon/edit/trailingspace.js +27 -0
- llms/extensions/core_tools/ui/codemirror/addon/selection/active-line.js +72 -0
- llms/extensions/core_tools/ui/codemirror/addon/selection/mark-selection.js +119 -0
- llms/extensions/core_tools/ui/codemirror/addon/selection/selection-pointer.js +98 -0
- llms/extensions/core_tools/ui/codemirror/codemirror.css +344 -0
- llms/extensions/core_tools/ui/codemirror/codemirror.js +9884 -0
- llms/extensions/core_tools/ui/codemirror/doc/docs.css +225 -0
- llms/extensions/core_tools/ui/codemirror/doc/source_sans.woff +0 -0
- llms/extensions/core_tools/ui/codemirror/mode/clike/clike.js +942 -0
- llms/extensions/core_tools/ui/codemirror/mode/javascript/index.html +118 -0
- llms/extensions/core_tools/ui/codemirror/mode/javascript/javascript.js +962 -0
- llms/extensions/core_tools/ui/codemirror/mode/javascript/typescript.html +62 -0
- llms/extensions/core_tools/ui/codemirror/mode/python/python.js +402 -0
- llms/extensions/core_tools/ui/codemirror/theme/dracula.css +40 -0
- llms/extensions/core_tools/ui/codemirror/theme/mocha.css +135 -0
- llms/extensions/core_tools/ui/index.mjs +650 -0
- llms/extensions/gallery/README.md +61 -0
- llms/extensions/gallery/__init__.py +63 -0
- llms/extensions/gallery/db.py +243 -0
- llms/extensions/gallery/ui/index.mjs +482 -0
- llms/extensions/katex/README.md +39 -0
- llms/extensions/katex/__init__.py +6 -0
- llms/extensions/katex/ui/README.md +125 -0
- llms/extensions/katex/ui/contrib/auto-render.js +338 -0
- llms/extensions/katex/ui/contrib/auto-render.min.js +1 -0
- llms/extensions/katex/ui/contrib/auto-render.mjs +244 -0
- llms/extensions/katex/ui/contrib/copy-tex.js +127 -0
- llms/extensions/katex/ui/contrib/copy-tex.min.js +1 -0
- llms/extensions/katex/ui/contrib/copy-tex.mjs +105 -0
- llms/extensions/katex/ui/contrib/mathtex-script-type.js +109 -0
- llms/extensions/katex/ui/contrib/mathtex-script-type.min.js +1 -0
- llms/extensions/katex/ui/contrib/mathtex-script-type.mjs +24 -0
- llms/extensions/katex/ui/contrib/mhchem.js +3213 -0
- llms/extensions/katex/ui/contrib/mhchem.min.js +1 -0
- llms/extensions/katex/ui/contrib/mhchem.mjs +3109 -0
- llms/extensions/katex/ui/contrib/render-a11y-string.js +887 -0
- llms/extensions/katex/ui/contrib/render-a11y-string.min.js +1 -0
- llms/extensions/katex/ui/contrib/render-a11y-string.mjs +800 -0
- llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Bold.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Italic.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Main-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Math-Italic.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Script-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- llms/extensions/katex/ui/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- llms/extensions/katex/ui/index.mjs +92 -0
- llms/extensions/katex/ui/katex-swap.css +1230 -0
- llms/extensions/katex/ui/katex-swap.min.css +1 -0
- llms/extensions/katex/ui/katex.css +1230 -0
- llms/extensions/katex/ui/katex.js +19080 -0
- llms/extensions/katex/ui/katex.min.css +1 -0
- llms/extensions/katex/ui/katex.min.js +1 -0
- llms/extensions/katex/ui/katex.min.mjs +1 -0
- llms/extensions/katex/ui/katex.mjs +18547 -0
- llms/extensions/providers/__init__.py +22 -0
- llms/extensions/providers/anthropic.py +233 -0
- llms/extensions/providers/cerebras.py +37 -0
- llms/extensions/providers/chutes.py +153 -0
- llms/extensions/providers/google.py +481 -0
- llms/extensions/providers/nvidia.py +103 -0
- llms/extensions/providers/openai.py +154 -0
- llms/extensions/providers/openrouter.py +74 -0
- llms/extensions/providers/zai.py +182 -0
- llms/extensions/system_prompts/README.md +22 -0
- llms/extensions/system_prompts/__init__.py +45 -0
- llms/extensions/system_prompts/ui/index.mjs +280 -0
- llms/extensions/system_prompts/ui/prompts.json +1067 -0
- llms/extensions/tools/__init__.py +144 -0
- llms/extensions/tools/ui/index.mjs +706 -0
- llms/index.html +58 -0
- llms/llms.json +400 -0
- llms/main.py +4407 -0
- llms/providers-extra.json +394 -0
- llms/providers.json +1 -0
- llms/ui/App.mjs +188 -0
- llms/ui/ai.mjs +217 -0
- llms/ui/app.css +7081 -0
- llms/ui/ctx.mjs +412 -0
- llms/ui/index.mjs +131 -0
- llms/ui/lib/chart.js +14 -0
- llms/ui/lib/charts.mjs +16 -0
- llms/ui/lib/color.js +14 -0
- llms/ui/lib/servicestack-vue.mjs +37 -0
- llms/ui/lib/vue.min.mjs +13 -0
- llms/ui/lib/vue.mjs +18530 -0
- {llms_py-2.0.9.data/data → llms}/ui/markdown.mjs +33 -15
- llms/ui/modules/chat/ChatBody.mjs +976 -0
- llms/ui/modules/chat/SettingsDialog.mjs +374 -0
- llms/ui/modules/chat/index.mjs +991 -0
- llms/ui/modules/icons.mjs +46 -0
- llms/ui/modules/layout.mjs +271 -0
- llms/ui/modules/model-selector.mjs +811 -0
- llms/ui/tailwind.input.css +742 -0
- {llms_py-2.0.9.data/data → llms}/ui/typography.css +133 -7
- llms/ui/utils.mjs +261 -0
- llms_py-3.0.10.dist-info/METADATA +49 -0
- llms_py-3.0.10.dist-info/RECORD +177 -0
- llms_py-3.0.10.dist-info/entry_points.txt +2 -0
- {llms_py-2.0.9.dist-info → llms_py-3.0.10.dist-info}/licenses/LICENSE +1 -2
- llms.py +0 -1402
- llms_py-2.0.9.data/data/index.html +0 -64
- llms_py-2.0.9.data/data/llms.json +0 -447
- llms_py-2.0.9.data/data/requirements.txt +0 -1
- llms_py-2.0.9.data/data/ui/App.mjs +0 -20
- llms_py-2.0.9.data/data/ui/ChatPrompt.mjs +0 -389
- llms_py-2.0.9.data/data/ui/Main.mjs +0 -680
- llms_py-2.0.9.data/data/ui/app.css +0 -3951
- llms_py-2.0.9.data/data/ui/lib/servicestack-vue.min.mjs +0 -37
- llms_py-2.0.9.data/data/ui/lib/vue.min.mjs +0 -12
- llms_py-2.0.9.data/data/ui/tailwind.input.css +0 -261
- llms_py-2.0.9.data/data/ui/threadStore.mjs +0 -273
- llms_py-2.0.9.data/data/ui/utils.mjs +0 -114
- llms_py-2.0.9.data/data/ui.json +0 -1069
- llms_py-2.0.9.dist-info/METADATA +0 -941
- llms_py-2.0.9.dist-info/RECORD +0 -30
- llms_py-2.0.9.dist-info/entry_points.txt +0 -2
- {llms_py-2.0.9.data/data → llms}/ui/fav.svg +0 -0
- {llms_py-2.0.9.data/data → llms}/ui/lib/highlight.min.mjs +0 -0
- {llms_py-2.0.9.data/data → llms}/ui/lib/idb.min.mjs +0 -0
- {llms_py-2.0.9.data/data → llms}/ui/lib/marked.min.mjs +0 -0
- /llms_py-2.0.9.data/data/ui/lib/servicestack-client.min.mjs → /llms/ui/lib/servicestack-client.mjs +0 -0
- {llms_py-2.0.9.data/data → llms}/ui/lib/vue-router.min.mjs +0 -0
- {llms_py-2.0.9.dist-info → llms_py-3.0.10.dist-info}/WHEEL +0 -0
- {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
|
+
});
|