forked from mathquill/mathquill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickstart.html
48 lines (43 loc) · 1.67 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
41
42
43
44
45
46
47
48
<!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">
\begin{aligned}
2x &= 4 \\
x &= 2
\end{aligned}
</span>
<p>Editable math field: <span id="math-field">
</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.min.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/
enterCreatesAligned: true,
handlers: {
edit: function() {
// retrieve, in LaTeX format, the math that was typed:
latexSpan.textContent = mathField.latex();
}
}
});
</script>
</body>
</html>