-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
92 lines (87 loc) · 1.8 KB
/
index.html
File metadata and controls
92 lines (87 loc) · 1.8 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>markrun</title>
<style>
.box:after {
content: ' ';
display: block;
clear: both;
}
.box {
position: relative;
padding-right: 50%;
}
.textarea {
position: absolute;
right:0;top:0;
width:48%;
min-height: 300px;
color: #abb2bf;
background: #282c34;
display: block;
padding: 1em;
overflow: auto;
border-radius: .2em;
border: 0;
}
.preview {
display: block;
float: right;
width:48%;
}
.error {
color:red;
}
</style>
</head>
<body>
<pre id="error" class="error"></pre>
<div class="box">
<div id="preview" ></div>
<textarea id="markdown" class="textarea">
# markrun
[https://github.com/markrun/markrun](https://github.com/markrun/markrun)
````html
time: <div class="demo" id="demo" ></div>
````
````js
document.getElementById('demo').innerHTML = new Date().getTime()
````
````css
.demo {
color:blue;
}
````
<!--MARKRUN-HTML
<em>markrun/markrun</em>
-->
</textarea>
</div>
<script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js" ></script>
<script src="https://unpkg.com/markrun@0.3.0/browser/markrun.js" ></script>
<script>
$(function () {
var $preview = $('#preview')
var $markdown = $('#markdown')
var $error = $('#error')
$markdown.on('input change', function () {
var errorMsg = ''
try {
var html = markrun(this.value)
}
catch(e) {
errorMsg = e.message
console.log(e)
}
$error.html(errorMsg)
$preview.html(html)
console.log(html)
}).trigger('input')
})
</script>
</body>
</html>