forked from markedjs/marked
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlatex.html
58 lines (49 loc) · 1.26 KB
/
latex.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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-BTL0nVi8DnMrNdMQZG1Ww6yasK9ZGnUxL1ZWukXQ7fygA1py52yPp9W4wrR00VML" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-y6SGsNt7yZECc4Pf86XmQhC4hG2wxL6Upkt9N1efhFxfh6wlxBH0mJiTE8XYclC1" crossorigin="anonymous"></script>
<script src="../../lib/marked.js"></script>
<script>
marked.setOptions({
gfm: true,
breaks: true,
latexRender: katex.renderToString.bind(katex),
});
$ = document.querySelector.bind(document)
function mdRender(){
var text = $('#input').value
$('#preview').innerHTML = marked (text);
}
window.onload=mdRender
</script>
</head>
<body>
<textarea id="input" oninput="mdRender()" "autofocus">
```
$$ x^2+y^2 = 1 $$
$$
\frac{n!}{k!(n-k)!} = \binom{n}{k}
$$
```
$$ x^2+y^2 = 1 $$
$$
\frac{n!}{k!(n-k)!} = \binom{n}{k}
$$
</textarea>
<style>
em{ color:red}
textarea{width:100%; height:200px;}
#preview{
padding: 0.5em 1em; margin: 1em 1em;
}
pre{
padding: 2em 1em; margin: 0 2em 2em 0; border-radius: 1em;
line-height: 2em;
width:90%;
background: #f5f2f0;
}
</style>
<div id="preview"> </div>
</body>
</html>