-
-
Save eunomie/5388070 to your computer and use it in GitHub Desktop.
Markdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h = document.getElementsByTagName('head')[0] | |
m = document.createElement('script'); m.src="https://pagedown.googlecode.com/hg/Markdown.Converter.js";h.appendChild(m) | |
document.body.innerHTML = '<table><tr><td contenteditable></td><td></td>' | |
a = document.createElement('style'); a.appendChild(document.createTextNode('table {width:100%;height:100%}td{width:50%;overflow:auto}td+td{background:#eeeeec}'));h.appendChild(a) | |
tds=document.getElementsByTagName('td') | |
s = tds[0] | |
p = tds[1] | |
;(_ = function() { | |
if (!("Markdown" in window)) { | |
window.setTimeout(_, 100) | |
return | |
} | |
c = new Markdown.Converter() | |
s.addEventListener('keyup', function() { p.innerHTML = c.makeHtml(s.innerText || s.innerHTML.replace(/<br>/g, '\n'))}) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment