Created
April 9, 2009 21:12
-
-
Save erickedji/92741 to your computer and use it in GitHub Desktop.
ubiquity: turn all urls in the selection into links
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
| /* | |
| * Turn all urls in the selection into links | |
| * Frustrated by Google docs asking me to do CTRL-K, ENTER for every link. | |
| * Eric KEDJI <eric.kedji@gmail.com> | |
| */ | |
| CmdUtils.CreateCommand({ | |
| name: "linkify", | |
| homepage: "http://erickedji.wordpress.com/", | |
| author: {name: "Eric", email: "eric.kedji@gmail.com"}, | |
| license: "GPL", | |
| description: "Turn all the urls in the selection into links", | |
| help: "Invoke it on a chunk of text", | |
| takes: {"input": /.*/}, | |
| preview: function(pblock, input) { | |
| pblock.innerHTML = "'Linkify' the selected text."; | |
| }, | |
| execute: function(input) { | |
| CmdUtils.setSelection( | |
| input.text.replace(/http:\/\/([^ \)]+)/g, '<a href="http:\/\/$1">http:\/\/$1</a>')); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment