-
-
Save clausd/77051 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
| /* Convert selection to HTML entitites - danish chars only */ | |
| CmdUtils.CreateCommand({ | |
| name: "entitize", | |
| icon: "http://www.classy.dk/favicon.ico", | |
| homepage: "http://www.classy.dk/", | |
| author: { name: "Claus Dahl", email: "dee@classy.dk"}, | |
| license: "GPL", | |
| description: "Translates danish characters to html entities", | |
| help: "select text and apply to replace with entitized text", | |
| takes: {"input": noun_arb_text}, | |
| _entitize: function (input) { | |
| var text = input; | |
| text = text.replace(/&/g, "&"); | |
| text = text.replace(/>/g, ">"); | |
| text = text.replace(/</g, "<"); | |
| text = text.replace(/ø/g,'&oslash;'); | |
| text = text.replace(/Ø/g,'&Oslash;'); | |
| text = text.replace(/å/g,'&aring;'); | |
| text = text.replace(/Å/g,'&Aring;'); | |
| text = text.replace(/æ/g,'&aelig;'); | |
| text = text.replace(/Æ/g,'&AElig;'); | |
| text = text.replace(/ä/g,'&auml;'); | |
| text = text.replace(/Ä/g,'&Auml;'); | |
| text = text.replace(/ö/g,'&ouml;'); | |
| text = text.replace(/Ö/g,'&Ouml;'); | |
| return text; | |
| }, | |
| preview: function( pblock, input ) { | |
| pblock.innerHTML = this._entitize(input.html); | |
| }, | |
| execute: function(input) { | |
| CmdUtils.setSelection(this._entitize(input.html)); | |
| } | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment