nicolewhite / algebra.js

Build, display, and solve algebraic equations.
http://algebra.js.org
MIT License
1.34k stars 111 forks source link

Cannot read 'Render' property #61

Closed pvskand closed 8 years ago

pvskand commented 8 years ago

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>
nicolewhite commented 8 years ago

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

pvskand commented 8 years ago

Why is this error showing up? image

nicolewhite commented 8 years ago

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.

pvskand commented 8 years ago

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

nicolewhite commented 8 years ago

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>