forked from obedm503/showdown-katex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ejs
155 lines (139 loc) · 3.63 KB
/
index.ejs
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html>
<head>
<title>showdown-katex</title>
<link
rel="stylesheet"
href="https://unpkg.com/katex@0.16.2/dist/katex.min.css"
/>
<style>
code {
padding: 2px 4px !important;
}
#sandbox {
background-color: silver;
}
#sandbox > .col-md-6 > #sandbox-out,
#sandbox > .col-md-6 > #sandbox-in {
border: none;
box-sizing: border-box;
height: 350px;
padding: 10px;
resize: none;
width: 100%;
}
#sandbox-in {
margin: 10px auto;
background: #000;
color: #fff;
font: 14px Menlo, monospace;
}
#sandbox-in:focus {
outline: none !important;
border: 1px solid red;
box-shadow: 0 0 10px #719ece;
}
#sandbox-out {
color: black;
margin: 20px auto;
background: white;
}
</style>
</head>
<body style="display:none;" onload="document.body.style.display = 'block'">
<!-- readme -->
<bootmark src="README.md"></bootmark>
<!-- sandboxed demo -->
<div class="container">
<div class="row">
<h3>Try the live demo</h3>
</div>
<div class="row" id="sandbox">
<div class="col-md-6">
<h4 class="text-center">
Input Markdown
</h4>
<textarea id="sandbox-in">
#### Some Markdown Here
```asciimath
g(x) = 3x^4 + 2x^2
```
```latex
\sum_{i=1}^n i^3 = \left( \frac{n(g(n)+1)} 2 \right) ^2
```
```latex
C_p[\ce{H2O(l)}] = \pu{75.3 J // mol K}
```
```js
var some = normal('code');
```
</textarea>
</div>
<div class="col-md-6">
<h4 class="text-center">
Output
</h4>
<div id="sandbox-out"></div>
</div>
</div>
<hr />
</div>
<!-- examples -->
<bootmark src="examples.md"></bootmark>
<!-- changelog -->
<bootmark src="CHANGELOG.md"></bootmark>
<script src="https://unpkg.com/bootmark@0.8.0/dist/bootmark.bundle.min.js"></script>
<script src="<%= SRC %>"></script>
<script>
// define options. options in individual elements override these
// these do not affect the live demo
$.fn.bootmark.options = {
html: {
toc: false,
prettifyTheme: 'tomorrow-night-eighties',
},
showdown: {
extensions: [showdownKatex()],
},
};
// sandboxed live demo
$(function() {
var $input = $('#sandbox-in');
var $output = $('#sandbox-out');
try {
var params = new URLSearchParams(location.search);
var source = params.get('source');
if (source) {
$input.val(source);
}
} catch (e) {
// URLSearchParams is not supported everywhere
}
function render(e) {
var val = $input.val();
try {
var params = new URLSearchParams();
params.set('source', val);
if (e) {
// only set ?source when the user types in the box
var url = location.origin + '?' + params.toString();
history.pushState({ path: url }, document.title, url);
}
} catch (e) {
// URLSearchParams is not supported everywhere
}
$output.bootmark({
// markdown passed directly
markdown: val,
template: {
// "export" only the html produced
text: '${bootmark}',
},
});
}
$input.bind('input propertychange', render);
render();
});
</script>
</body>
</html>