Skip to content

Instantly share code, notes, and snippets.

@yatsu
Created February 6, 2010 13:09
Show Gist options
  • Save yatsu/296703 to your computer and use it in GitHub Desktop.
Save yatsu/296703 to your computer and use it in GitHub Desktop.
/* This is a template command */
CmdUtils.CreateCommand({
names: [ "markdown-copy" ],
homepage: "http://ubiquity.s21g.com/296703",
author: { name: "Masaki Yatsu", email: "yatsu@yatsu.info"},
license: "MIT",
description: "Copy url, title and selected text in Markdown format",
help: "Copy url, title and selected text in Markdown format",
arguments: [{ role: 'object', nountype: noun_arb_text, label: 'text' }],
urlTemp: "[${title}](${url} )",
contentTemp: "[${title}](${url} )\n\n> ${content}",
preview: function(pblock, args) {
var win = CmdUtils.getWindow();
var temp = args.object.text.length > 0 ? this.contentTemp : this.urlTemp;
pblock.innerHTML = CmdUtils.renderTemplate(temp, { title: win.document.title, url: win.location.href, content: args.object.text });
},
execute: function(args) {
var win = CmdUtils.getWindow();
var temp = args.object.text.length > 0 ? this.contentTemp : this.urlTemp;
Utils.clipboard.text = CmdUtils.renderTemplate(temp, { title: win.document.title, url: win.location.href, content: args.object.text });
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment