mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-06 03:38:39 +00:00
Improve README.md (#1515)
* Fix KaTeX logo * Add npm badge * Change CircleCI badge * Remove redundant links * Remove unnecessary details * Add a link to auto-render extension * Add a link to the list of supported commands * Add a section about auto-render extension * Update README.md
This commit is contained in:
35
README.md
35
README.md
@@ -1,6 +1,7 @@
|
||||
# [<img src="https://khan.github.io/KaTeX/katex-logo.svg" width="130" alt="KaTeX">](https://khan.github.io/KaTeX/)
|
||||
# [<img src="https://cdn.rawgit.com/Khan/KaTeX/84189cd3adae24d92e766d14eb80d6e54f3c7dca/katex-logo.svg" width="130" alt="KaTeX">](https://khan.github.io/KaTeX/)
|
||||
[](https://www.npmjs.com/package/katex)
|
||||
[](https://travis-ci.org/Khan/KaTeX)
|
||||
[](https://circleci.com/gh/Khan/KaTeX)
|
||||
[](https://circleci.com/gh/Khan/KaTeX)
|
||||
[](https://codecov.io/gh/Khan/KaTeX)
|
||||
[](https://gitter.im/Khan/KaTeX?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://greenkeeper.io/)
|
||||

|
||||
@@ -12,7 +13,9 @@ KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the we
|
||||
* **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.
|
||||
|
||||
KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9 - IE 11. More information can be found on the [list of supported commands](https://khan.github.io/KaTeX/function-support.html) and on the [wiki](https://github.com/khan/katex/wiki).
|
||||
KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9 - IE 11.
|
||||
|
||||
KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the [list of supported functions](https://khan.github.io/KaTeX/docs/supported.html).
|
||||
|
||||
## Getting started
|
||||
|
||||
@@ -31,14 +34,28 @@ Call `katex.render` with a TeX expression and a DOM element to render into:
|
||||
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element);
|
||||
```
|
||||
|
||||
To avoid escaping the backslash (double backslash), you can use
|
||||
[`String.raw`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw)
|
||||
(but beware that `${`, `\u` and `\x` may still need escaping):
|
||||
```js
|
||||
katex.render(String.raw`c = \pm\sqrt{a^2 + b^2}`, element);
|
||||
If KaTeX can't parse the expression, it throws a `katex.ParseError` error.
|
||||
|
||||
#### Rendering expressions in text elements
|
||||
|
||||
To automatically render math in text elements, include the [auto-render script](https://khan.github.io/KaTeX/docs/autorender.html) `contrib/auto-render.min.js`, or via CDN:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/contrib/auto-render.min.js" integrity="sha384-aGfk5kvhIq5x1x5YdvCp4upKZYnA8ckafviDpmWEKp4afOZEqOli7gqSnh8I6enH" crossorigin="anonymous"></script>
|
||||
````
|
||||
|
||||
Then, call the `renderMathInElement` function with a DOM element containing expressions in a script tag before the closing body tag:
|
||||
|
||||
```html
|
||||
<body>
|
||||
...
|
||||
<script>
|
||||
renderMathInElement(document.body);
|
||||
</script>
|
||||
</body>
|
||||
```
|
||||
|
||||
If KaTeX can't parse the expression, it throws a `katex.ParseError` error.
|
||||
See [Auto-render Extension](https://khan.github.io/KaTeX/docs/autorender.html) for more details.
|
||||
|
||||
#### Server side rendering or rendering to a string
|
||||
|
||||
|
Reference in New Issue
Block a user