Skip to content

Instantly share code, notes, and snippets.

@tomcritchlow
Created June 19, 2019 18:46
Show Gist options
  • Save tomcritchlow/92ec5f069b5b9bc35cf1fbd7dcbefd1d to your computer and use it in GitHub Desktop.
Save tomcritchlow/92ec5f069b5b9bc35cf1fbd7dcbefd1d to your computer and use it in GitHub Desktop.
A bookmarklet for turning selected text into a quote for markdown blogs
function getSelectionText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
}
function blogquote() {
var title = document.title;
var url = document.location;
var host = location.hostname;
var quote = getSelectionText();
var mdfile = ">"+quote+"\n\nsource: ["+title+"]("+url+")";
prompt("copy",mdfile);
}
blogquote()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment