Our blog has the code highlighting plugin activated so that code can be added into the posts fairly easily.
The trick to getting it to work is to go to the source view in the editor (the button is top left in the editor) and then enclose the code in <pre lang="language tag">...</pre> tags.
I don’t know the complete list of languages, but so far java, javascript, and xml have worked. The highlighting is done by an engine called Geshi. I don’t know which version. They claim to be able to deal with any language possible including “Z80 ASM,” which raises the question of “Why?” Having said it deals with almost all languages, I haven’t been able to get HTML to work. That may be a result of the editor, which is merely passible I’d say.
Here is an XML example:
<branch name="bin" id="1">
</branch>
</root>
Here is a java example:
boolean ret = super.init();
if (getNumStrings()>0)
url = getString(0);
else
url = "http://www.wazia.com";
return ret;
}
Here is an HTML example (using lang=”xml”:
<head>
<title>This is a simple page</title>
</head>
<body>
<div id="contentpane">
<h1>This is a simple page</h1>
<p>Here is some text on this dumb page.</p>
</div>
</body>
</html>
To be honest putting xml into the text sucks, but the other languages work very well.



Ah-hah. When you copy/pasted the java code, did the indenting stick or did you manually indent it?
I assume you’re the one who fixed my failed code inclusion in the old regex example post. Did you re-copy it in or fix the lost indenting in my post or just change the surrounding tags and now the code highlighting is showing it as indented?
I copied the code into IDEA and reindented it and then pasted back. The indenting you type will show.
The highlighter will handle tabs. Right now tabs are expanded to 8 spaces. I don’t use tabs. I use spaces in idea. Does 8 spaces work for other people?
That is not always true with xml code. The editor sometimes mangles that.
Would people rather have line numbers or the ability to easily copy out of the page?
With line numbers copying out of the page into an editor ends up with extra hash (#) marks. Is there a way to handle that with css or should I just turn off line numbers./
Turn off the line numbers.
I can’t get this to work for my post. I tried:
and in both cases, after I clicked Save, the editor just stripped out the lang attribute so I was left with the regular old tag.
That was supposed to say, I tried:
<pre lang=”language tag”>
and
<pre lang=”java”>
Hmm I was able to just add it. I don’t know. You can see that your post was changed.
I don’t know, I just tried it again with my new post, and the language=”xml” attribute is always stripped out by the editor.