nicolewhite/algebra.js

Cannot read 'Render' property

pvskand opened this issue · 5 comments

I have used the sample code given in your Docs bu there is this error showing up saying that Cannot read property render. Should we define it like var render = new algebra.render? I did that as well but wasn't able to rectify the error.

<script >
var Fraction = algebra.Fraction;
var Expression = algebra.Expression;
var Equation = algebra.Equation;
var katex = algebra.katex;
var render = algebra.render;


var lambda = new Expression("lambda").add(3).divide(4);
var Phi = new Expression("Phi").subtract(new Fraction(1, 5)).add(lambda);

katex.render(algebra.toTex(lambda), expr1);
katex.render(algebra.toTex(Phi), expr2);
</script>
<div id="expr1"></div>
    <div id="expr2"></div>

There is no render property in this library. That is a katex method.

Why is this error showing up?
image

Please read the docs more closely. That example is using KaTeX, another library. Remove these lines:

var katex = algebra.katex;
var render = algebra.render;

This library doesn't have either of those methods.

Okay I am sorry for not reading the Docs properly. I thought KaTeX was a part of algebra.js. My bad!

From their docs over here you can include KaTeX in your HTML easily:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js"></script>

At that point you should be able to use katex.render in a <script> tag like I do in the docs:

<script>
katex.render(...)
</script>