0.3.2 • Published 8 years ago
katex-latex v0.3.2
katex-latex
Showdown extension to display math using KaTeX and LaTeX or AsciiMath
Special characters do not need escaping. katex-latex is no longer dependent on jQuery!
Works well alongside bootmark
Config
You can customize what gets passed to the katex renderer by using the katex.config
object.
These are the defaults:
{
displayMode: true,
throwOnError: false, //allows katex to fail silently
errorColor: '#ff0000',
[
{ left: "$$", right: "$$", display: true }, // katex default
{ left: "\\[", right: "\\]", display: true }, // katex default
{ left: "\\(", right: "\\)", display: false }, // katex default
{ left: '~', right: '~', display: false, asciimath: true },
{ left: '&&', right: '&&', display: true, asciimath: true },
],
}
Examples:
<script>
// disable displayMode
katex.config.displayMode = false;
// maybe you want katex to throwOnError
katex.config.throwOnError = true;
// change errorColor to blue
katex.config.errorColor = '#1500ff';
</script>
Check katex for more details.
FOUC
If your page suffers from a "Flash Of Unstyled Content," add this to your <body>
tag:
<body style="display:none;" onload="$('body').show();">
This hides the body and shows it only when the JavaScript has loaded.
Math Example
in asciimath
```asciimath
x = (-b+-sqrt(b^2-4ac))/(2a)
```
x = (-b+-sqrt(b^2-4ac))/(2a)
in latex
```latex
x=\frac{ -b\pm\sqrt{ b^2-4ac } } {2a}
```
x=\frac{ -b\pm\sqrt{ b^2-4ac } } {2a}
They will both render the exact same thing. If the examples don't render correctly click here.