git ssb

6+

cel / downmark



Commit e1d55af4c6ecc7aec5bea5d5146664d17bc2d5f3

Initial commit

Charles Lehner committed on 5/2/2016, 5:40:31 AM

Files changed

index.htmladded
index.jsadded
package.jsonadded
index.htmlView
@@ -1,0 +1,53 @@
1+<!doctype html>
2+<html>
3+ <head>
4+<style>
5+
6+* {
7+ padding: 0;
8+ margin: 0;
9+}
10+
11+.container {
12+ position: absolute;
13+ top: 0;
14+ bottom: 0;
15+ width: 50%;
16+}
17+
18+.left {
19+ left: 0;
20+ border-right: 1px solid #888;
21+}
22+
23+.right {
24+ right: 0;
25+}
26+
27+.box {
28+ padding: 1em;
29+ min-height: 80%;
30+}
31+
32+#output {
33+ font-family: monospace;
34+ white-space: pre-wrap;
35+}
36+
37+#input:empty:before {
38+ color: #999;
39+ content: 'paste rich text here';
40+}
41+
42+</style>
43+ </head>
44+ <body>
45+ <div class="container left">
46+ <div id="input" class="box" contenteditable="true"></div>
47+ </div>
48+ <div class="container right">
49+ <div id="output" class="box" contenteditable="true"></div>
50+ </div>
51+ <script src="bundle.js"></script>
52+ </body>
53+</html>
index.jsView
@@ -1,0 +1,28 @@
1+var toMarkdown = require('to-markdown')
2+
3+function debounce(fn, wait) {
4+ var timeout
5+ return function() {
6+ clearTimeout(timeout)
7+ timeout = setTimeout(fn, wait)
8+ }
9+}
10+
11+var value
12+var inputEl = document.getElementById('input')
13+var outputEl = document.getElementById('output')
14+var outputText = outputEl.appendChild(document.createTextNode(''))
15+var opt = {
16+ converters: [{
17+ filter: 'span',
18+ replacement: function (content) {
19+ return content
20+ }
21+ }]
22+}
23+inputEl.onkeydown = inputEl.onkeyup = debounce(function() {
24+ var newVal = inputEl.innerHTML
25+ if (value == newVal) return
26+ value = newVal
27+ outputText.nodeValue = toMarkdown(value, opt)
28+})
package.jsonView
@@ -1,0 +1,15 @@
1+{
2+ "name": "downmark",
3+ "version": "0.0.0",
4+ "description": "editor that turns rich text into markdown",
5+ "main": "index.js",
6+ "author": "Charles Lehner (http://celehner.com/)",
7+ "license": "Fair",
8+ "scripts": {
9+ "build": "browserify . -o bundle.js"
10+ },
11+ "devDependencies": {
12+ "browserify": "^13.0.0",
13+ "to-markdown": "^3.0.0"
14+ }
15+}

Built with git-ssb-web