forked from fex-team/kf-parser
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
117 lines (99 loc) · 3.76 KB
/
index.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.main {
width: 1000px;
height: 100%;
margin: 0 auto;
}
#editor {
width: 100%;
height: 200px;
}
.split {
padding: 50px 0;
}
#editor textarea {
width: 100%;
height: 100%;
resize: none;
}
</style>
<script src="dev-lib/jquery-1.10.2.min.js"></script>
<script src="dev-lib/kitygraph.all.js"></script>
<script src="dev-lib/kity-formula-render.all.js"></script>
<script src="dev-lib/dev-define.js"></script>
<script>
inc.config({
base: './src'
});
</script>
<script src="dev-lib/start.js"></script>
<script src="dev-lib/dev-start.js"></script>
<!--<script src="dist/kity-formula-parser.all.js"></script>-->
<script>
window.onload = function () {
var Parser = kf.Parser,
Assembly = kf.Assembly,
latexParser = Parser.use( "latex" );
kf.ResourceManager.ready( function ( Formula ) {
var formula = new Formula( document.getElementById( "container" ), {
fontsize: 50,
color: 'red'
}),
assembly = new Assembly( formula );
document.getElementById( "parseBtn" ).onclick = function () {
parse();
};
document.onkeydown = function ( e ) {
if ( ( e.ctrlKey || e.metaKey ) && e.keyCode === 83 ) {
e.preventDefault();
parse();
}
};
function parse () {
var value = document.getElementById( "latexInput" ).value,
parseResult = latexParser.parse( value );
assembly.regenerateBy( parseResult );
}
}, {
path: "./resource/"
} );
};
</script>
</head>
<body>
<div class="main">
<div id="editor">
<!--<textarea id="latexInput">\int^{n}_{n=20}{n*3}</textarea>-->
<!--<textarea id="latexInput">\lim_{x\to\infty}{a-b}</textarea>-->
<!--<textarea id="latexInput">a+{b-c}</textarea>-->
<!--<textarea id="latexInput">\int{\sum ab} a</textarea>-->
<!--<textarea id="latexInput">a^2+b^2=c^2</textarea>-->
<!--<textarea id="latexInput">a+b+c-d</textarea>-->
<!--<textarea id="latexInput">a+b+{c+d}^2+acd</textarea>-->
<!--<textarea id="latexInput">\sqrt[n]{ab}=\sqrt[n]{a}\cdot\sqrt[n]{b}</textarea>-->
<!--<textarea id="latexInput">\left [ (a+b-c) \right ]</textarea>-->
<!--<textarea id="latexInput">e=\lim _{n\to \infty }\left(1+\frac{1233}{n}\right)</textarea>-->
<!--<textarea id="latexInput">\int^b_a{f(x)}dx=\lim_{n\to\infty}{\sum_{i=0}^\infty{\frac {b-a}nf(t_i)}} </textarea>-->
<!--<textarea id="latexInput">\begin{array}{cc}a&b\\c&d\end{array}</textarea>-->
<!--<textarea id="latexInput">\underbrace {abcd}_k</textarea>-->
<!--<textarea id="latexInput">\begin{split}c&=a+b\\&=a\div d\end{split}</textarea>-->
<textarea id="latexInput">\left\{\begin{array}{ll}x^2+y^2=1 & 1 \\ x+2y=5&2\end{array}\right.</textarea>
</div>
<div class="split">
<button id="parseBtn" type="button">转换</button>
</div>
<div id="container"></div>
</div>
</body>
</html>