Escape HTML with Eclipse Monkey

Posting code on my blog became tedious.
I always had to go though and replace every < and > with > and < or some parts of the code would simply disappear! Furthermore closing square brackets seem to change normal quotes into their italic counterparts, so ] has to be replaced with &#93; too.

Eclipse Monkey to the rescue!
Since i do not want to mess up my code inside of Eclipse, i let the monkey only play with my Clipboard.

After the script was finished, it had to ‘escape’ itself to reach the public :D

installing eclipse monkey
create a scripts folder in your project root and paste it into some escape.js, after this it should show up under ‘scripts > HTML’.

/*
 * Menu: HTML > basic html escape
 * Kudos: Michael Grosser
 * License: WTF
 */

function main() {
	systemClipboard = Packages.java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
	contents = systemClipboard.getContents(null);
	msg = contents.getTransferData(Packages.java.awt.datatransfer.DataFlavor.stringFlavor);
	msg = msg.replace('&','XXplaceHolDerXX');
	msg = msg.replace('XXplaceHolDerXX','&amp;');

	msg = msg.replace('<','&lt;');
	msg = msg.replace('>','&gt;');
	msg = msg.replace(']','&#93;');
	newContents  = new Packages.java.awt.datatransfer.StringSelection(msg);
	systemClipboard.setContents(newContents, newContents);
}

Stupid WordPress keeps ‘correcting’ my > to &gt; … :/

Eclipse Timesavers

More than 1 workspace per installation ?
Make links, each with a wokspace set (‘data’) and activate showlocation, so you know where you are in (when having multiple eclipses open)!
c:\...\eclipse.exe    -data c:\eclipse-workspaces\workspace1   -showlocation

Limit RAM usage:

c:\...\eclipse.exe    -vmargs -Xms256M -Xmx256M

Reuse preferences in  another installation:
File->Export->Preferences + import

More timesavers:
Eclipse Tips
Eclipse Navigations Shortcuts

Code Review With Eclipse

The only free and usable plugin: Jupiter
Update-Site: http://csdl.ics.hawaii.edu/Tools/Jupiter/Download
Works good, adds marks/comments in the editor.

Drawback:
Comments are saved as XML in a folder, which must be shared with all other developers (SVN(each comment = new Revision) /Samba)

Conclusion:
Make 1 review on 1 checked out source and commit OR create a samba server and link it to the review-data-folder, so reviews can be shared without commits.

In the editor

Entering a review

Show a review