Skip to content

Instantly share code, notes, and snippets.

@bbbco
Created October 28, 2008 05:27
Show Gist options
  • Save bbbco/20307 to your computer and use it in GitHub Desktop.
Save bbbco/20307 to your computer and use it in GitHub Desktop.
hyphenate
CmdUtils.CreateCommand( {
name: "hyphenated",
takes: {"phrase": noun_arb_text},
author: {
name: "Brian D. Goad",
email: "[email protected]"},
license: "MPL",
description: "Replaces the spaces in a phrase with a hyphen.",
_hyphenate: function(phrase) {
return phrase.text.replace( / /g, "-", i );
},
preview: function( pblock, phrase ) {
var msg = "Replaces the space in a phrase with a hyphen.";
msg += "<br />\" <i>";
msg += this._hyphenate(phrase);
msg += "</i> \"";
pblock.innerHTML = msg;
},
execute: function( phrase ){
CmdUtils.setSelection( this._hyphenate(phrase) );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment