--- Came wiffling through the eclipsey wood ---/*
* Menu: HTML > Encode entities
* Kudos: Mark Gerrard
* Key:M3+1
* License: EPL 1.0
* DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
*/
function main() {
var sourceEditor = editors.activeEditor;
var hashEnt = {
'¡': '¡',
'¢': '¢',
'£': '£',
'?': '¤',
'¥': '¥',
'?': '¦',
'§': '§',
'¨': '¨',
'©': '©',
'ª': 'ª',
'«': '«',
'¬': '¬',
'?': '­',
'®': '®',
'¯': '¯',
'°': '°',
'±': '±',
'?': '²',
'?': '³',
'´': '´',
'µ': 'µ',
'¶': '¶',
'·': '·',
'¸': '¸',
'?': '¹',
'º': 'º',
'»': '»',
'?': '¼',
'?': '½',
'?': '¾',
'¿': '¿',
'À': 'À',
'Á': 'Á',
'Â': 'Â',
'Ã': 'Ã',
'Ä': 'Ä',
'Å': 'Å',
'Æ': 'Æ',
'Ç': 'Ç',
'È': 'È',
'É': 'É',
'Ê': 'Ê',
'Ë': 'Ë',
'Ì': 'Ì',
'Í': 'Í',
'Î': 'Î',
'Ï': 'Ï',
'?': 'Ð',
'Ñ': 'Ñ',
'Ò': 'Ò',
'Ó': 'Ó',
'Ô': 'Ô',
'Õ': 'Õ',
'Ö': 'Ö',
'?': '×',
'Ø': 'Ø',
'Ù': 'Ù',
'Ú': 'Ú',
'Û': 'Û',
'Ü': 'Ü',
'?': 'Ý',
'?': 'Þ',
'ß': 'ß',
'à': 'à',
'á': 'á',
'â': 'â',
'ã': 'ã',
'ä': 'ä',
'å': 'å',
'æ': 'æ',
'ç': 'ç',
'è': 'è',
'é': 'é',
'ê': 'ê',
'ë': 'ë',
'ì': 'ì',
'í': 'í',
'î': 'î',
'ï': 'ï',
'?': 'ð',
'ñ': 'ñ',
'ò': 'ò',
'ó': 'ó',
'ô': 'ô',
'õ': 'õ',
'ö': 'ö',
'÷': '÷',
'ø': 'ø',
'ù': 'ù',
'ú': 'ú',
'û': 'û',
'ü': 'ü',
'?': 'ý',
'?': 'þ',
'ÿ': 'ÿ',
'"': '"',
'<': '<',
'>': '>',
'&': '&',
'–': '-',
'“': '"',
'”': '"'
};
// make sure we have an editor
if (sourceEditor === undefined) {
valid = false;
showError("No active editor");
}
else
{
var range = sourceEditor.selectionRange;
var offset = range.startingOffset;
var deleteLength = range.endingOffset - range.startingOffset;
var source = sourceEditor.source;
var selection = source.substring(range.startingOffset, range.endingOffset);
var newselection = '';
for (var i = 0; i < selection.length; i++) {
var curChar = selection.charAt(i);
if (hashEnt.hasOwnProperty(curChar)) {
newselection+= hashEnt[curChar];
} else {
newselection+= curChar.toString();
}
}
sourceEditor.applyEdit(offset, deleteLength, newselection);
sourceEditor.selectAndReveal(offset, newselection.length);
}
};--- And burbled as it ran! ---
Copie o código do script acima, vá em “Scripts->Paste new script” no menu do Aptana. Tcharan! Script instalado =)
Basta selecionar o texto que está com os caracteres especiais (ex.: açafrão) e vá no menu “Scripts->HTML->Encode Entities” ou simplesmente use o atalho “ALT+1”.
Para alterar as teclas de atalho basta editar a linha 4 (* Key:M3+1) do script.
Obs: as linhas “--- Came wiffling through the eclipsey wood ---” e “--- And burbled as it ran! ---”, no script, são necessárias para não ocorrer o erro “Can’t find any scripts on clipboard - make sure you include the Jabberwocky-inspired markers at the beginning and ending of the script”.
©2010. Postage by Greg Cooper. Icons by P.J. Onori. Thanks to Jamie Cassidy & Panic.
*Unlikely to find your lost post using this but you can try...
Comments