A much-requested feature on this website has been automatic syntax highlighting of code snippets. It is now available and I thought I'd document it here instead of sending everyone an e-mail. The reason why it took so long to implement is that I didn't know how to best integrate it with the Seam wiki text syntax. As you know, we wrap a code block in backticks - that doesn't leave any room for syntax highlighting options. Other wiki text parsers use something like <code syntax="java">...</code> but I wanted to keep the superfast backtick syntax and have it highlighted.
So the way it works now is with an optional line of parameters that follows the opening backtick:
`[brush: java; gutter: true;] String text = "Hello World"; // Some comment... System.out.println(text); `
The options are enclosed in square brackets and the closing square bracket needs to be followed by a newline. See this page for a list of options. I've installed all brushes, though most of you will probably use 'java', 'xml', and 'sql'.
The example will then render like this:
String text = "Hello World"; // Some comment... System.out.println(text);
If you do not specify a brush or if you do not include an option line, the code block will be rendered as a grey box, as before. Oh, and the preview when you edit a document will always show the non-highlighted version, it's only applied when you save or update the document.
(No, it will not work on the seamframework.org forums. This has to be tested here first.)