This repository has been archived by the owner on Jul 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
editor.html
45 lines (38 loc) · 1.76 KB
/
editor.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
<html>
<head>
<title>Demarcate Lean Editing Mode</title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
<link rel="stylesheet" href="css/demarcate.css" type="text/css" />
<link rel="stylesheet" href="css/editor_styles.css" type="text/css" />
</head>
<body>
<div id="edit_me">
</div>
<div id="render">
<a href="#">Preview Markdown</a>
</div>
<!-- Include jQuery - this is only for some of the DOM manipulations and is not required for demarcate -->
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- OPTIONALLY include keys.js to enable shortcut functions -->
<script src="bower_components/keymaster/keymaster.js" type="text/javascript"></script>
<!-- Include demarcate.min.js -->
<script src="bin/demarcate.js" type="text/javascript"></script>
<!-- Hook up the editor -->
<script type="text/javascript">
var hide_preview = function() {
$("#preview").remove();
}
$(document).ready( function() {
demarcate.enable($('#edit_me').get(0));
$("#render").click( function (e) {
e.preventDefault();
$("#preview").remove(); // prevent stacking previews
var md = demarcate.parse().replace(/\n/g,"<br>");
var prev = $("<div />", { id: "preview", html: md });
$("body").append(prev);
});
$(document).on("click", "#preview", hide_preview);
});
</script>
</body>
</html>