-
Notifications
You must be signed in to change notification settings - Fork 1
/
md.html
63 lines (57 loc) · 1.17 KB
/
md.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
<html>
<head>
<title>Markdown Editor by Cuteribs</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
html,
body,
#editor {
margin: 0;
height: 100%;
color: #333;
}
textarea,
#editor div {
display: inline-block;
width: 49%;
height: 100%;
vertical-align: top;
box-sizing: border-box;
padding: 0 20px;
}
textarea {
border: none;
border-right: 1px solid #ccc;
resize: none;
outline: none;
background-color: #f6f6f6;
font-size: 14px;
padding: 20px;
}
img {
max-width: 90%;
}
code {
color: #f66;
}
</style>
<script src="https://unpkg.com/marked/marked.min.js"></script>
</head>
<body>
<div id="editor">
<textarea id="input"></textarea>
<div id="output"></div>
</div>
<script>
marked.use({ renderer: {
codespan: (src) => `<strong>${src}</strong>`
}});
const input = document.querySelector('#input');
const output = document.querySelector('#output');
input.addEventListener('change', e => {
const html = marked.parse(input.value);
output.innerHTML = html;
});
</script>
</body>
</html>