This is a mirror of https://github.com/Khan/KaTeX and for own development.

ylemkimon ce3840d4ce Include only necessary fonts for target environment specified by Browserslist (#1674) il y a 6 ans
.circleci 112582daa5 Replace Khan/KaTeX with KaTeX/KaTeX (#1781) il y a 6 ans
contrib 64745b5c8a Add mhchem extension (#1436) il y a 6 ans
dockers 11490b5e0b Allow screenshotter to be run on IE, Edge, Safari and remote, e.g., BrowserStack (#1661) il y a 6 ans
docs ce3840d4ce Include only necessary fonts for target environment specified by Browserslist (#1674) il y a 6 ans
src 64745b5c8a Add mhchem extension (#1436) il y a 6 ans
static fdb155aa97 Build ECMAScript modules (#1479) il y a 6 ans
submodules 74fb394bb5 Update fonts to remove \neq and \notin glyphs (#1499) il y a 6 ans
test 3dfd17d9b4 Add catcode to Lexer, move comment parsing back to Lexer (#1789) il y a 6 ans
website ec6a2b4f36 Remove Supported Functions onPageNav style (#1767) il y a 6 ans
.browserslistrc cd8e6e0de6 Add browserslist (#1662) il y a 6 ans
.codecov.yml 789aabe7a1 add .codecov.yml and disable patch coverage (#1164) il y a 6 ans
.eslintignore 64745b5c8a Add mhchem extension (#1436) il y a 6 ans
.eslintrc 4178639ea5 Upgrade to Babel 7 (#1595) il y a 6 ans
.flowconfig 237986a7ca Change build directory to `dist` and cleanup NPM scripts (#1500) il y a 6 ans
.gitattributes a3f0653e5c Set up a diff attribute and textconv instructions for font files il y a 7 ans
.gitignore b99de9ae68 Use local built CSS and fonts for master documentation (#1584) il y a 6 ans
.gitmodules 96ad6e0f4f Add unicode-fonts as submodule (#1182) il y a 6 ans
.stylelintrc b99de9ae68 Use local built CSS and fonts for master documentation (#1584) il y a 6 ans
CHANGELOG.md 112582daa5 Replace Khan/KaTeX with KaTeX/KaTeX (#1781) il y a 6 ans
CODE_OF_CONDUCT.md ace67541a0 Create CODE_OF_CONDUCT.md (#553) il y a 8 ans
CONTRIBUTING.md 112582daa5 Replace Khan/KaTeX with KaTeX/KaTeX (#1781) il y a 6 ans
LICENSE 9a9842886e Remove Object.assign() in auto-render which requires expensive polyfill, update LICENSE (#1591) il y a 6 ans
README.md 112582daa5 Replace Khan/KaTeX with KaTeX/KaTeX (#1781) il y a 6 ans
babel.config.js ce3840d4ce Include only necessary fonts for target environment specified by Browserslist (#1674) il y a 6 ans
bower.json 112582daa5 Replace Khan/KaTeX with KaTeX/KaTeX (#1781) il y a 6 ans
cli.js 3514d48856 cli's default maxSize should be Infinity, not 0 (#1739) il y a 6 ans
greenkeeper.json 6f0a76c3a5 Enable Greenkeeper on website/package.json (#1687) il y a 6 ans
katex.js 96310815c5 Remove indexOf & textContent polyfill for IE 8 (#1645) il y a 6 ans
katex.webpack.js f628ca142b Generate ECMAScript module for contrib (#1624) il y a 6 ans
package.json ce3840d4ce Include only necessary fonts for target environment specified by Browserslist (#1674) il y a 6 ans
release.sh 112582daa5 Replace Khan/KaTeX with KaTeX/KaTeX (#1781) il y a 6 ans
rollup.config.js f628ca142b Generate ECMAScript module for contrib (#1624) il y a 6 ans
update-sri.js 112582daa5 Replace Khan/KaTeX with KaTeX/KaTeX (#1781) il y a 6 ans
webpack.analyze.js 0fb71c8bf8 Lint webpack.*.js (#1467) il y a 6 ans
webpack.common.js ce3840d4ce Include only necessary fonts for target environment specified by Browserslist (#1674) il y a 6 ans
webpack.config.js e1614995e3 enforce consistent object brace spacing (#1376) il y a 6 ans
webpack.dev.js e1614995e3 enforce consistent object brace spacing (#1376) il y a 6 ans
yarn.lock ce3840d4ce Include only necessary fonts for target environment specified by Browserslist (#1674) il y a 6 ans

README.md

KaTeX

npm CircleCI codecov Greenkeeper badge jsDelivr

KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web.

  • 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.
  • 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.

KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9–11.

KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the list of supported functions.

Try out KaTeX on the demo page!

Getting started

Starter template

<!DOCTYPE html>
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
<html>
  <head>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">

    <!-- The loading of KaTeX is deferred to speed up page rendering -->
    <script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js" integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx" crossorigin="anonymous"></script>

    <!-- To automatically render math in text elements, include the auto-render extension: -->
    <script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js" integrity="sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe" crossorigin="anonymous"
        onload="renderMathInElement(document.body);"></script>
  </head>
  ...
</html>

You can also download KaTeX and host it yourself.

For details on how to configure auto-render extension, refer to the documentation.

API

Call katex.render to render a TeX expression directly into a DOM element. For example:

katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, {
    throwOnError: false
});

Call katex.renderToString to generate an HTML string of the rendered math, e.g., for server-side rendering. For example:

var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
    throwOnError: false
});
// '<span class="katex">...</span>'

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.

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, options documentation, and handling errors documentation.

Demo and Documentation

Learn more about using KaTeX on the website!

Contributing

See CONTRIBUTING.md

License

KaTeX is licensed under the MIT License.