Skip to content

Instantly share code, notes, and snippets.

@nathan
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathan/dd5f200c12f9a0fb2693 to your computer and use it in GitHub Desktop.
Save nathan/dd5f200c12f9a0fb2693 to your computer and use it in GitHub Desktop.
Exporting things
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