Reputation: 23
I created a single index.html
file to test auto-render of KaTeX (0.9.0-alpha).
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0-alpha/katex.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0-alpha/katex.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0-alpha/contrib/auto-render.min.js"></script>
</head>
<body>
<div id="el"><span>$$2+\frac{1}{x}$$</span></div>
<script>
renderMathInElement(document.body);
</script>
</body>
</html>
But when I open html file in browser (Chrome 61.0), I got an error (also appears in KaTeX 0.8.3):
Uncaught TypeError: renderMathInElement is not a function
So how to use KaTex in a single html?
Upvotes: 1
Views: 550
Reputation: 341
It appears that you are hitting a bug in KaTeX: https://github.com/Khan/KaTeX/pull/920. The bug has been fixed but the fix is not yet released to the CDN, so in the meantime I just reverted to 0.8.3; I am surprised that did not work for you.
Upvotes: 1