Created
September 9, 2008 22:23
-
-
Save tothda/9783 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Slightly modified version of the official syntax-highlight command. The original does not work for me with Ruby. | |
| // it uses: http://xzfv.appspot.com | |
| // ruby formatting only | |
| CmdUtils.CreateCommand({ | |
| name: "shl", | |
| takes: {"code": noun_arb_text}, | |
| icon: "chrome://ubiquity/skin/icons/color_wheel.png", | |
| description: "Treats your selection as program source code, guesses its language, and colors it based on syntax.", | |
| execute: function( directObj ) { | |
| var code = directObj.text; | |
| var url = "http://xzfv.appspot.com/doformat"; | |
| var params = { | |
| source: code, | |
| language: "ruby", | |
| output: "html" | |
| }; | |
| jQuery.ajax({ | |
| type: 'POST', | |
| url: url, | |
| data: params, | |
| success: function( data ) { | |
| var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "div"); | |
| tempElement.innerHTML = data; | |
| var html = jQuery(tempElement).find('.highlight').html(); | |
| CmdUtils.setSelection(html); | |
| } | |
| }); | |
| }, | |
| preview: "Syntax highlights your code." | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment