-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
105 lines (91 loc) · 2.84 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
<!DOCTYPE html>
<html>
<head>
<title>GitHub Markdown Preview with VueJs - coligo</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="github-markdown.css">
<style>
body {
background-color: #f4f7f7;
}
.header-text h4 {
color: #454552;
}
.header-text h1 {
color: #e85a71;
}
#editor,
#preview {
height: 500px;
max-height: 500px;
margin-bottom: 20px;
margin-top: 20px;
}
.panel {
overflow-y: auto;
max-height: 500px;
padding: 10px;
}
.container {
padding-bottom: 30px;
}
</style>
</head>
<body>
<div id="app" class="container">
<div class="row">
<div class="col-xs-12 header-text">
<h1>GitHub Markdown Preview</h1>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6">
<textarea v-model="rawMarkdown" id="editor" class="form-control"></textarea>
</div>
<div id="preview" class="col-xs-12 col-md-6">
<div class="panel panel-default">
<div class="panel-body">
<article class="markdown-body" >
{{{renderedMarkdown}}}
</article>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<button @click="renderPreview" type="button" class="btn btn-primary pull-right">Preview</button>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.2.0.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/vue/1.0.16/vue.js"></script>
<script src="https://cdn.jsdelivr.net/vue.resource/0.7.0/vue-resource.min.js"></script>
<script>
var vm = new Vue({
el: "#app",
data: {
rawMarkdown: 'input',
renderedMarkdown: 'output'
},
methods:{
renderPreview: function(){
// POST request to GitHub API
this.$http({
url: 'https://api.github.com/markdown',
method: 'POST',
data: {text: this.rawMarkdown, mode: 'gfm'}
}).then(function (response) {
// success callback
this.renderedMarkdown = response.data;
}, function (response) {
// error callback
console.log(response.data);
});
}
}
});
</script>
</body>
</html>