www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

README.md (4465B)


      1 # [<img src="https://katex.org/img/katex-logo-black.svg" width="130" alt="KaTeX">](https://katex.org/)
      2 [![npm](https://img.shields.io/npm/v/katex.svg)](https://www.npmjs.com/package/katex)
      3 [![CI](https://github.com/KaTeX/KaTeX/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/KaTeX/KaTeX/actions?query=workflow%3ACI)
      4 [![codecov](https://codecov.io/gh/KaTeX/KaTeX/branch/master/graph/badge.svg)](https://codecov.io/gh/KaTeX/KaTeX)
      5 [![Discussions](https://img.shields.io/badge/Discussions-join-brightgreen)](https://github.com/KaTeX/KaTeX/discussions)
      6 [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/katex/badge?style=rounded)](https://www.jsdelivr.com/package/npm/katex)
      7 ![katex.min.js size](https://img.badgesize.io/https://unpkg.com/katex/dist/katex.min.js?compression=gzip)
      8 [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/KaTeX/KaTeX)
      9 
     10 KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web.
     11 
     12  * **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).
     13  * **Print quality:** KaTeX's layout is based on Donald Knuth's TeX, the gold standard for math typesetting.
     14  * **Self contained:** KaTeX has no dependencies and can easily be bundled with your website resources.
     15  * **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.
     16 
     17 KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 11.
     18 
     19 KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the [list of supported functions](https://katex.org/docs/supported.html).
     20 
     21 Try out KaTeX [on the demo page](https://katex.org/#demo)!
     22 
     23 ## Getting started
     24 
     25 ### Starter template
     26 
     27 ```html
     28 <!DOCTYPE html>
     29 <!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
     30 <html>
     31   <head>
     32     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.css" integrity="sha384-t5CR+zwDAROtph0PXGte6ia8heboACF9R5l/DiY+WZ3P2lxNgvJkQk5n7GPvLMYw" crossorigin="anonymous">
     33 
     34     <!-- The loading of KaTeX is deferred to speed up page rendering -->
     35     <script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/katex.min.js" integrity="sha384-FaFLTlohFghEIZkw6VGwmf9ISTubWAVYW8tG8+w2LAIftJEULZABrF9PPFv+tVkH" crossorigin="anonymous"></script>
     36 
     37     <!-- To automatically render math in text elements, include the auto-render extension: -->
     38     <script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.0/dist/contrib/auto-render.min.js" integrity="sha384-bHBqxz8fokvgoJ/sc17HODNxa42TlaEhB+w8ZJXTc2nZf1VgEaFZeZvT4Mznfz0v" crossorigin="anonymous"
     39         onload="renderMathInElement(document.body);"></script>
     40   </head>
     41   ...
     42 </html>
     43 ```
     44 
     45 You can also [download KaTeX](https://github.com/KaTeX/KaTeX/releases) and host it yourself.
     46 
     47 For details on how to configure auto-render extension, refer to [the documentation](https://katex.org/docs/autorender.html).
     48 
     49 ### API
     50 
     51 Call `katex.render` to render a TeX expression directly into a DOM element.
     52 For example:
     53 
     54 ```js
     55 katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, {
     56     throwOnError: false
     57 });
     58 ```
     59 
     60 Call `katex.renderToString` to generate an HTML string of the rendered math,
     61 e.g., for server-side rendering.  For example:
     62 
     63 ```js
     64 var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
     65     throwOnError: false
     66 });
     67 // '<span class="katex">...</span>'
     68 ```
     69 
     70 Make sure to include the CSS and font files in both cases.
     71 If you are doing all rendering on the server, there is no need to include the
     72 JavaScript on the client.
     73 
     74 The examples above use the `throwOnError: false` option, which renders invalid
     75 inputs as the TeX source code in red (by default), with the error message as
     76 hover text.  For other available options, see the
     77 [API documentation](https://katex.org/docs/api.html),
     78 [options documentation](https://katex.org/docs/options.html), and
     79 [handling errors documentation](https://katex.org/docs/error.html).
     80 
     81 ## Demo and Documentation
     82 
     83 Learn more about using KaTeX [on the website](https://katex.org)!
     84 
     85 ## Contributing
     86 
     87 See [CONTRIBUTING.md](CONTRIBUTING.md)
     88 
     89 ## License
     90 
     91 KaTeX is licensed under the [MIT License](http://opensource.org/licenses/MIT).