forked from mathquill/mathquill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickstart.html
40 lines (36 loc) · 1.57 KB
/
quickstart.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html>
<head>
<title>MathQuill Quickstart</title>
<link rel="stylesheet" type="text/css" href="build/mathquill.css">
</head>
<body>
<p>Static math span: <span id="static-math">x = \frac{ -b \pm \sqrt{b^2-4ac} }{ 2a }</span>
<p>Editable math field: <span id="math-field">x^2</span></p>
<p>LaTeX of what you typed: <code id="latex">x^2</code></p>
<p><a href="http://docs.mathquill.com/en/latest/Getting_Started/">MathQuill’s Getting
Started Guide</a></p>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.js"></script>
<script src="build/mathquill.js"></script>
<script>
var staticMathSpan = document.getElementById('static-math');
var mathFieldSpan = document.getElementById('math-field');
var latexSpan = document.getElementById('latex');
var MQ = MathQuill.getInterface(2); // keeps the API stable
// easily create static or editable math from a DOM element by calling the
// appropriate constructor: http://docs.mathquill.com/en/latest/Api_Methods/
MQ.StaticMath(staticMathSpan);
// you may pass in an options object:
var mathField = MQ.MathField(mathFieldSpan, {
spaceBehavesLikeTab: true, // an example config option, for more see:
// http://docs.mathquill.com/en/latest/Config/
handlers: {
edit: function() {
// retrieve, in LaTeX format, the math that was typed:
latexSpan.textContent = mathField.latex();
}
}
});
</script>
</body>
</html>