llms-py 2.0.20__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 +3 -1
- llms/db.py +359 -0
- llms/{ui/Analytics.mjs → extensions/analytics/ui/index.mjs} +254 -327
- llms/extensions/app/README.md +20 -0
- llms/extensions/app/__init__.py +589 -0
- llms/extensions/app/db.py +536 -0
- llms/{ui → extensions/app/ui}/Recents.mjs +99 -73
- llms/{ui/Sidebar.mjs → extensions/app/ui/index.mjs} +139 -68
- 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 +36 -62
- llms/llms.json +180 -879
- llms/main.py +3640 -899
- llms/providers-extra.json +394 -0
- llms/providers.json +1 -0
- llms/ui/App.mjs +176 -8
- llms/ui/ai.mjs +156 -20
- llms/ui/app.css +3161 -244
- 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/highlight.min.mjs +1243 -0
- llms/ui/lib/idb.min.mjs +8 -0
- llms/ui/lib/marked.min.mjs +8 -0
- llms/ui/lib/servicestack-client.mjs +1 -0
- llms/ui/lib/servicestack-vue.mjs +37 -0
- llms/ui/lib/vue-router.min.mjs +6 -0
- llms/ui/lib/vue.min.mjs +13 -0
- llms/ui/lib/vue.mjs +18530 -0
- llms/ui/markdown.mjs +25 -14
- llms/ui/modules/chat/ChatBody.mjs +976 -0
- llms/ui/{SettingsDialog.mjs → modules/chat/SettingsDialog.mjs} +74 -74
- 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 +550 -78
- llms/ui/typography.css +54 -36
- llms/ui/utils.mjs +197 -92
- llms_py-3.0.10.dist-info/METADATA +49 -0
- llms_py-3.0.10.dist-info/RECORD +177 -0
- {llms_py-2.0.20.dist-info → llms_py-3.0.10.dist-info}/licenses/LICENSE +1 -2
- llms/ui/Avatar.mjs +0 -28
- llms/ui/Brand.mjs +0 -34
- llms/ui/ChatPrompt.mjs +0 -443
- llms/ui/Main.mjs +0 -740
- llms/ui/ModelSelector.mjs +0 -60
- llms/ui/ProviderIcon.mjs +0 -29
- llms/ui/ProviderStatus.mjs +0 -105
- llms/ui/SignIn.mjs +0 -64
- llms/ui/SystemPromptEditor.mjs +0 -31
- llms/ui/SystemPromptSelector.mjs +0 -36
- llms/ui/Welcome.mjs +0 -8
- llms/ui/threadStore.mjs +0 -524
- llms/ui.json +0 -1069
- llms_py-2.0.20.dist-info/METADATA +0 -931
- llms_py-2.0.20.dist-info/RECORD +0 -36
- {llms_py-2.0.20.dist-info → llms_py-3.0.10.dist-info}/WHEEL +0 -0
- {llms_py-2.0.20.dist-info → llms_py-3.0.10.dist-info}/entry_points.txt +0 -0
- {llms_py-2.0.20.dist-info → llms_py-3.0.10.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<h1><a href="https://katex.org/">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://katex.org/img/katex-logo.svg">
|
|
4
|
+
<img alt="KaTeX" width=130 src="https://katex.org/img/katex-logo-black.svg">
|
|
5
|
+
</picture>
|
|
6
|
+
</a></h1>
|
|
7
|
+
|
|
8
|
+
[](https://www.npmjs.com/package/katex)
|
|
9
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
10
|
+
[](https://github.com/KaTeX/KaTeX/actions?query=workflow%3ACI)
|
|
11
|
+
[](https://codecov.io/gh/KaTeX/KaTeX)
|
|
12
|
+
[](https://github.com/KaTeX/KaTeX/discussions)
|
|
13
|
+
[](https://www.jsdelivr.com/package/npm/katex)
|
|
14
|
+

|
|
15
|
+
[](https://gitpod.io/#https://github.com/KaTeX/KaTeX)
|
|
16
|
+
[](https://opencollective.com/katex)
|
|
17
|
+
|
|
18
|
+
KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web.
|
|
19
|
+
|
|
20
|
+
* **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](https://www.intmath.com/cg5/katex-mathjax-comparison.php).
|
|
21
|
+
* **Print quality:** KaTeX's layout is based on Donald Knuth's TeX, the gold standard for math typesetting.
|
|
22
|
+
* **Self contained:** KaTeX has no dependencies and can easily be bundled with your website resources.
|
|
23
|
+
* **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.
|
|
24
|
+
|
|
25
|
+
KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 11.
|
|
26
|
+
|
|
27
|
+
KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the [list of supported functions](https://katex.org/docs/supported.html).
|
|
28
|
+
|
|
29
|
+
Try out KaTeX [on the demo page](https://katex.org/#demo)!
|
|
30
|
+
|
|
31
|
+
## Getting started
|
|
32
|
+
|
|
33
|
+
### Starter template
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<!DOCTYPE html>
|
|
37
|
+
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
|
|
38
|
+
<html>
|
|
39
|
+
<head>
|
|
40
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.27/dist/katex.min.css" integrity="sha384-Pu5+C18nP5dwykLJOhd2U4Xen7rjScHN/qusop27hdd2drI+lL5KvX7YntvT8yew" crossorigin="anonymous">
|
|
41
|
+
|
|
42
|
+
<!-- The loading of KaTeX is deferred to speed up page rendering -->
|
|
43
|
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.27/dist/katex.min.js" integrity="sha384-2B8pfmZZ6JlVoScJm/5hQfNS2TI/6hPqDZInzzPc8oHpN5SgeNOf4LzREO6p5YtZ" crossorigin="anonymous"></script>
|
|
44
|
+
|
|
45
|
+
<!-- To automatically render math in text elements, include the auto-render extension: -->
|
|
46
|
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.27/dist/contrib/auto-render.min.js" integrity="sha384-hCXGrW6PitJEwbkoStFjeJxv+fSOOQKOPbJxSfM6G5sWZjAyWhXiTIIAmQqnlLlh" crossorigin="anonymous"
|
|
47
|
+
onload="renderMathInElement(document.body);"></script>
|
|
48
|
+
</head>
|
|
49
|
+
...
|
|
50
|
+
</html>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
You can also [download KaTeX](https://github.com/KaTeX/KaTeX/releases) and host it yourself.
|
|
54
|
+
|
|
55
|
+
For details on how to configure auto-render extension, refer to [the documentation](https://katex.org/docs/autorender.html).
|
|
56
|
+
|
|
57
|
+
### API
|
|
58
|
+
|
|
59
|
+
Call `katex.render` to render a TeX expression directly into a DOM element.
|
|
60
|
+
For example:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, {
|
|
64
|
+
throwOnError: false
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Call `katex.renderToString` to generate an HTML string of the rendered math,
|
|
69
|
+
e.g., for server-side rendering. For example:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
|
|
73
|
+
throwOnError: false
|
|
74
|
+
});
|
|
75
|
+
// '<span class="katex">...</span>'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Make sure to include the CSS and font files in both cases.
|
|
79
|
+
If you are doing all rendering on the server, there is no need to include the
|
|
80
|
+
JavaScript on the client.
|
|
81
|
+
|
|
82
|
+
The examples above use the `throwOnError: false` option, which renders invalid
|
|
83
|
+
inputs as the TeX source code in red (by default), with the error message as
|
|
84
|
+
hover text. For other available options, see the
|
|
85
|
+
[API documentation](https://katex.org/docs/api.html),
|
|
86
|
+
[options documentation](https://katex.org/docs/options.html), and
|
|
87
|
+
[handling errors documentation](https://katex.org/docs/error.html).
|
|
88
|
+
|
|
89
|
+
## Demo and Documentation
|
|
90
|
+
|
|
91
|
+
Learn more about using KaTeX [on the website](https://katex.org)!
|
|
92
|
+
|
|
93
|
+
## Contributors
|
|
94
|
+
|
|
95
|
+
### Code Contributors
|
|
96
|
+
|
|
97
|
+
This project exists thanks to all the people who contribute code. If you'd like to help, see [our guide to contributing code](CONTRIBUTING.md).
|
|
98
|
+
<a href="https://github.com/KaTeX/KaTeX/graphs/contributors"><img src="https://contributors-svg.opencollective.com/katex/contributors.svg?width=890&button=false" alt="Code contributors" /></a>
|
|
99
|
+
|
|
100
|
+
### Financial Contributors
|
|
101
|
+
|
|
102
|
+
Become a financial contributor and help us sustain our community.
|
|
103
|
+
|
|
104
|
+
#### Individuals
|
|
105
|
+
|
|
106
|
+
<a href="https://opencollective.com/katex"><img src="https://opencollective.com/katex/individuals.svg?width=890" alt="Contribute on Open Collective"></a>
|
|
107
|
+
|
|
108
|
+
#### Organizations
|
|
109
|
+
|
|
110
|
+
Support this project with your organization. Your logo will show up here with a link to your website.
|
|
111
|
+
|
|
112
|
+
<a href="https://opencollective.com/katex/organization/0/website"><img src="https://opencollective.com/katex/organization/0/avatar.svg" alt="Organization 1"></a>
|
|
113
|
+
<a href="https://opencollective.com/katex/organization/1/website"><img src="https://opencollective.com/katex/organization/1/avatar.svg" alt="Organization 2"></a>
|
|
114
|
+
<a href="https://opencollective.com/katex/organization/2/website"><img src="https://opencollective.com/katex/organization/2/avatar.svg" alt="Organization 3"></a>
|
|
115
|
+
<a href="https://opencollective.com/katex/organization/3/website"><img src="https://opencollective.com/katex/organization/3/avatar.svg" alt="Organization 4"></a>
|
|
116
|
+
<a href="https://opencollective.com/katex/organization/4/website"><img src="https://opencollective.com/katex/organization/4/avatar.svg" alt="Organization 5"></a>
|
|
117
|
+
<a href="https://opencollective.com/katex/organization/5/website"><img src="https://opencollective.com/katex/organization/5/avatar.svg" alt="Organization 6"></a>
|
|
118
|
+
<a href="https://opencollective.com/katex/organization/6/website"><img src="https://opencollective.com/katex/organization/6/avatar.svg" alt="Organization 7"></a>
|
|
119
|
+
<a href="https://opencollective.com/katex/organization/7/website"><img src="https://opencollective.com/katex/organization/7/avatar.svg" alt="Organization 8"></a>
|
|
120
|
+
<a href="https://opencollective.com/katex/organization/8/website"><img src="https://opencollective.com/katex/organization/8/avatar.svg" alt="Organization 9"></a>
|
|
121
|
+
<a href="https://opencollective.com/katex/organization/9/website"><img src="https://opencollective.com/katex/organization/9/avatar.svg" alt="Organization 10"></a>
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
KaTeX is licensed under the [MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -0,0 +1,338 @@
|
|
|
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__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
|
+
|
|
81
|
+
// EXPORTS
|
|
82
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
83
|
+
"default": function() { return /* binding */ auto_render; }
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// EXTERNAL MODULE: external "katex"
|
|
87
|
+
var external_katex_ = __webpack_require__(757);
|
|
88
|
+
var external_katex_default = /*#__PURE__*/__webpack_require__.n(external_katex_);
|
|
89
|
+
;// CONCATENATED MODULE: ./contrib/auto-render/splitAtDelimiters.js
|
|
90
|
+
/* eslint no-constant-condition:0 */
|
|
91
|
+
const findEndOfMath = function (delimiter, text, startIndex) {
|
|
92
|
+
// Adapted from
|
|
93
|
+
// https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx
|
|
94
|
+
let index = startIndex;
|
|
95
|
+
let braceLevel = 0;
|
|
96
|
+
const delimLength = delimiter.length;
|
|
97
|
+
|
|
98
|
+
while (index < text.length) {
|
|
99
|
+
const character = text[index];
|
|
100
|
+
|
|
101
|
+
if (braceLevel <= 0 && text.slice(index, index + delimLength) === delimiter) {
|
|
102
|
+
return index;
|
|
103
|
+
} else if (character === "\\") {
|
|
104
|
+
index++;
|
|
105
|
+
} else if (character === "{") {
|
|
106
|
+
braceLevel++;
|
|
107
|
+
} else if (character === "}") {
|
|
108
|
+
braceLevel--;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
index++;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return -1;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const escapeRegex = function (string) {
|
|
118
|
+
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const amsRegex = /^\\begin{/;
|
|
122
|
+
|
|
123
|
+
const splitAtDelimiters = function (text, delimiters) {
|
|
124
|
+
let index;
|
|
125
|
+
const data = [];
|
|
126
|
+
const regexLeft = new RegExp("(" + delimiters.map(x => escapeRegex(x.left)).join("|") + ")");
|
|
127
|
+
|
|
128
|
+
while (true) {
|
|
129
|
+
index = text.search(regexLeft);
|
|
130
|
+
|
|
131
|
+
if (index === -1) {
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (index > 0) {
|
|
136
|
+
data.push({
|
|
137
|
+
type: "text",
|
|
138
|
+
data: text.slice(0, index)
|
|
139
|
+
});
|
|
140
|
+
text = text.slice(index); // now text starts with delimiter
|
|
141
|
+
} // ... so this always succeeds:
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
const i = delimiters.findIndex(delim => text.startsWith(delim.left));
|
|
145
|
+
index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length);
|
|
146
|
+
|
|
147
|
+
if (index === -1) {
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const rawData = text.slice(0, index + delimiters[i].right.length);
|
|
152
|
+
const math = amsRegex.test(rawData) ? rawData : text.slice(delimiters[i].left.length, index);
|
|
153
|
+
data.push({
|
|
154
|
+
type: "math",
|
|
155
|
+
data: math,
|
|
156
|
+
rawData,
|
|
157
|
+
display: delimiters[i].display
|
|
158
|
+
});
|
|
159
|
+
text = text.slice(index + delimiters[i].right.length);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (text !== "") {
|
|
163
|
+
data.push({
|
|
164
|
+
type: "text",
|
|
165
|
+
data: text
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return data;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/* harmony default export */ var auto_render_splitAtDelimiters = (splitAtDelimiters);
|
|
173
|
+
;// CONCATENATED MODULE: ./contrib/auto-render/auto-render.js
|
|
174
|
+
/* eslint no-console:0 */
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
/* Note: optionsCopy is mutated by this method. If it is ever exposed in the
|
|
178
|
+
* API, we should copy it before mutating.
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
const renderMathInText = function (text, optionsCopy) {
|
|
182
|
+
const data = auto_render_splitAtDelimiters(text, optionsCopy.delimiters);
|
|
183
|
+
|
|
184
|
+
if (data.length === 1 && data[0].type === 'text') {
|
|
185
|
+
// There is no formula in the text.
|
|
186
|
+
// Let's return null which means there is no need to replace
|
|
187
|
+
// the current text node with a new one.
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const fragment = document.createDocumentFragment();
|
|
192
|
+
|
|
193
|
+
for (let i = 0; i < data.length; i++) {
|
|
194
|
+
if (data[i].type === "text") {
|
|
195
|
+
fragment.appendChild(document.createTextNode(data[i].data));
|
|
196
|
+
} else {
|
|
197
|
+
const span = document.createElement("span");
|
|
198
|
+
let math = data[i].data; // Override any display mode defined in the settings with that
|
|
199
|
+
// defined by the text itself
|
|
200
|
+
|
|
201
|
+
optionsCopy.displayMode = data[i].display;
|
|
202
|
+
|
|
203
|
+
try {
|
|
204
|
+
if (optionsCopy.preProcess) {
|
|
205
|
+
math = optionsCopy.preProcess(math);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
external_katex_default().render(math, span, optionsCopy);
|
|
209
|
+
} catch (e) {
|
|
210
|
+
if (!(e instanceof (external_katex_default()).ParseError)) {
|
|
211
|
+
throw e;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
optionsCopy.errorCallback("KaTeX auto-render: Failed to parse `" + data[i].data + "` with ", e);
|
|
215
|
+
fragment.appendChild(document.createTextNode(data[i].rawData));
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
fragment.appendChild(span);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return fragment;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const renderElem = function (elem, optionsCopy) {
|
|
227
|
+
for (let i = 0; i < elem.childNodes.length; i++) {
|
|
228
|
+
const childNode = elem.childNodes[i];
|
|
229
|
+
|
|
230
|
+
if (childNode.nodeType === 3) {
|
|
231
|
+
// Text node
|
|
232
|
+
// Concatenate all sibling text nodes.
|
|
233
|
+
// Webkit browsers split very large text nodes into smaller ones,
|
|
234
|
+
// so the delimiters may be split across different nodes.
|
|
235
|
+
let textContentConcat = childNode.textContent;
|
|
236
|
+
let sibling = childNode.nextSibling;
|
|
237
|
+
let nSiblings = 0;
|
|
238
|
+
|
|
239
|
+
while (sibling && sibling.nodeType === Node.TEXT_NODE) {
|
|
240
|
+
textContentConcat += sibling.textContent;
|
|
241
|
+
sibling = sibling.nextSibling;
|
|
242
|
+
nSiblings++;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const frag = renderMathInText(textContentConcat, optionsCopy);
|
|
246
|
+
|
|
247
|
+
if (frag) {
|
|
248
|
+
// Remove extra text nodes
|
|
249
|
+
for (let j = 0; j < nSiblings; j++) {
|
|
250
|
+
childNode.nextSibling.remove();
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
i += frag.childNodes.length - 1;
|
|
254
|
+
elem.replaceChild(frag, childNode);
|
|
255
|
+
} else {
|
|
256
|
+
// If the concatenated text does not contain math
|
|
257
|
+
// the siblings will not either
|
|
258
|
+
i += nSiblings;
|
|
259
|
+
}
|
|
260
|
+
} else if (childNode.nodeType === 1) {
|
|
261
|
+
// Element node
|
|
262
|
+
const className = ' ' + childNode.className + ' ';
|
|
263
|
+
const shouldRender = optionsCopy.ignoredTags.indexOf(childNode.nodeName.toLowerCase()) === -1 && optionsCopy.ignoredClasses.every(x => className.indexOf(' ' + x + ' ') === -1);
|
|
264
|
+
|
|
265
|
+
if (shouldRender) {
|
|
266
|
+
renderElem(childNode, optionsCopy);
|
|
267
|
+
}
|
|
268
|
+
} // Otherwise, it's something else, and ignore it.
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const renderMathInElement = function (elem, options) {
|
|
274
|
+
if (!elem) {
|
|
275
|
+
throw new Error("No element provided to render");
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const optionsCopy = {}; // Object.assign(optionsCopy, option)
|
|
279
|
+
|
|
280
|
+
for (const option in options) {
|
|
281
|
+
if (options.hasOwnProperty(option)) {
|
|
282
|
+
optionsCopy[option] = options[option];
|
|
283
|
+
}
|
|
284
|
+
} // default options
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
optionsCopy.delimiters = optionsCopy.delimiters || [{
|
|
288
|
+
left: "$$",
|
|
289
|
+
right: "$$",
|
|
290
|
+
display: true
|
|
291
|
+
}, {
|
|
292
|
+
left: "\\(",
|
|
293
|
+
right: "\\)",
|
|
294
|
+
display: false
|
|
295
|
+
}, // LaTeX uses $…$, but it ruins the display of normal `$` in text:
|
|
296
|
+
// {left: "$", right: "$", display: false},
|
|
297
|
+
// $ must come after $$
|
|
298
|
+
// Render AMS environments even if outside $$…$$ delimiters.
|
|
299
|
+
{
|
|
300
|
+
left: "\\begin{equation}",
|
|
301
|
+
right: "\\end{equation}",
|
|
302
|
+
display: true
|
|
303
|
+
}, {
|
|
304
|
+
left: "\\begin{align}",
|
|
305
|
+
right: "\\end{align}",
|
|
306
|
+
display: true
|
|
307
|
+
}, {
|
|
308
|
+
left: "\\begin{alignat}",
|
|
309
|
+
right: "\\end{alignat}",
|
|
310
|
+
display: true
|
|
311
|
+
}, {
|
|
312
|
+
left: "\\begin{gather}",
|
|
313
|
+
right: "\\end{gather}",
|
|
314
|
+
display: true
|
|
315
|
+
}, {
|
|
316
|
+
left: "\\begin{CD}",
|
|
317
|
+
right: "\\end{CD}",
|
|
318
|
+
display: true
|
|
319
|
+
}, {
|
|
320
|
+
left: "\\[",
|
|
321
|
+
right: "\\]",
|
|
322
|
+
display: true
|
|
323
|
+
}];
|
|
324
|
+
optionsCopy.ignoredTags = optionsCopy.ignoredTags || ["script", "noscript", "style", "textarea", "pre", "code", "option"];
|
|
325
|
+
optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || [];
|
|
326
|
+
optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; // Enable sharing of global macros defined via `\gdef` between different
|
|
327
|
+
// math elements within a single call to `renderMathInElement`.
|
|
328
|
+
|
|
329
|
+
optionsCopy.macros = optionsCopy.macros || {};
|
|
330
|
+
renderElem(elem, optionsCopy);
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
/* harmony default export */ var auto_render = (renderMathInElement);
|
|
334
|
+
__webpack_exports__ = __webpack_exports__["default"];
|
|
335
|
+
/******/ return __webpack_exports__;
|
|
336
|
+
/******/ })()
|
|
337
|
+
;
|
|
338
|
+
});
|
|
@@ -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(){"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={};r.d(o,{default:function(){return p}});var i=r(757),a=r.n(i);const l=function(e,t,n){let r=n,o=0;const i=e.length;for(;r<t.length;){const n=t[r];if(o<=0&&t.slice(r,r+i)===e)return r;"\\"===n?r++:"{"===n?o++:"}"===n&&o--,r++}return-1},s=/^\\begin{/;var d=function(e,t){let n;const r=[],o=new RegExp("("+t.map((e=>e.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"))).join("|")+")");for(;n=e.search(o),-1!==n;){n>0&&(r.push({type:"text",data:e.slice(0,n)}),e=e.slice(n));const o=t.findIndex((t=>e.startsWith(t.left)));if(n=l(t[o].right,e,t[o].left.length),-1===n)break;const i=e.slice(0,n+t[o].right.length),a=s.test(i)?i:e.slice(t[o].left.length,n);r.push({type:"math",data:a,rawData:i,display:t[o].display}),e=e.slice(n+t[o].right.length)}return""!==e&&r.push({type:"text",data:e}),r};const c=function(e,t){const n=d(e,t.delimiters);if(1===n.length&&"text"===n[0].type)return null;const r=document.createDocumentFragment();for(let e=0;e<n.length;e++)if("text"===n[e].type)r.appendChild(document.createTextNode(n[e].data));else{const o=document.createElement("span");let i=n[e].data;t.displayMode=n[e].display;try{t.preProcess&&(i=t.preProcess(i)),a().render(i,o,t)}catch(o){if(!(o instanceof a().ParseError))throw o;t.errorCallback("KaTeX auto-render: Failed to parse `"+n[e].data+"` with ",o),r.appendChild(document.createTextNode(n[e].rawData));continue}r.appendChild(o)}return r},f=function(e,t){for(let n=0;n<e.childNodes.length;n++){const r=e.childNodes[n];if(3===r.nodeType){let o=r.textContent,i=r.nextSibling,a=0;for(;i&&i.nodeType===Node.TEXT_NODE;)o+=i.textContent,i=i.nextSibling,a++;const l=c(o,t);if(l){for(let e=0;e<a;e++)r.nextSibling.remove();n+=l.childNodes.length-1,e.replaceChild(l,r)}else n+=a}else if(1===r.nodeType){const e=" "+r.className+" ";-1===t.ignoredTags.indexOf(r.nodeName.toLowerCase())&&t.ignoredClasses.every((t=>-1===e.indexOf(" "+t+" ")))&&f(r,t)}}};var p=function(e,t){if(!e)throw new Error("No element provided to render");const n={};for(const e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);n.delimiters=n.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}],n.ignoredTags=n.ignoredTags||["script","noscript","style","textarea","pre","code","option"],n.ignoredClasses=n.ignoredClasses||[],n.errorCallback=n.errorCallback||console.error,n.macros=n.macros||{},f(e,n)};return o=o.default}()}));
|