Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Bookmarklet for Markdown Code Indenting
(function(){var a=document.activeElement,b=document.getSelection().toString(),c="",d=b.split("\n");indent=" ",i=0,total=d.length;if(b==""){return}for(i=0;i<total;i++){c+=indent+d[i]+"\n"}a.value=a.value.split(b).join(c)}())
(function() {
var el = document.activeElement,
selection = document.getSelection().toString(),
result = "",
lines = selection.split("\n");
indent = " ",
i = 0, total = lines.length;
if (selection == "") {
return;
}
for (i = 0; i < total; i++) {
result += indent + lines[i] + "\n";
}
el.value = el.value.split(selection).join(result);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment