mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 11:18:39 +00:00
* website/docs: initial commit * Change secondaryColor * Fix index.css not being copied and included on global stylesheet * Fix stylesheet link [skip ci] * Change documentation link to API(Usage) [skip ci] * Add `Libraries` in usage [skip ci] * Remove documentation from `README.md` and add link to the site [skip ci] * Use KaTeX in the parent directory to build Markdown [skip ci] * Revise function support page. Avoid error msgs. * General edit to function support page
909 B
909 B
id, title
id | title |
---|---|
api | API |
In-browser rendering
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
(but beware that ${
, \u
and \x
may still need escaping):
katex.render(String.raw`c = \pm\sqrt{a^2 + b^2}`, element);
If KaTeX can't parse the expression, it throws a ParseError
. See handling errors
for configuring how to handle errors.
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
:
var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}");
// '<span class="katex">...</span>'