May

14

ColdFusion Brush for SyntaxHighlighter Plus and Evolved

SyntaxHighlighter Plus has been replaced by SyntaxHighligher Evolved. Instructions for adding a ColdFusion brush to both are below.

SyntaxHighlighter Plus is a great Wordpress plugin for highlighting code in your blog posts. Out of the box it doesn’t come with a brush for ColdFusion syntax highlighting. A brush is a javascript file that is used by SyntaxHighlighter Plus to determine how to style the code inside the syntax highlighter itself. You could use the HTML brush for ColdFusion code, but a little funkiness happens at times so I added my own brush for ColdFusion.

How to Add the Brush

For Plus and Evolved, add the shBrushColdFusion.js to the scripts folder. If you installed it as a WordPress plugin, the folder structure will be syntaxhighlighter-plus (Plus) or syntaxhighlighter (Evolved), syntaxhighlighter, scripts.
SyntaxHighligher Plus: Modify the syntaxhighlighter.php found in the syntaxhighlighter-plus folder by adding ‘ColdFusion’ => array(‘coldfusion’, ‘cf’), to the aliases array.

$this->aliases = apply_filters( 'agsyntaxhighlighter_aliases', array(
            'Bash'      => array('bash', 'sh', 'shell'),
            'ColdFusion' => array('coldfusion', 'cf'),
            'Cpp'       => array('cpp', 'c', 'c++'),
            'CSharp'  => array('c#', 'c-sharp', 'csharp'),
            'Css'     => array('css'),
            'Delphi'  => array('delphi', 'pascal'),
            'Diff'    => array('diff', 'patch'),
            'Groovy'  => array('groovy'),
            'Java'    => array('java'),
            'JScript' => array('js', 'jscript', 'javascript'),
            'Perl'    => array('perl', 'pl'),
            'Php'     => array('php'),
            'Plain'   => array('', 'plain', 'text'),
            'Python'  => array('py', 'python'),
            'Ruby'    => array('rb', 'ruby', 'rails', 'ror'),
            'Scala'   => array('scala'),
            'Sql'     => array('sql'),
            'Vb'      => array('vb', 'vbnet', 'vb.net'),
            'Xml'     => array('xml', 'html', 'xhtml', 'xslt'),
        ) );

SyntaxHighligher Evolved: Modify the syntaxhighlighter.php found in the syntaxhighlighter folder by adding a registration for the brush in function _construct().

wp_register_script( 'syntaxhighlighter-brush-coldfusion',       plugins_url('syntaxhighlighter/syntaxhighlighter/scripts/shBrushColdFusion.js'),       array('syntaxhighlighter-core'), $this->agshver );

Add ColdFusion to the list of aliases.

'coldfusion'    => 'coldfusion',
'cf'            => 'coldfusion',

How to Use the ColdFusion Brush

Wrap the code you want to display in your post using one of the following methods:

[sourcecode language=’coldfusion’]code here[/sourcecode]
[sourcecode language=’cf’]code here[/sourcecode]
[coldfusion]code here[/coldfusion]
[cf]code here[/cf]

Personally I like the last method the best.


ColdFusion brush javascript code (change extension to .js before uploading)

9 Comments for ColdFusion Brush for SyntaxHighlighter Plus and Evolved


Alex Gorbatchev
May 23, 2009

Good job on the CF brush? Would you mind me including it into the next release?


jen
May 23, 2009

@Alex
Yes, feel free. And thank you for making the SyntaxHighlighter available in the first place.


amclean
May 27, 2009

I struggled for ages with another developer’s custom brush for cfml, but your instructions were clear and concise.
It worked right away.
Already applied to my site.
Thanks so much.


jen
May 27, 2009

@amclean

You’re welcome!

[...] on my site it does. Well I can’t take the credit, a quick Google search yields the true source, http://www.jensbits.com/2009/05/14/coldfusion-brush-for-syntaxhighlighter-plus/. var addthis_pub = ‘amclean’; var addthis_language = ‘en’;var addthis_options = ‘email, [...]


michiel
June 13, 2009

Very clear explanation, after a little struggle I got it to work. I got the shBrushColdFusion.js file from another source (Google code) and that gave me the error message “Can’t find brush for: cf”.

Using your explanation and your source file it all worked fine. Thanks a bunch!

[...] Link via jensbits.com [...]


Abel Braaksma
September 21, 2009

Excellent brush, really! I added your brush to my ever increasing list of bundled and non-bundled SyntaxHighlighter brushes (http://www.undermyhat.org/blog/2009/09/list-of-brushes-syntaxhighligher/) and would like to ask you whether I can either put a direct link to a *.js file, or make a copy of your code and place it on my server for convenience download


jen
September 21, 2009

@Abel
Thank you. Feel free to do whatever you would like with the file. It’s free to use any way you wish.

Leave a comment

Why ask?

 

« | »