Using SyntaxHighlighter in Redmine

Redmine provides built-in syntax highlighting based on CodeRay (for this, refer here). But it is not so much powerful as leading libraries such as SyntaxHighlighter.

You can use SyntaxHighlighter with Redmine by simply modifying one template file in the Redmine. The file to modify, base.rhtml is a template file specifying the layout of most pages and located at the following position.

The default contents of base.rhtml is like followings.

You can add a few header elements for styles and scripts to install SyntaxHighlighter like the following.

If your Redmine is located at a restricted network and so can reach 'http://alexgorbatchev.com/'. You should download SyntaxHighlighter and deploy it under the public directory of your Redmine installation.

When SyntaxHighlighter is deployed at ${redmine.home}/htdocs/pulbic/vendor/syntaxhighlighter_3.0.83 directory, the custom header elements would be like the following.

You should restart Redmine to apply the change of template. When loading Redmine using Apache HTTP server, just restart Apache HTTP server.

For more about SyntaxHighlighter refer its homepage at http://alexgorbatchev.com/SyntaxHighlighter/


Post a Comment