本网站最受欢迎的功能之一是自动语法高亮代码片段。现在它已经可用,我想在这里记录一下,而不是给每个人发电子邮件。之所以花费这么长时间才实现,是因为我不知道如何最好地将其与Seam wiki文本语法集成。正如您所知,我们用反引号包裹代码块 - 这没有留下任何语法高亮选项的空间。其他wiki文本解析器使用类似以下的方式<code syntax="java">...</code>但我希望保留超级快速的`语法 和 进行高亮显示。
因此,现在的工作方式是使用可选的参数行,它跟在开头的反引号后面
<p class="wikiPara">
The options are enclosed in square brackets and the closing square bracket needs to be followed by a newline. See <a href="http://alexgorbatchev.com/wiki/SyntaxHighlighter:Configuration" target="" class="regularLink">this page</a> for a list of options. I've installed all brushes, though most of you will probably use 'java', 'xml', and 'sql'.
</p>
<p class="wikiPara">
The example will then render like this:
</p>
<pre class="wikiPreformatted brush: java; gutter: true;">String text = "Hello World"; // Some comment...
System.out.println(text);
如果您没有指定画笔或未包含选项行,代码块将像以前一样渲染为灰色框。哦,还有,当您编辑文档时,预览将始终显示未高亮的版本,只有在您保存或更新文档时才会应用。
(不,它不会在seamframework.org论坛上工作。这必须在这里先进行测试。)