-
Notifications
You must be signed in to change notification settings - Fork 0
/
mathjax.html
80 lines (76 loc) · 2.15 KB
/
mathjax.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
layout: false
---
<html>
<meta charset="utf-8">
<body>
<style type="text/css">
div#input_area {
float:left;
height:135px;
width:50%;
margin-left:5px;
}
#input_area h2 {
margin:10px 0 6px 5px;
color:red;
font-size:14px;
}
#input_area textarea{
width:100%;
height:100px;
overflow:auto;
border:1px solid #c5c5c5;
border-right:0;
font:14px "Courier New", Courier, monospace;
}
div#output_area {
float:right;
height:135px;
width:49%;
}
#output_area h2 {
margin:10px 0 6px 5px;
color:red;
font-size:14px;
}
#output_area div{
width:100%;
height:100px;
border:1px solid #c5c5c5;
}
</style>
<div id = "input_area">
<h2>输入公式:</h2>
<textarea id = "input_mathjax" wrap="logical"></textarea>
</div>
<div id="output_area">
<h2>查看结果:</h2>
<div id="output_mathjax" >\({}\)</div>
</div>
<input type="button" value="显示公式" onClick="show_mathjax()">
<script type="text/javascript">
function show_mathjax()
{
var data = document.getElementById("input_mathjax").value;
var math = MathJax.Hub.getAllJax("output_mathjax")[0];
MathJax.Hub.Queue(["Text",math, data]);
}
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
}
});
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for(i=0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<script type="text/javascript" src="http://cdn.bootcss.com/mathjax/2.5.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</body>
</html>