-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRender Markdown.html
53 lines (49 loc) · 1.77 KB
/
Render Markdown.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
<!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">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>MD <--> HTML</title>
<style>
#dropContainer {
width: 960px;
height: 768px;
margin-top: 40px;
margin: auto;
text-align: center;
vertical-align: text;
border: black 1px solid;
}
</style>
</head>
<body>
<div class="" id="dropContainer">
<input type="file" class="" id="source">
<h4>Drop MD file here</h4>
</div>
<div id="htmlDiv"></div>
<script src="https://cdn.jsdelivr.net/npm/showdown@1.9.0/dist/showdown.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.0/showdown.min.js"></script>
<script>
(function () {
const dropContainer = document.querySelector('#dropContainer');
dropContainer.ondragover = dropContainer.ondragenter = function (evt) {
evt.preventDefault();
};
dropContainer.ondrop = function (evt) {
evt.preventDefault();
const reader = new FileReader();
reader.onload = function (file) {
// document.querySelector('#htmlDiv').innerHTML = new showdown.Converter().makeHtml(file.target.result);
document.body.innerHTML = new showdown.Converter().makeHtml(file.target.result);
console.log('document: ', document);
}
reader.readAsText(evt.dataTransfer.files[0]);
};
})();
</script>
</body>
</html>