Last active
August 29, 2015 14:04
-
-
Save nathan/dd5f200c12f9a0fb2693 to your computer and use it in GitHub Desktop.
Exporting things
This file contains 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
var indent = ''; | |
function mdify(els) { | |
if (els.length) return [].map.call(els, mdify).join('\n'); | |
if (els.tagName === 'P' || els.tagName === 'LI') return els.textContent; | |
if (els.tagName === 'UL') {indent += ' '; return '* ' + [].map.call(els.children, mdify).join((indent = indent.slice(4), '\n' + indent + '* '));} | |
return ''; | |
} | |
copy([].slice.call(document.querySelectorAll('tr')).reverse().map(function(tr) { | |
return '# v' + tr.querySelector('td:first-child').textContent.trim() + '\n\n' + mdify(tr.querySelector('td:last-child').children); | |
}).join('\n\n').replace(/\* \* /g, ' * ').replace(/[“”]/g, '"')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment