-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
51 lines (45 loc) · 1.21 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
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.flex {
display: flex;
height: 100%;
align-items: center;
}
.form {
width: 40%;
min-height: 500px;
border: 1px solid #AAA;
white-space: pre;
}
</style>
<script type="text/javascript">
function mdToHtml() {
var input = document.getElementById("md-input").value;
sendGithubApiRequest(input);
}
function sendGithubApiRequest(mdText) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://api.github.com/markdown', true);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.onload = function() {
document.getElementById("html-output").innerText = this.responseText;
};
var data = JSON.stringify({"text": mdText, "mode": "markdown"});
xhr.send(data);
}
</script>
</head>
<body>
<div class="flex">
<textarea id="md-input" class="form" type="text">Write your md here</textarea>
<div>
<button onclick="mdToHtml()">Convert</button>
</div>
<div id="html-output" class="form">
</div>
</div>
</body>
</html>