1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-09 19:39:57 +00:00
TiddlyWiki5/plugins/tiddlywiki/katex/files/README.md

120 lines
7.0 KiB
Markdown
Raw Normal View History

2021-01-31 15:11:12 +00:00
# [<img src="https://katex.org/img/katex-logo-black.svg" width="130" alt="KaTeX">](https://katex.org/)
[![npm](https://img.shields.io/npm/v/katex.svg)](https://www.npmjs.com/package/katex)
2021-09-12 09:54:54 +00:00
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![CI](https://github.com/KaTeX/KaTeX/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/KaTeX/KaTeX/actions?query=workflow%3ACI)
2021-01-31 15:11:12 +00:00
[![codecov](https://codecov.io/gh/KaTeX/KaTeX/branch/master/graph/badge.svg)](https://codecov.io/gh/KaTeX/KaTeX)
2021-09-12 09:54:54 +00:00
[![Discussions](https://img.shields.io/badge/Discussions-join-brightgreen)](https://github.com/KaTeX/KaTeX/discussions)
2021-01-31 15:11:12 +00:00
[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/katex/badge?style=rounded)](https://www.jsdelivr.com/package/npm/katex)
2021-09-12 09:54:54 +00:00
![katex.min.js size](https://img.badgesize.io/https://unpkg.com/katex/dist/katex.min.js?compression=gzip)
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/KaTeX/KaTeX)
[![Financial Contributors on Open Collective](https://opencollective.com/katex/all/badge.svg?label=financial+contributors)](https://opencollective.com/katex)
2016-04-22 14:50:23 +00:00
KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web.
2018-01-11 21:42:56 +00:00
* **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](http://www.intmath.com/cg5/katex-mathjax-comparison.php).
2021-01-31 15:11:12 +00:00
* **Print quality:** KaTeX's layout is based on Donald Knuth's TeX, the gold standard for math typesetting.
* **Self contained:** KaTeX has no dependencies and can easily be bundled with your website resources.
* **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.
2021-01-31 15:11:12 +00:00
KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 11.
2021-01-31 15:11:12 +00:00
KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the [list of supported functions](https://katex.org/docs/supported.html).
2021-01-31 15:11:12 +00:00
Try out KaTeX [on the demo page](https://katex.org/#demo)!
2021-01-31 15:11:12 +00:00
## Getting started
2015-03-14 08:34:16 +00:00
2021-01-31 15:11:12 +00:00
### Starter template
2021-01-31 15:11:12 +00:00
```html
<!DOCTYPE html>
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
<html>
<head>
2021-09-12 09:54:54 +00:00
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/katex.min.css" integrity="sha384-zTROYFVGOfTw7JV7KUu8udsvW2fx4lWOsCEDqhBreBwlHI4ioVRtmIvEThzJHGET" crossorigin="anonymous">
2021-01-31 15:11:12 +00:00
<!-- The loading of KaTeX is deferred to speed up page rendering -->
2021-09-12 09:54:54 +00:00
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/katex.min.js" integrity="sha384-GxNFqL3r9uRJQhR+47eDxuPoNE7yLftQM8LcxzgS4HT73tp970WS/wV5p8UzCOmb" crossorigin="anonymous"></script>
2021-01-31 15:11:12 +00:00
<!-- To automatically render math in text elements, include the auto-render extension: -->
2021-09-12 09:54:54 +00:00
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/contrib/auto-render.min.js" integrity="sha384-vZTG03m+2yp6N6BNi5iM4rW4oIwk5DfcNdFfxkk9ZWpDriOkXX8voJBFrAO7MpVl" crossorigin="anonymous"
2021-01-31 15:11:12 +00:00
onload="renderMathInElement(document.body);"></script>
</head>
...
</html>
```
2021-01-31 15:11:12 +00:00
You can also [download KaTeX](https://github.com/KaTeX/KaTeX/releases) and host it yourself.
2015-03-14 08:34:16 +00:00
2021-01-31 15:11:12 +00:00
For details on how to configure auto-render extension, refer to [the documentation](https://katex.org/docs/autorender.html).
2015-03-14 08:34:16 +00:00
2021-01-31 15:11:12 +00:00
### API
2015-03-14 08:34:16 +00:00
2021-01-31 15:11:12 +00:00
Call `katex.render` to render a TeX expression directly into a DOM element.
2015-03-14 08:34:16 +00:00
For example:
2014-10-17 19:10:38 +00:00
```js
2021-01-31 15:11:12 +00:00
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, {
throwOnError: false
2018-01-11 21:42:56 +00:00
});
2014-10-17 19:10:38 +00:00
```
2021-01-31 15:11:12 +00:00
Call `katex.renderToString` to generate an HTML string of the rendered math,
e.g., for server-side rendering. For example:
2015-06-29 20:07:26 +00:00
2021-01-31 15:11:12 +00:00
```js
var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
throwOnError: false
});
// '<span class="katex">...</span>'
```
2015-06-29 20:07:26 +00:00
2021-01-31 15:11:12 +00:00
Make sure to include the CSS and font files in both cases.
If you are doing all rendering on the server, there is no need to include the
JavaScript on the client.
2018-01-11 21:42:56 +00:00
2021-01-31 15:11:12 +00:00
The examples above use the `throwOnError: false` option, which renders invalid
inputs as the TeX source code in red (by default), with the error message as
hover text. For other available options, see the
[API documentation](https://katex.org/docs/api.html),
[options documentation](https://katex.org/docs/options.html), and
[handling errors documentation](https://katex.org/docs/error.html).
2018-01-11 21:42:56 +00:00
2021-01-31 15:11:12 +00:00
## Demo and Documentation
2018-01-11 21:42:56 +00:00
2021-01-31 15:11:12 +00:00
Learn more about using KaTeX [on the website](https://katex.org)!
2018-01-11 21:42:56 +00:00
2021-09-12 09:54:54 +00:00
## Contributors
2021-09-12 09:54:54 +00:00
### Code Contributors
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).
<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>
### Financial Contributors
Become a financial contributor and help us sustain our community.
#### Individuals
<a href="https://opencollective.com/katex"><img src="https://opencollective.com/katex/individuals.svg?width=890" alt="Contribute on Open Collective"></a>
#### Organizations
Support this project with your organization. Your logo will show up here with a link to your website.
<a href="https://opencollective.com/katex/organization/0/website"><img src="https://opencollective.com/katex/organization/0/avatar.svg" alt="Organization 1"></a>
<a href="https://opencollective.com/katex/organization/1/website"><img src="https://opencollective.com/katex/organization/1/avatar.svg" alt="Organization 2"></a>
<a href="https://opencollective.com/katex/organization/2/website"><img src="https://opencollective.com/katex/organization/2/avatar.svg" alt="Organization 3"></a>
<a href="https://opencollective.com/katex/organization/3/website"><img src="https://opencollective.com/katex/organization/3/avatar.svg" alt="Organization 4"></a>
<a href="https://opencollective.com/katex/organization/4/website"><img src="https://opencollective.com/katex/organization/4/avatar.svg" alt="Organization 5"></a>
<a href="https://opencollective.com/katex/organization/5/website"><img src="https://opencollective.com/katex/organization/5/avatar.svg" alt="Organization 6"></a>
<a href="https://opencollective.com/katex/organization/6/website"><img src="https://opencollective.com/katex/organization/6/avatar.svg" alt="Organization 7"></a>
<a href="https://opencollective.com/katex/organization/7/website"><img src="https://opencollective.com/katex/organization/7/avatar.svg" alt="Organization 8"></a>
<a href="https://opencollective.com/katex/organization/8/website"><img src="https://opencollective.com/katex/organization/8/avatar.svg" alt="Organization 9"></a>
<a href="https://opencollective.com/katex/organization/9/website"><img src="https://opencollective.com/katex/organization/9/avatar.svg" alt="Organization 10"></a>
## License
2014-10-17 19:10:38 +00:00
KaTeX is licensed under the [MIT License](http://opensource.org/licenses/MIT).