arnar (owner)

Revisions

gist: 15512 Download_button fork
public
Public Clone URL: git://gist.github.com/15512.git
Embed All Files: show embed
MarkdownLink.js #
1
2
3
4
5
6
7
8
9
10
11
12
CmdUtils.CreateCommand({
  names: ["mdlink", "markdown link"],
  arguments: [{role: "object", nountype: noun_arb_text, label: "search term"}],
  preview: "Replaces the selected text with a Markdown link to the first Google result for that text.",
  execute: function( args ) {
    var baseUrl = "http://ajax.googleapis.com/ajax/services/search/web";
    var params = {v: "1.0", q: args.object.text};
    jQuery.getJSON( baseUrl, params, function( results ) {
      CmdUtils.setSelection( "[" + args.object.text + "](" + results.responseData.results[0].url + ")" );
    })
  }
});