git ssb

6+

cel / downmark



Tree: c215e2fd7a75c6f661ea666fa20733af27fc6806

Files: c215e2fd7a75c6f661ea666fa20733af27fc6806 / index.js

699 bytesRaw
1var toMarkdown = require('to-markdown')
2
3function debounce(fn, wait) {
4 var timeout
5 return function() {
6 clearTimeout(timeout)
7 timeout = setTimeout(fn, wait)
8 }
9}
10
11var value
12var inputEl = document.getElementById('input')
13var outputEl = document.getElementById('output')
14var outputText = outputEl.appendChild(document.createTextNode(''))
15var opt = {
16 gfm: true,
17 converters: [{
18 filter: ['span', 'div', 'small', 'font'],
19 replacement: function (content) {
20 return content
21 }
22 }]
23}
24inputEl.onkeydown = inputEl.onkeyup = debounce(function() {
25 var newVal = inputEl.innerHTML
26 if (value == newVal) return
27 value = newVal
28 outputText.nodeValue = toMarkdown(value, opt)
29})
30

Built with git-ssb-web