katex 0.10.0-rc → 0.10.2
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.
- package/CHANGELOG.md +214 -126
- package/README.md +18 -17
- package/cli.js +5 -1
- package/contrib/auto-render/README.md +1 -1
- package/contrib/auto-render/auto-render.js +4 -1
- package/contrib/auto-render/test/auto-render-spec.js +17 -0
- package/contrib/copy-tex/README.md +8 -2
- package/contrib/copy-tex/copy-tex.js +0 -1
- package/contrib/copy-tex/copy-tex.webpack.js +6 -0
- package/contrib/mathtex-script-type/README.md +10 -6
- package/contrib/mhchem/README.md +19 -0
- package/contrib/mhchem/mhchem.js +1695 -0
- package/contrib/mhchem/mhchem.patch +235 -0
- package/dist/README.md +18 -17
- package/dist/contrib/auto-render.js +179 -161
- package/dist/contrib/auto-render.min.js +1 -1
- package/dist/contrib/auto-render.mjs +215 -0
- package/dist/contrib/copy-tex.js +84 -62
- package/dist/contrib/copy-tex.min.css +1 -1
- package/dist/contrib/copy-tex.min.js +1 -1
- package/dist/contrib/copy-tex.mjs +85 -0
- package/dist/contrib/mathtex-script-type.js +17 -14
- package/dist/contrib/mathtex-script-type.mjs +24 -0
- package/dist/contrib/mhchem.js +3241 -0
- package/dist/contrib/mhchem.min.js +1 -0
- package/dist/contrib/mhchem.mjs +3109 -0
- package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/katex.css +24 -9
- package/dist/katex.js +13295 -12413
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +13388 -11826
- package/katex.js +1 -2
- package/package.json +60 -48
- package/src/Lexer.js +25 -25
- package/src/MacroExpander.js +0 -1
- package/src/Options.js +11 -75
- package/src/Parser.js +231 -313
- package/src/Settings.js +6 -0
- package/src/buildCommon.js +140 -103
- package/src/buildHTML.js +125 -121
- package/src/buildMathML.js +14 -4
- package/src/buildTree.js +16 -10
- package/src/delimiter.js +4 -3
- package/src/domTree.js +91 -44
- package/src/environments/array.js +120 -7
- package/src/fontMetrics.js +3 -2
- package/src/functions/arrow.js +21 -7
- package/src/functions/color.js +2 -37
- package/src/functions/delimsizing.js +18 -11
- package/src/functions/enclose.js +19 -4
- package/src/functions/environment.js +35 -4
- package/src/functions/font.js +1 -2
- package/src/functions/genfrac.js +35 -20
- package/src/functions/href.js +5 -3
- package/src/functions/includegraphics.js +146 -0
- package/src/functions/mclass.js +1 -0
- package/src/functions/op.js +21 -32
- package/src/functions/operatorname.js +1 -2
- package/src/functions/ordgroup.js +4 -0
- package/src/functions/phantom.js +7 -3
- package/src/functions/rule.js +20 -9
- package/src/functions/sizing.js +2 -4
- package/src/functions/smash.js +5 -2
- package/src/functions/sqrt.js +1 -4
- package/src/functions/styling.js +0 -1
- package/src/functions/supsub.js +6 -2
- package/src/functions/symbolsOp.js +4 -0
- package/src/functions/symbolsSpacing.js +29 -6
- package/src/functions/tag.js +20 -4
- package/src/functions/text.js +6 -4
- package/src/functions/verb.js +16 -4
- package/src/functions.js +2 -0
- package/src/katex.less +35 -12
- package/src/macros.js +161 -36
- package/src/mathMLTree.js +17 -19
- package/src/parseNode.js +27 -1
- package/src/stretchy.js +3 -1
- package/src/svgGeometry.js +1 -1
- package/src/symbols.js +39 -17
- package/src/tree.js +0 -4
- package/src/types.js +4 -3
- package/src/unicodeMake.js +1 -1
- package/src/utils.js +1 -62
- package/src/wide-character.js +2 -2
|
@@ -26,11 +26,14 @@ const renderMathInText = function(text, optionsCopy) {
|
|
|
26
26
|
fragment.appendChild(document.createTextNode(data[i].data));
|
|
27
27
|
} else {
|
|
28
28
|
const span = document.createElement("span");
|
|
29
|
-
|
|
29
|
+
let math = data[i].data;
|
|
30
30
|
// Override any display mode defined in the settings with that
|
|
31
31
|
// defined by the text itself
|
|
32
32
|
optionsCopy.displayMode = data[i].display;
|
|
33
33
|
try {
|
|
34
|
+
if (optionsCopy.preProcess) {
|
|
35
|
+
math = optionsCopy.preProcess(math);
|
|
36
|
+
}
|
|
34
37
|
katex.render(math, span, optionsCopy);
|
|
35
38
|
} catch (e) {
|
|
36
39
|
if (!(e instanceof katex.ParseError)) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
/* global describe: false */
|
|
5
5
|
|
|
6
6
|
import splitAtDelimiters from "../splitAtDelimiters";
|
|
7
|
+
import renderMathInElement from "../auto-render";
|
|
7
8
|
|
|
8
9
|
beforeEach(function() {
|
|
9
10
|
expect.extend({
|
|
@@ -234,3 +235,19 @@ describe("A delimiter splitter", function() {
|
|
|
234
235
|
]);
|
|
235
236
|
});
|
|
236
237
|
});
|
|
238
|
+
|
|
239
|
+
describe("Pre-process callback", function() {
|
|
240
|
+
it("replace `-squared` with `^2 `", function() {
|
|
241
|
+
const el1 = document.createElement('div');
|
|
242
|
+
el1.textContent = 'Circle equation: $x-squared + y-squared = r-squared$.';
|
|
243
|
+
const el2 = document.createElement('div');
|
|
244
|
+
el2.textContent = 'Circle equation: $x^2 + y^2 = r^2$.';
|
|
245
|
+
const delimiters = [{left: "$", right: "$", display: false}];
|
|
246
|
+
renderMathInElement(el1, {
|
|
247
|
+
delimiters,
|
|
248
|
+
preProcess: math => math.replace(/-squared/g, '^2'),
|
|
249
|
+
});
|
|
250
|
+
renderMathInElement(el2, {delimiters});
|
|
251
|
+
expect(el1.innerHTML).toEqual(el2.innerHTML);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
@@ -21,8 +21,8 @@ provided by this extension). Without this CSS, partially selected equations
|
|
|
21
21
|
will just get the usual HTML copy/paste behavior.
|
|
22
22
|
|
|
23
23
|
```html
|
|
24
|
-
<link href="https://cdn.jsdelivr.net/npm/katex@0.10.
|
|
25
|
-
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.
|
|
24
|
+
<link href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/copy-tex.css" rel="stylesheet" type="text/css">
|
|
25
|
+
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/copy-tex.min.js" integrity="sha384-XhWAe6BtVcvEdS3FFKT7Mcft4HJjPqMQvi5V4YhzH9Qxw497jC13TupOEvjoIPy7" crossorigin="anonymous"></script>
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
See [index.html](index.html) for an example.
|
|
@@ -35,6 +35,12 @@ If you want to build your own custom copy handler based on this one,
|
|
|
35
35
|
copy the `copy-tex.js` into your codebase and replace the `require`
|
|
36
36
|
statement with `require('katex/contrib/copy-tex/katex2tex.js')`.
|
|
37
37
|
|
|
38
|
+
<!-- TODO: uncomment when releasing a new version
|
|
39
|
+
ECMAScript module is also available:
|
|
40
|
+
```html
|
|
41
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/copy-tex.mjs" integrity="sha384-kS7UtO844uqLwxPmaRwzg1nGbKiHsIteWh+DP2cvT2FtigL0v6w1yPXYKEDzct0C" crossorigin="anonymous"></script>
|
|
42
|
+
```` -->
|
|
43
|
+
|
|
38
44
|
### Known Issues
|
|
39
45
|
|
|
40
46
|
This extension has been tested on Chrome, Firefox, Edge, and Safari.
|
|
@@ -12,10 +12,8 @@ Load the extension by adding the following line to your HTML file.
|
|
|
12
12
|
This extension should be loaded *after* all `script type=math/tex` blocks that you want to render.
|
|
13
13
|
|
|
14
14
|
```html
|
|
15
|
-
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.
|
|
15
|
+
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/mathtex-script-type.min.js" integrity="sha384-LJ2FmexL77rmGm6SIpxq7y+XA6bkLzGZEgCywzKOZG/ws4va9fUVu2neMjvc3zdv"></script>
|
|
16
16
|
```
|
|
17
|
-
Note that if the URL above contains `...` in-place of a version string, then this script has not yet
|
|
18
|
-
been deployed to the CDN.
|
|
19
17
|
You can download the script and use it locally, or from a local KaTeX installation instead.
|
|
20
18
|
|
|
21
19
|
For example, in the following simple page, we first load KaTeX as usual.
|
|
@@ -25,12 +23,18 @@ After we're done writing `math/tex` scripts, we load this extension.
|
|
|
25
23
|
```html
|
|
26
24
|
<html>
|
|
27
25
|
<head>
|
|
28
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.
|
|
29
|
-
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.
|
|
26
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
|
|
27
|
+
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script>
|
|
30
28
|
</head>
|
|
31
29
|
<body>
|
|
32
30
|
<script type="math/tex">x+\sqrt{1-x^2}</script>
|
|
33
|
-
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.
|
|
31
|
+
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/mathtex-script-type.min.js" integrity="sha384-LJ2FmexL77rmGm6SIpxq7y+XA6bkLzGZEgCywzKOZG/ws4va9fUVu2neMjvc3zdv"></script>
|
|
34
32
|
</body>
|
|
35
33
|
</html>
|
|
36
34
|
```
|
|
35
|
+
|
|
36
|
+
<!-- TODO: uncomment when releasing a new version
|
|
37
|
+
ECMAScript module is also available:
|
|
38
|
+
```html
|
|
39
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/mathtex-script-type.mjs" integrity="sha384-qc7HqE4GHbr2H9R+C8mTSdJmkkZ9E1bkIRyRrxMsoj3dcbGjILzoXJGcBGGns1bk" crossorigin="anonymous"></script>
|
|
40
|
+
```` -->
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# mhchem extension
|
|
2
|
+
|
|
3
|
+
This extension adds to KaTeX the `\ce` and `\pu` functions from the [mhchem](https://mhchem.github.io/MathJax-mhchem/) package.
|
|
4
|
+
|
|
5
|
+
### Usage
|
|
6
|
+
|
|
7
|
+
This extension isn't part of core KaTeX, so the script should be separately included. Write the following line into the HTML page's `<head>`. Place it *after* the line that calls `katex.js`.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/mhchem.min.js" integrity="sha384-oa0lfxCGjaU1LdYckhq8LZcP+JTf8cyJXe69O6VE6UrShzWveT6KiCElJrck/stm"></script>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Syntax
|
|
14
|
+
|
|
15
|
+
See the [mhchem Manual](https://mhchem.github.io/MathJax-mhchem/) for a full explanation of the input syntax, with working examples. The manual also includes a demonstration box.
|
|
16
|
+
|
|
17
|
+
### Browser Support
|
|
18
|
+
|
|
19
|
+
This extension has been tested on Chrome, Firefox, Opera, and Edge.
|