mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-05-08 10:24:08 +00:00
Upgrade to KaTeX v0.2.0
This commit is contained in:
parent
3165eb1429
commit
ae001a19e5
@ -38,11 +38,17 @@ $$\displaystyle \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}}
|
|||||||
|
|
||||||
!! Example 3
|
!! Example 3
|
||||||
|
|
||||||
|
Use a wrapper element with the class `katex-display` to render math in display mode, centred on a single line in display style.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
<div class="katex-display">
|
||||||
$$\displaystyle \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
|
$$\displaystyle \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
|
||||||
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<div class="katex-display">
|
||||||
$$\displaystyle \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
|
$$\displaystyle \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
|
||||||
|
</div>
|
||||||
|
|
||||||
!! Example 4
|
!! Example 4
|
||||||
|
|
||||||
|
@ -11,20 +11,24 @@ KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, and
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Download the built files from [the releases page](https://github.com/khan/katex/releases). Include the `katex.min.js` and `katex.min.css` files on your page:
|
You can [download KaTeX](https://github.com/khan/katex/releases) and host it on your server or include the `katex.min.js` and `katex.min.css` files on your page directly from a CDN:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="/path/to/katex.min.css">
|
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.1/katex.min.css">
|
||||||
<script src="/path/to/katex.min.js"></script>
|
<script src="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.1/katex.min.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### In-browser rendering
|
||||||
|
|
||||||
Call `katex.render` with a TeX expression and a DOM element to render into:
|
Call `katex.render` with a TeX expression and a DOM element to render into:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element);
|
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element);
|
||||||
```
|
```
|
||||||
|
|
||||||
To generate HTML on the server, you can use `katex.renderToString`:
|
#### Server side rendering or rendering to a string
|
||||||
|
|
||||||
|
To generate HTML on the server or to generate an HTML string of the rendered math, you can use `katex.renderToString`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}");
|
var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}");
|
||||||
@ -33,12 +37,16 @@ var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}");
|
|||||||
|
|
||||||
Make sure to include the CSS and font files, but there is no need to include the JavaScript.
|
Make sure to include the CSS and font files, but there is no need to include the JavaScript.
|
||||||
|
|
||||||
These APIs default to inline math typesetting; for display math you can prepend `\displaystyle` ([#66](https://github.com/Khan/KaTeX/issues/66)):
|
#### Rendering options
|
||||||
|
|
||||||
|
You can provide an object of options as the last argument to `katex.render` and `katex.renderToString`. Available options are:
|
||||||
|
|
||||||
|
- `displayMode`: `boolean`. If `true` the math will be rendered in display mode, which will put the math in display style (so `\int` and `\sum` are large, for example), and will center the math on the page on its own line. If `false` the math will be rendered in inline mode. (default: `false`)
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
katex.render("\\displaystyle " + formula, element);
|
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, { displayMode: true });
|
||||||
// OR
|
|
||||||
var html = katex.renderToString("\\displaystyle " + formula);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
2
plugins/tiddlywiki/katex/files/katex.min.css
vendored
2
plugins/tiddlywiki/katex/files/katex.min.css
vendored
File diff suppressed because one or more lines are too long
7
plugins/tiddlywiki/katex/files/katex.min.js
vendored
7
plugins/tiddlywiki/katex/files/katex.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user