Created
October 1, 2008 15:26
-
-
Save source-data/14100 to your computer and use it in GitHub Desktop.
This file contains 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
CmdUtils.CreateCommand({ | |
names: ["rewrap"], | |
arguments: [{role: "object", | |
nountype: noun_arb_text, | |
label: "input"}], | |
help: "removes unnecessary carriage returns and strings of spaces", | |
execute: function(arguments) { | |
var selectedText=arguments.text; | |
selectedText=selectedText.replace(/[\r\n]{2}/g,"§#!"); | |
selectedText=selectedText.replace(/[\r\n]+/g," "); | |
selectedText=selectedText.replace(/§#!/g,"\r\r"); | |
selectedText=selectedText.replace(/ +/g," "); | |
CmdUtils.setSelection("",{text: selectedText}); | |
}, | |
preview: function(pblock, arguments) { | |
var selectedText=arguments.text; | |
selectedText=selectedText.replace(/[\r\n]{2}/g,"§#!"); | |
selectedText=selectedText.replace(/[\r\n]+/g," "); | |
selectedText=selectedText.replace(/§#!/g,"\r\r"); | |
selectedText=selectedText.replace(/ +/g," "); | |
pblock.innerHTML=selectedText; | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment