forked from soegaard/bracket
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.js
32 lines (28 loc) · 970 Bytes
/
main.js
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
window.startup = function() {
var tex = document.getElementsByClassName("tex");
Array.prototype.forEach.call(tex, function(el) {
katex.render(el.getAttribute("data-expr"), el);
});
var demoInput = document.getElementById("demo-input");
var demoOutput = document.getElementById("demo-output");
function doDemo() {
try {
katex.render(demoInput.value, demoOutput, {
displayMode: true
});
} catch(err) {
while(demoOutput.lastChild) {
demoOutput.removeChild(demoOutput.lastChild);
}
var msg = document.createTextNode(err.message);
var span = document.createElement("span");
span.appendChild(msg);
demoOutput.appendChild(span);
span.setAttribute("class", "errorMessage");
}
}
demoInput.addEventListener("input", function() {
doDemo();
});
doDemo();
};